hedjr01 Posted March 24, 2007 Share Posted March 24, 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 when using the form below. Visitors click on a profile ('offer') page of a given advertiser ($AgentName) contained in the "yellow_agents" db table, then can click a link to the form below to send the advertiser an email. It all seems to operate ok, but no email arrives. Each "Agent" has an email address in the db. To test I set myself up as an advertiser with a valid email address, then used the form to send myself a message. None appeared. Everything else looks ok, so I am guessing this is a script error. 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. So that seems ok. That's about the extent of my abilities. I am hoping someone could look over the following form and script and see if you can spot any errors I have missed. This form and script came as part of a software package that did not include a php.ini file. If I am not showing the correct script files for review, pls. advise. I'm new at this. Thanks!! >>>>>>>>>>>Email 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> <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> >>>>>>>>>>>>>>>>>>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> Thank you for your message! <a class=RedLink href=\"info.php?id=$_GET[AgentID]\">back to the offer details[/url]</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!!! Link to comment https://forums.phpfreaks.com/topic/44146-php-email-dilema/ Share on other sites More sharing options...
AndyB Posted March 24, 2007 Share Posted March 24, 2007 //donotmail($to, $subject, $message, $headers); Perhaps you want to uncomment that and try again? mail($to, $subject, $message, $headers); Link to comment https://forums.phpfreaks.com/topic/44146-php-email-dilema/#findComment-214417 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.