icklechurch Posted March 12, 2009 Share Posted March 12, 2009 Hello, I'm just setting up an email to be sent when a user goes to a certain page. The current code I have is: $Name = "create"; //senders name $email = "downloads@xyz.com"; //senders e-mail adress $recipient = "me@xyz.co.uk"; //recipient $mail_body = "Please click <a href='http://www.xyz.com'>here</a> to access the downloads."; //mail body $subject = "Download Details"; //subject $header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields mail($recipient, $subject, $mail_body, $header); //mail command Problem is, that the message won't send and I think it's something to do with the <a href=""></a> being in the code? Can anyone point me in the right direction?! Thanks Quote Link to comment Share on other sites More sharing options...
kev wood Posted March 12, 2009 Share Posted March 12, 2009 change what you need in this and use this code it works fine for me. $message .= '<body leftmargin="0" topmargin="0"> <table width="700" border="0" align="center" cellpadding="0" cellspacing="5"> <tr> <td>The ' . $table . ' section of the <a href="piponline.info"> PiPonline website</a> has been updated. Please follow the link to see the new content. </tr> </table> </body>'; $query = "SELECT * FROM emails WHERE page = '$table'"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { $contactemail = $row['email']; // Contacts //$replyName = $merc_replyId; //$replyEmail = $merc_replyAddress; $replyName = "PiPonliine"; $replyEmail = "info@piponline.info"; $contactname = ""; // Subject $subject = "Website Update"; // Headers $headers = "MIME-Version: 1.0" . PHP_EOL; $headers .= "Content-type: text/html; charset=iso-8859-1" . PHP_EOL; $headers .= "From: ".$replyName." <".$replyEmail.">" . PHP_EOL; $headers .= "BCC: ".$contactname." <".$contactemail.">\r\n" . PHP_EOL; mail($contactemail, $subject, $message, $headers); } as you can see from my script i am pulling all the email address details from a mysql db. that bit can be taken out or changed to match up with your db if you have it set that way or just take that section out and change this line $headers .= "BCC: ".$contactname." <".$contactemail.">\r\n" . PHP_EOL; to just hold the email address you want the mail sent to . Quote Link to comment Share on other sites More sharing options...
kev wood Posted March 12, 2009 Share Posted March 12, 2009 also remember if you are sending to more than one user to put all the address in the BCC so only the persons email address shows up in there inbox and they cannot see everyones email address it was sent to. Quote Link to comment Share on other sites More sharing options...
phpretard Posted March 12, 2009 Share Posted March 12, 2009 ...and hope they don't "reply all" Quote Link to comment Share on other sites More sharing options...
icklechurch Posted March 12, 2009 Author Share Posted March 12, 2009 Thanks! Bit of re-jigging and all sorted. Quote Link to comment Share on other sites More sharing options...
kev wood Posted March 12, 2009 Share Posted March 12, 2009 sound. happy i could help. 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.