hedjr01 Posted March 20, 2007 Share Posted March 20, 2007 Hi folks, I cannot seem to get my php email system to work. It fails to send email messages to recipients contained in a MySql db. I checked in MySql to verify that each recipient has a valid email address in the db and that the db field name (email) matches the script. I am hoping someone could look over the following form and script and see if you can spot any errors I have missed. Thanks!! >>>>>>>>>>>I use the following form for visitors:<<<<<<<<<<<<<<<<<< <script> function CheckMail() { if(document.je.u_name.value=="") { alert('Enter your name, please!'); document.je.u_name.focus(); return false; } if(document.je.u_email.value=="") { alert('Enter your email, please!'); document.je.u_email.focus(); return false; } if(document.je.subject.value=="") { alert('Enter the subject, please!'); document.je.subject.focus(); return false; } if(document.je.message.value=="") { alert('Enter your message, please!'); document.je.message.focus(); return false; } } </script> <br><br> <form method=post onsubmit="return CheckMail();" name=je> <table width=340 align=center border=0> <caption align=center><span style="font-size:11; font-family:verdana; color:black; font-weight:bold">Use this form to contact <?=$AgentName?></span></caption> <tr> <td>Name:</td> <td><input type=text name="u_name" size=42 class="mtext"></td> </tr> <tr> <td>Email:</td> <td><input type=text name=u_email size=42 class="mtext"></td> </tr> <tr> <td>Subject:</td> <td><input type=text name=subject size=42 class="mtext" value="<?=$SubjectLine?>"></td> </tr> <tr> <td valign=top>Message:</td> <td><textarea rows=6 cols=41 name=message class="mtext"><?=$_POST[message]?></textarea></td> </tr> <tr> <td> </td> <td> <input type=submit name=s1 value="Send" class="sub1"> </td> </tr> </table> </form> >>>>>>>>>>>>>>>>>>I use the following email PHP script: <<<<<<<<<<<<<<<<<<<<<<< <? require_once("conn.php"); require_once("includes.php"); //get the agent info $q1 = "select * from yellow_agents where AgentID = '$_GET[AgentID]' "; $r1 = mysql_query($q1) or die(mysql_error()); $a1 = mysql_fetch_array($r1); if(isset($_POST[s1])) { $to = $a1; $subject = $_POST[subject]; $message = $_POST[message]; $message .= "\n\nOffer:\nhttp://$_SERVER[HTTP_HOST]/info.php?id=$_GET[AgentID]\n\n"; $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\n"; $headers .= "Content-Transfer-Encoding: 8bit\n"; $headers .= "From: $_POST[u_name] <$aset[ContactEmail]>\n"; $headers .= "Reply-To: $_POST[u_name] <$_POST[u_email]>\n"; $headers .= "X-Priority: 3\n"; $headers .= "X-MSMail-Priority: Normal\n"; $headers .= "X-Mailer: PHP/" . phpversion(); //donotmail($to, $subject, $message, $headers); $thankyou = "<center><b><br><br><br>Thank you for your message!<br><br><a class=RedLink href=\"info.php?id=$_GET[AgentID]\">back to the offer details</a></center>"; //get the templates require_once("templates/HeaderTemplate.php"); require_once("templates/EmailThankyouTemplate.php"); require_once("templates/FooterTemplate.php"); } $AgentName = "$a1[FirstName] $a1[LastName]"; //get the templates require_once("templates/HeaderTemplate.php"); require_once("templates/EmailTemplate.php"); require_once("templates/FooterTemplate.php"); ?> Anyone see an error or inconsistency in these????? Thanks!!! Quote Link to comment https://forums.phpfreaks.com/topic/43506-php-email-problem/ Share on other sites More sharing options...
trq Posted March 20, 2007 Share Posted March 20, 2007 Are you posting this in the Installation forum because you are unsure as to wether or not you have a valid email server setup or what? What does the email section of your php.ini look like? Quote Link to comment https://forums.phpfreaks.com/topic/43506-php-email-problem/#findComment-211277 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.