bravo14 Posted April 16, 2011 Share Posted April 16, 2011 Hi I am trying to send html emails to users when they register on a site. I am using the code below <?php //email settings $to=$_POST['user_name']; $from="Trade-Bidz <registrations@trade-bidz.co.uk>"; $subject = "Trade-Bidz Registration Confirmation"; $content = "Hello ".$_POST['contact_name']."<p>Welcome to <a href=\"http://www.trade-bidz.co.uk\">Trade-Bidz</a>. Add us to your Favourite and make it quicker to sell your part exchanges.</p><p>Your Login details are below, you will need these to be able to sell your vehicles and to be able to place bids on other vehicles</p> <p>Email Address:".$_POST['user_name']."<br/> Password:".$_POST['password']."</p> <p>We hope you have great success with Trade-Bidz.</p> <p>Kind Regards</p> <p>The Trade-Bidz Team</p>"; $message=('<html><head> <link href="http://www.trade-bidz.co.uk/style/trade-bidz.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="header"> </div> <img src="http://www.trade-bidz.co.uk/images/logo.jpg" width="300" /></div> <div id="content">'. $content.'</div> <div id="footer">© Trade-Bidz 2011</div> </body></html>'); $headers ="MIME-Version: 1.0rn"; $headers .= "Content-type : text/html; charset=iso=8859-1rn"; $headers .= "From: $from\r\n"; $headers .= "Reply-To: noreply@trade-bidz.co.uk"; mail($to, $subject, $message, $headers); echo ('Registration email has been sent'); ?> When the user registers, the code displays as a page in the browser, and the email that is sent displays the html code What am I doing wrong? Quote Link to comment Share on other sites More sharing options...
DavidAM Posted April 16, 2011 Share Posted April 16, 2011 $headers ="MIME-Version: 1.0rn"; $headers .= "Content-type : text/html; charset=iso=8859-1rn"; That should be \r\n on the end of those lines, not rn Quote Link to comment Share on other sites More sharing options...
bravo14 Posted April 17, 2011 Author Share Posted April 17, 2011 Hi I have amended the code, which now looks like <?php //email settings $to=$_POST['user_name']; $from="Trade-Bidz <registrations@trade-bidz.co.uk>"; $subject = "Trade-Bidz Registration Confirmation"; $content = "Hello ".$_POST['contact_name']."<p>Welcome to <a href=\"http://www.trade-bidz.co.uk\">Trade-Bidz</a>. Add us to your Favourite and make it quicker to sell your part exchanges.</p><p>Your Login details are below, you will need these to be able to sell your vehicles and to be able to place bids on other vehicles</p> <p>Email Address:".$_POST['user_name']."<br/> Password:".$_POST['password']."</p> <p>We hope you have great success with Trade-Bidz.</p> <p>Kind Regards</p> <p>The Trade-Bidz Team</p>"; $message=('<html><head> <link href="http://www.trade-bidz.co.uk/style/trade-bidz.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="header"> </div> <img src="http://www.trade-bidz.co.uk/images/logo.jpg" width="300" /></div> <div id="content">'. $content.'</div> <div id="footer">© Trade-Bidz 2011</div> </body></html>'); $headers ="MIME-Version: 1.0\r\n"; $headers .= "Content-type : text/html; charset=iso=8859-1\r\n"; $headers .= "From: $from\r\n"; $headers .= "Reply-To: noreply@trade-bidz.co.uk"; mail($to, $subject, $message, $headers); echo ('Registration email has been sent'); ?> The message is being displayed in a browser, I want to stop the message displaying ina browser, and the email that is received is blank. Please help me. Quote Link to comment Share on other sites More sharing options...
DavidAM Posted April 18, 2011 Share Posted April 18, 2011 I copied that code to a new script file, put in my email address for TO and FROM. And ran it. The message was not displayed in the browser (except for the "Registration email has been sent" message that you echo at the end) and the email I received contained the text from your script - including the image (which is pretty cool). In other words, that code works exactly as you want it to, for me. Quote Link to comment Share on other sites More sharing options...
OGirly Posted April 18, 2011 Share Posted April 18, 2011 yeppers works perfectly here as well! Don't you hate when things work on others machines but not your own, it's like Best wishes, ~ alice Quote Link to comment Share on other sites More sharing options...
bravo14 Posted April 19, 2011 Author Share Posted April 19, 2011 The problem is with the webmail I am using, my host has advised me remove the link to the CSS file and have the style defined in the email. Very strange. 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.