synking Posted October 22, 2009 Share Posted October 22, 2009 hey i am having an issue sending email from mail() $to = $_POST['carrier']; $to .= '[email protected]'; $subject = 'Access Numbers Down'; $message = wordwrap($_POST['number'], 70); $headers = 'From: [email protected]' . "\r\n" ; $headers .= 'Reply-To: [email protected]' . "\r\n" ; $headers .= 'X-Mailer: PHP/' .phpversion(); $sent = mail($to, $subject, $message, $headers); if($sent) { echo 'message was sent'; } else { echo 'message not sent'; } the code comes from this form. <form method="POST" id="access_number_issue" action="#" name="reporting_access" target="_SELF"> <table> <tr> <td colspan="2" class="labelcell"><label for="Number">Number to report:</label></td> <td colspan="2" class="fieldcell"><input type="text" name="number" id="number" tabindex="1" size="20" maxlength="30"> </tr> <tr> <td colspan="2" class="labelcell"><label for="carrier">Carrier</label></td> <td colspan="2" class="fieldcell"><Select name="carrier" id="change" tabindex="2"> <option value="[email protected]">test</option> <?php foreach ($carrierchange as $key => $value) { echo ("<option value=\"$key\">$value</option>\n"); } ?> </select></td> </tr> <tr> <td colspan="2" class="labelcell"><label for="test account">Test Account</label></td> <td colspan="2" class="fieldcell"><select name="account" id="change" tabindex="3" size="1"> <?php foreach ($testaccount as $key => $value) { echo ("<option value=\"$key\">$value</option>\n"); } ?> </select></td> </tr> <tr> <td colspan="2"><input type="submit" value="Submit" name="search" class="button" tabindex="4"></td> <td colspan="2"><input type="reset" value="reset" name="reset" class="button" tabindex="5"></td> </tr> </table> It did work at one time but sent only a blank email now it does not send at all. EDIT: can anyone point me in the right direction. Quote Link to comment https://forums.phpfreaks.com/topic/178629-solved-php-mail-not-sending/ Share on other sites More sharing options...
Daniel0 Posted October 22, 2009 Share Posted October 22, 2009 Have you setup an SMTP server/MTA on your server? Quote Link to comment https://forums.phpfreaks.com/topic/178629-solved-php-mail-not-sending/#findComment-942156 Share on other sites More sharing options...
synking Posted October 22, 2009 Author Share Posted October 22, 2009 yes the server the script is on is the actual server to get the support email from. Quote Link to comment https://forums.phpfreaks.com/topic/178629-solved-php-mail-not-sending/#findComment-942161 Share on other sites More sharing options...
synking Posted October 22, 2009 Author Share Posted October 22, 2009 Ok hey i was able to get the mail to send but the message is blank there is nothing there. it comes from [email protected]. goes to the [email protected] the headers are there but nothing appears in the message it's self any ideas. Quote Link to comment https://forums.phpfreaks.com/topic/178629-solved-php-mail-not-sending/#findComment-942186 Share on other sites More sharing options...
synking Posted October 22, 2009 Author Share Posted October 22, 2009 Actually i found that if i don't not send the message from the post it works fine but if i try to pass post data it does not send. even if i create a variable that contains the post data it will not send but if i change the variable to anything else it will work. any ideas. Quote Link to comment https://forums.phpfreaks.com/topic/178629-solved-php-mail-not-sending/#findComment-942266 Share on other sites More sharing options...
synking Posted October 23, 2009 Author Share Posted October 23, 2009 Ok i am still having issues with this. here is the entire page as it stands now. <?php error_reporting(E_ALL); echo '<pre>'; print_r($_POST); echo '</pre>'; $carrierchange = array ( '[email protected]' => "Cisp", '[email protected]' => "Cogent", '[email protected]' => "PNG", ); $carrierchange = str_replace(" ", "", $carrierchange); $testaccount = array ( '[email protected]' => "Cisp Test", '[email protected]' => "test1", '[email protected]' => "testconnect", ); $testaccount = str_replace(" ", "", $testaccount); $to = $_POST['carrier']; $to .= '[email protected]'; $subject = 'Access Numbers Down'; $mess = $_POST['number']; $mess = str_replace (" ","\r\n", $mess); $message = wordwrap($mess, 70); $headers = 'From: [email protected]' . "\n" ; $headers .= 'Reply-To: [email protected]' . "\n" ; $headers .= 'X-Mailer: PHP/' .phpversion(); $sent = mail($to, $subject, $message, $headers); echo ($sent); ?> <html> <head><title></title> </head> <body> <form method="POST" id="access_number_issue" action="#" name="reporting_access" target="_SELF"> <table> <tr> <td colspan="2" class="labelcell"><label for="Number">Number to report:</label></td> <td colspan="2" class="fieldcell"><input type="text" name="number" id="number" tabindex="1" size="60" maxlength="60"> </tr> <tr> <td colspan="2" class="labelcell"><label for="carrier">Carrier</label></td> <td colspan="2" class="fieldcell"><Select name="carrier" id="change" tabindex="2"> <option value="[email protected]">test</option> <?php foreach ($carrierchange as $key => $value) { echo ("<option value=\"$key\">$value</option>\n"); } ?> </select></td> </tr> <tr> <td colspan="2" class="labelcell"><label for="test account">Test Account</label></td> <td colspan="2" class="fieldcell"><select name="account" id="change" tabindex="3" size="1"> <?php foreach ($testaccount as $key => $value) { echo ("<option value=\"$key\">$value</option>\n"); } ?> </select></td> </tr> <tr> <td colspan="2"><input type="submit" value="Submit" name="search" class="button" tabindex="4"></td> <td colspan="2"><input type="reset" value="reset" name="reset" class="button" tabindex="5"></td> </tr> </table> </form> </body> </html> If i go to the page fresh the first time it will send a blank email. If i attempt to fill out the form nothing is sent. The php script does not send it is not an issue with it being rejected the form will not send. I don't know why it will not send i do not get an error from php. Quote Link to comment https://forums.phpfreaks.com/topic/178629-solved-php-mail-not-sending/#findComment-942835 Share on other sites More sharing options...
synking Posted October 23, 2009 Author Share Posted October 23, 2009 i figured it out the script was failing because of the multiple to fields. Quote Link to comment https://forums.phpfreaks.com/topic/178629-solved-php-mail-not-sending/#findComment-942861 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.