Jump to content

Sending HTML Emails through PHP


Mzor

Recommended Posts

Hey guys! Been a long time since I've posted here but I am back for help because I'm encountering a problem that's kind of baffling me.

 

I'm programming a web game, and one of the things that happens is that an email gets sent out when it's your turn in one of your games. This is working fine and all but I can not for the life of me figure out how to send email with html in it that is universally accepted. What I've been doing so far works for gmail, hotmail, etc. but for some reason breaks entirely when someone opens an email with a client like Thunderbird or Outlook.

 

Here's what I've been doing:

 

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Admin <admin@examplesite.com>' . "\r\n";
  
$mail_body = '<html><body>It is now your turn in the game. The game can be viewed <a href="examplesite.com">here</a>.</body></html>';

mail("user@examplesite.com",'New Turn',$mail_body,$headers);

 

Is there something I'm missing? I have literally no experience using Outlook or the like so I don't know if it's a problem with them or if I'm doing something wrong.

Link to comment
Share on other sites

Oh, basically the link just doesn't work. It turns up as plain text... the html tags don't show, so obviously it recognizes it is HTML, but there is simply no link, whereas there is a link when using Gmail.

Link to comment
Share on other sites

Have you tried sending it without specifying the headers as html? When my header is basic like "From donotreply@whatever.com", usually just pasting the url is enough because then the email client(gmail, hotmail, etc) will convert it into a hyperlink automatically.

 

Also, have you tried taking out the "<html><body>" of the email? I feel like that part might clash with the email client's <html> and <body> tags which it has in the beginning of its html code.

 

 

But your note "but there is simply no link, whereas there is a link when using Gmail." makes me think that if the client has detected the email as spam, that would be one reason why it stripped the html. Or as stated above, there are probably settings in outlook/etc where you can specify how html is treated based on the address it arrives from

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.