Jump to content

simple question


spires

Recommended Posts

In order to send HTML code (that means <a href=... links) in an e-mail, you must let the script know that your message contains html. In theory, this should work:

[code]$link = '<a href="nickyrubin.com/members">login</a>';
$to      = $buyer_email;
$subject = 'Hi '.$firstname.', Nicky Rubin Would like to thank you';
$message = 'Hi '.$firstname.'
Thank you for buying from nickyrubin.com
Here is you username and password
USERNAME = '.$buyer_email.'
PASSWORD = '.$password.'
Please login here'.$link.'';
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

mail($to, $subject, $message, $headers);
  $enter = '<div class="error">An email has been sent containing your username and password.</div>';[/code]

What is in the $headers variable lets the script know it should be formatted as HTML. Please note, however, that means that you must format the rest of your message in HTML. For example, you cannot just format a new line by using a return, you must use < br > (without the spaces) instead.

e.g.

[code]$link = '<a href="nickyrubin.com/members">login</a>';
$to      = $buyer_email;
$subject = 'Hi '.$firstname.', Nicky Rubin Would like to thank you';
$message = 'Hi '.$firstname.'<br>
Thank you for buying from nickyrubin.com<br>
Here is you username and password<br>
USERNAME = '.$buyer_email.'<br>
PASSWORD = '.$password.'<br>
Please login here'.$link.'';<br>
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

mail($to, $subject, $message, $headers);
  $enter = '<div class="error">An email has been sent containing your username and password.</div>';[/code]
Link to comment
https://forums.phpfreaks.com/topic/17984-simple-question/#findComment-76974
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.