0

i am tryind to send an email using my php program

here is my code

  $to = "sunilchhimpa92@gmail.com";
  $subject = "This is subject";
  $message = "This is simple text message.";
  $header = "sunilchhimpa92@yahoo.com \r\n";
 $mail_send = mail($to,$subject,$message,$header);
  echo $to. $subject.$message.$header;
  var_dump($mail_send);
  if( $mail_send == true )  
  {
    echo "Message sent successfully...";
  }
   else
   {
     echo "Message could not be sent...";
   }

here var_dump($mail_send) returning false.

and echo Message could not be sent...

what is the problem with my code

is password of sender mail is required ?

how can i do that ?

Sunil Kumar
  • 311
  • 1
  • 5
  • 16

1 Answers1

0

You can check this in server its working.

$admin_to   = 'bhavesh930@gmail.com';
$a_subject  = 'Subject';
$a_from     = 'someone@gmail.com';
$fromcc     = 'someone@gmail.com';      //for multiple user if required than only          

$a_headers = "MIME-Version: 1.0\r\n";
$a_headers .= "Content-type: text/html; charset=utf-8\r\n";
$a_headers .= "From:".$a_from."\r\n";

$a_headers .= "Bcc: ".$fromcc."\r\n";

$a_message= "<html>
   <body>
        <table width='100%' border='0' cellspacing='0' cellpadding='0'>

    <tr>
        <td>Message</td>
    </tr>

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

 $sendmail =  @mail($a_to,$a_subject,$a_message,$a_headers);
bhavesh
  • 68
  • 1
  • 1
  • 6