Hi there, just managed to get a email activation working using php mailer but for some reason it only prints out the url as text and not a link. I have since removed the <a> around the url to make it easier for suggestions.

I reckon this is a fairly simple problem but its been holding me back for some time.

require_once('lib/class.phpgmailer.php');
$mail = new PHPGMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = 'ssl://smtp.gmail.com'; // SMTP servers
$mail->Username = '***@gmail.com';
$mail->Password = '*****';
$mail->From = '****@gmail.com';
$mail->FromName = 'test';
$mail->Subject = 'test Registration';
$mail->AddAddress($email);
$mail->Body = "Your account has been successfully created with the following details:\n\nUsername: $username\nPassword: $password\nEmail: $email\nForename: $forename\nSurname: $surname\nLocation: $location\n\nPlease click on the link to activate your account.\n";
$mail->Body .= "http://localhost/Ad'll%20Do/activate.php?username=$username&&do=$active_code"; 
if (!$mail->Send()) {
echo "<span class='highlight'>Email was not sent.</sapn></p>";
echo "<p>Mailer Error: $mail->ErrorInfo</p></div>";
} else {
echo "<span class='highlight'>Email has been sent.</span></p></div>";
}

    PHP Mailer send mails in plain text , by default, you need to tell it that you're going to send an HTML email by using $mail->IsHTML(true), then you can use anchor tags.

    Since some email clients do not support HTML, and some users turn off HTML support on those that do for security, its best to also send the message in plain text.

    Here's an example: I've added block comments around the new bits

    /* NEW STUFF PART 1 */
    // Setup the two templates
    $html = "<p>This is the <b>HTML Version</b> of the email.<br /><br />Notice how I have used HTML tags to format <i>this email</i>  I can now use an anchor tag to create a link such as <a href=\"http://www.mysite.com\">MySite.com</a>.</p>";
    $text = "This is the plain text version.\n\nSo I can't make it have an active link.  Though putting in the url in full http://www.mysite.com may convert this into a link in some email clients";
    /* END OF NEW STUFF PART 1*/
    
    
    
    // Your part
    require_once('lib/class.phpgmailer.php');
    $mail = new PHPGMailer();
    $mail->IsSMTP(); // send via SMTP
    $mail->Host = 'ssl://smtp.gmail.com'; // SMTP servers
    $mail->Username = '***@gmail.com';
    $mail->Password = '*****';
    $mail->From = '****@gmail.com';
    $mail->FromName = 'test';
    $mail->Subject = 'test Registration';
    $mail->AddAddress($email);
    
    /* NEW STUFF PART 2 */
    // Set it to use HTML
    $mail->IsHTML(true);
    $mail->Body = $html;  // Set the HTML version as the normal body
    $mail->AltBody = $text;  // Set the plain text version to AltBody 
    /* END OF NEW STUFF PART 2 */
    
    
    // Back to your stuff
    if (!$mail->Send()) {
    echo "<span class='highlight'>Email was not sent.</sapn></p>";
    echo "<p>Mailer Error: $mail->ErrorInfo</p></div>";
    } else {
    echo "<span class='highlight'>Email has been sent.</span></p></div>";
    }
    
    
      Write a Reply...