PHP can not send mail to webmail

advertisements

I have a contact form in website that if you submit it will send to webmail. example :

    $isi_pesan = $message;
    $additional_headers = "From: ".$email."" . "\r\n" . "Reply-To: $email";
    $subject = 'Pesan untuk engineering.co.id';

    $to = '[email protected]';
 // $to = '[email protected]'; //this works

    if(mail($to, $subject, $isi_pesan, $additional_headers))
        echo '<div class="success-msg">Success !</div>';
    else
        echo '<div class="error-msg">Failed !</div>';

the message i got is "success !" but i got nothing in inbox webmail. PHP mail works if $to is not a webmail. so what setting i have to change to get the mail works in webmail? thanks in advance.


Have you looked in the SPAM folder? Take a look to this PHP class

https://github.com/Synchro/PHPMailer

$mail = new PHPMailer;

$mail->From = '[email protected]';
$mail->FromName = 'Mailer';
$mail->AddAddress('[email protected]');               // Name is optional
$mail->IsHTML(true);                                  // Set email format to HTML

$mail->Subject = 'Here is the subject';
$mail->Body    = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->Send()) {
   echo 'Message could not be sent.';
   echo 'Mailer Error: ' . $mail->ErrorInfo;
   exit;
}

echo 'Message has been sent';