-1

I have some problem in sending the mail, my mail not send to the receiver.. but get back email to me. my code is here please suggest me

 <?php 
   if(isset($_POST["c_submit"]))
   {
    if(($_POST['captcha']!="") || ($_SESSION['captcha_id'])!="")
    {
     if($_POST['captcha']==$_SESSION['captcha_id']) { 
        $to_customer = $_POST["mail"];
    $subject = "Thanking you for Contacting US";

    $mail_body = "

   <html>
    <head>
   <title>Thanking you for Contacting</title>

   </head>
    <body>
   <font face='Verdana'>
   Dear&nbsp;&nbsp;".$_POST["name"].",</br>

   <p>Thank you for visiting our website. We have received your enquiry through our web         form. We appreciate you considering</p>

      <p>Sincerely,</p>
        <b>Penis Plug. Ltd.</b><br />
      Website:". $site."<br />
        Email:" .$email."<br />

         <br />
      <br />

       </font>
     </body>
         </html>";
       $to = "ashish.sws@gmail.com";
        $mail_subject = "Contact Form Mail";
       $to_mail_body = "
        <htm>
     <head>
       <title>Customer Details</title>
       </head>
       <body>
        <font face='Verdana'>
         <table>
        <tr>
       <th>Name : </th>
      <td>".$_POST["name"]."</td>
         </tr>
          <tr>

         <tr>
          <th>Message : </th>
         <td>".$_POST["message"]."</td>
        </tr>

        <tr>
          <th>Email </th>
         <td>".$_POST["email"]."</td>
            </tr>

        <tr>
            <th>Contact No. : </th>
           <td>".$_POST["phone"]."</td>
          </tr>



         <tr>
          <th>Company : </th>
          <td>".$_POST["company"]."</td>
           </tr>

           </table>
           </font>
           </body>
           </html>
    ";

    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
     $headers .= 'From:   '.'http://www.swatiwebtechnologies.com'.'<'.'ashish.sws@gmail.com'.'> ' . "\r\n"; 



    if(@mail($to_customer,$subject,$mail_body,$headers))  
    {  
   echo "Mail send completed.";  
   }  
   else  
   {  
   echo "Cannot send mail.";  

     }  


        @mail($to,$mail_subject,$to_mail_body,$headers);


        } else if($_POST['captcha']!=""){

            echo '<font color="red"><b>Not Matching, Try Again...</b></font>';
        }
     }
         }
       ?> 

Here i am sending two mail 1 for customer and one for self in customer mail problem arise and self email working fine..plese suggest me

  • 3
    It doesn't show an error when you use [the error suppression operator](http://www.php.net//manual/en/language.operators.errorcontrol.php)? That doesn't seem very surprising. – Quentin Jun 16 '14 at 13:02
  • Once the message is received by the SMTP server, it is beyond your code's control. When the email "gets back to you" what does the mail server tell you? Why does it not send the message along as intended? Is the same behavior exhibited by other mail servers? – David Jun 16 '14 at 13:05

3 Answers3

1

As per the docs, the function returns false on failure to send.

$flgSend = @mail(...);

If this causes your code to show "Mail send completed.", but it still doesn't appear in your inbox, then either it just hasn't arrived yet or a SPAM filter has caught it.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
0

Try this for checking of email sending

if(@mail($to_customer,$subject,$mail_body,$headers))  
{  
echo "Mail send completed.";  
}  
else  
{  
echo "Cannot send mail.";

} 
Cornel Raiu
  • 2,758
  • 3
  • 22
  • 31
0

Suggestions:

  • What is the exact error, if you remove the error suppression operator?
  • Are you sure the http://www.com in the from: part is valid?
  • Many spam blocking list providers will block your mail if you don't authenticate encryped. Then, an answer get back to your inbox that your mail was not delivered.
  • Search here for "mail php", it will bring you dozens of ideas. Like this: PHP mail() - mail not sending
Community
  • 1
  • 1
peter_the_oak
  • 3,529
  • 3
  • 23
  • 37