• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

phpmailer sending email as hyperlinked

I am using phpmailer to generate emails.  In the body of the email I want to include a link to our site, but I do not want the actual url to be displayed - just a "click here" .  My code is like this:

      $mail->Subject =  ' Can You View?';

      $message = '<html><body><p><a href="http://www.amazon.com" >Click Here</a> to go shopping!</p></body></html>';
      
      $mail->MsgHTML($message);

But the email displays:
Click Here <http://www.amazon.com>  to go shopping!

The link works - I just don't want to display the url.
0
PegOC96
Asked:
PegOC96
1 Solution
 
nickinthoozCommented:
try this...see if it changes anything

$mail->IsHTML(true);
$mail->Subject =  ' Can You View?';
$mail->Body= '<html><body><p><a href="http://www.amazon.com" >Click Here</a> to go shopping!</p></body></html>';

$mail->Send();

Open in new window


or this:
$Body= '<html><body><p><a href="http://www.amazon.com" >Click Here</a> to go shopping!</p></body></html>';
    $mail->IsHTML(true);  
    $mail->Subject  =   ' Can You View?';
 
	$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
	$mail->MsgHTML($Body);
 
	$mail->CharSet="UTF-8";
 
    if(!$mail->Send())
    {
        echo "Mailer Error: " . $mail->ErrorInfo;
    }
    else
    {
        echo 'Message has been sent.';
    }

Open in new window

0
 
PegOC96Author Commented:
I had tried those and it still worked the same.  However, I've realized that the problem is in my email program, not the code.  I usually view my email using Entourage on a Mac.  And that is where it is not working. But when I view the same email through web mail or a mail program on a different computer (Outlook), it does appear correctly.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now