php_begins Posted September 29, 2011 Share Posted September 29, 2011 Hi I am having trouble sending emails with html content. My $content variable is defined as follows: $content='<html><body> lots of html data with tables and rows here </body></html>'; But when I execute the code, it says 'Mail sent', but I do not get any email. if i just define $body="hello", it sends me the email. Here is my code to send the email <? $to = "test@gmail.com"; $subject = "test"; $body=$content; $from = "webmaster@example.com"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Admin <Admin@test.com>' . "\r\n"; // Send email if(mail($to,$subject,$body,$headers)) { // Inform the user echo "Your email has been sent"; } else { echo "MAIL not sent"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/248130-email-with-html-elements-not-sent/ Share on other sites More sharing options...
Jacbey Posted September 29, 2011 Share Posted September 29, 2011 Well, first off, the email address it is sending it too is "test@gmail.com". That's your problem. Change it to your email address. Quote Link to comment https://forums.phpfreaks.com/topic/248130-email-with-html-elements-not-sent/#findComment-1274151 Share on other sites More sharing options...
php_begins Posted September 29, 2011 Author Share Posted September 29, 2011 well i am sending it to my email address..i just didnt want to display my email address here :-) Quote Link to comment https://forums.phpfreaks.com/topic/248130-email-with-html-elements-not-sent/#findComment-1274154 Share on other sites More sharing options...
Howlin1 Posted September 29, 2011 Share Posted September 29, 2011 Have you tried sending the email (content included) to a non gmail address? Quote Link to comment https://forums.phpfreaks.com/topic/248130-email-with-html-elements-not-sent/#findComment-1274178 Share on other sites More sharing options...
mikesta707 Posted September 29, 2011 Share Posted September 29, 2011 Sometimes mail sent via the built in smtp protocol in PHP has some problems. Make sure of a few things A.)Your SMTP server is actually up and running B.)You check your spam folder and such C.)Your email address/info is correct D.)Your header information is formed correctly. D is especially important as some email providers dont allow emails with malformed headers Quote Link to comment https://forums.phpfreaks.com/topic/248130-email-with-html-elements-not-sent/#findComment-1274180 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.