0

i want to send a mail the code is given below. i cant understand waht is happening . It works on localhost but not on live server.

if (isset($_POST['test_mail'])){
                            $to             =   '2606ankit@gmail.com';  //put email address on which mail send
                           $subject     =   "Newsletter";                   //Put subject of mail here
                           $from        =   'ankit@studiokrew.com';     //put email address from 
                           //email body start
                          // $body    .=    file_get_contents('file/'.$filename.'');
                           $body      .= 'anio';
                           // Always set content-type when sending HTML email
                            $headers = "MIME-Version: 1.0" . "\r\n";
                            $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

                            // More headers
                            $headers .= 'From: '.$from. "\r\n";

                            //if you need to send cc mail then uncomment below line and change email address
                            //$headers .= 'Cc: myboss@example.com' . "\r\n";

                         mail($to,$subject,$body,$headers); 

  }
Ankit Sharma
  • 17
  • 1
  • 8

3 Answers3

1
 try this..
 <?php  if (isset($_POST['test_mail'])){
   $host=$_SERVER['HTTP_HOST'];
   $replyto="<no-reply >";
   $to ='2606ankit@gmail.com'; 
   $subject = "Newsletter"; 
   $from  = 'ankit@studiokrew.com';
   $headers = "From: \"Invoice\"<noreply@$host>\n";
   $headers .= "Reply-To: ".$replyto."\r\n";
   $headers .= "MIME-Version: 1.0\r\n";
   $headers .= "Content-Type: multipart/mixed; boundary=\"abc"\"\r\n\r\n";
   $headers .= 'From: '.$from. "\r\n";
   $header .= "Content-Type:text/html; charset=\"iso-8859-1\"\n";
   $body = "This is a multi-part message in MIME format.\r\n";
   $body .= "Content-type:text/html; charset=iso-8859-1\r\n";
   $body .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; 
   $body      .= 'anio';                          
   mail($to,$subject,$body,$headers); 
}

?>

Sharma Vikram
  • 2,440
  • 6
  • 23
  • 46
0

check the MTA logs on your server.also web server logs the answer will be there somewhere.

Jasen
  • 11,837
  • 2
  • 30
  • 48
0

Test with a simple mail() script that does not require any external data, just to make sure that your server indeed can send mail. If that fails, you'd have to contact the server admins for help.

budhajeewa
  • 2,268
  • 1
  • 17
  • 19