Jump to content

[SOLVED] php mail() not sending.


synking

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/178629-solved-php-mail-not-sending/
Share on other sites

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.