EchoFool Posted May 27, 2010 Share Posted May 27, 2010 When a user registers i send them an activation email but my mail function doesn't work properly even though i got it from the php website. The headers is my problem they won't work so <br> just comes through as text rather than actually using it as html. My script: <?php $subject = "Welcome"; $headers = 'From: Company Name'; $headers .= 'Reply-To: '.$Domain; $headers .= 'MIME-Version: 1.0'; $headers .= 'Content-type: text/html; charset=iso-8859-1'; $message = 'Thank you for registering! <br><br> To activate your account, please visit this link:'; $message = $message. "<br><br> ".$Link; $message = $message. '<br><br> Your username is: '.$Username.' <br>You password is: '.$Password2.' !'; mail($Email, $subject, $message, $headers); ?> What am i doing wrong with my headers? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted May 27, 2010 Share Posted May 27, 2010 Where is the variable $Email being set? That should be the email address of the recipient. Ken Quote Link to comment Share on other sites More sharing options...
-Karl- Posted May 27, 2010 Share Posted May 27, 2010 $subject = "Welcome"; $headers = 'From: Company Name'; $headers .= 'Reply-To: [email]DoNotReply@domain.com[/email]'; $headers .= 'MIME-Version: 1.0'; $headers .= 'Content-type: text/html; charset=iso-8859-1'; $message = "Thank you for registering!.\n\n"; $message = $message. "To activate your account, please visit this link:.\n\n"; $message = $message. "[url=http://www.google.com]www.google.com[/url].\n\n"; $message = $message. 'Your username is: '.$Username.' <br>You password is: '.$Password2.' !'; mail($Email, $subject, $message, $headers); That's for the breaks I believe. Quote Link to comment Share on other sites More sharing options...
EchoFool Posted May 27, 2010 Author Share Posted May 27, 2010 Where is the variable $Email being set? That should be the email address of the recipient. Ken That is further up the script. I do recieve the email but it comes out showing the "<br>" rather than acting as HTML. @Karl the method you used isn't what im trying to do sorry, im trying to allow the email to use HTML so itll convert "<br>" into new lines. Quote Link to comment Share on other sites More sharing options...
-Karl- Posted May 27, 2010 Share Posted May 27, 2010 Oh in that way, you're missing <html>, <head> and <body> tags. That's basic HTML. $message = '<html> <head> <title>Welcome</title> </head> <body> Thank you for registering!<br/><br/> To activate your account, please visit this link:<br/> <a href="link">Link</a><br/><br/> Your username is: '.$Username.' <br>You password is: '.$Password2.' ! </body> </html>'; Something like that. Quote Link to comment Share on other sites More sharing options...
EchoFool Posted May 27, 2010 Author Share Posted May 27, 2010 Yeah tried that it just shows them aswell... Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 27, 2010 Share Posted May 27, 2010 Each header line must be terminated by a \r\n (inside of double-quotes). Also, your From: header must be an actual email address and it must be hosted at the sending mail server. The Reply-to: header must be an email address (it's not clear from the code you posted.) Quote Link to comment Share on other sites More sharing options...
EchoFool Posted May 27, 2010 Author Share Posted May 27, 2010 How come when i recieve emails from things like facebook in Gmail then it says "From : Facebook" Rather than a website email ? The Reply to is "donotreply@domain.com" which isn't a real email address at my server cos people are not suppose to reply. Edit the /r/n worked perfectly Thanks Quote Link to comment Share on other sites More sharing options...
-Karl- Posted May 27, 2010 Share Posted May 27, 2010 $headers .= 'From: Your Website <admin@website.com>' . "\r\n"; Quote Link to comment Share on other sites More sharing options...
EchoFool Posted May 27, 2010 Author Share Posted May 27, 2010 Oh thanks One final question, when i send an email to a user it says "Mailed-by: server.domain.com" But other emails from other companies do not seem to, why is this ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.