Mzor Posted March 2, 2012 Share Posted March 2, 2012 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 <[email protected]>' . "\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("[email protected]",'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. Quote Link to comment https://forums.phpfreaks.com/topic/258128-sending-html-emails-through-php/ Share on other sites More sharing options...
The Little Guy Posted March 2, 2012 Share Posted March 2, 2012 describe how it breaks? Quote Link to comment https://forums.phpfreaks.com/topic/258128-sending-html-emails-through-php/#findComment-1323204 Share on other sites More sharing options...
Mzor Posted March 2, 2012 Author Share Posted March 2, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/258128-sending-html-emails-through-php/#findComment-1323222 Share on other sites More sharing options...
The Little Guy Posted March 3, 2012 Share Posted March 3, 2012 it is more than likely the client program settings. I believe when you send an email as html, it also sends as plain text and the client is probably set up to use the plain text version by default, otherwise it just strips the tags. Quote Link to comment https://forums.phpfreaks.com/topic/258128-sending-html-emails-through-php/#findComment-1323349 Share on other sites More sharing options...
dannyb785 Posted March 3, 2012 Share Posted March 3, 2012 Have you tried sending it without specifying the headers as html? When my header is basic like "From [email protected]", 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 Quote Link to comment https://forums.phpfreaks.com/topic/258128-sending-html-emails-through-php/#findComment-1323369 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.