PHP Mail Function Doesn't Complete Sending of E-Mail

PHP Mail Not Sending But No Errors

Try this to find out where is the problem

$success = mail('example@example.com','New Enquiry',$msg);
if (!$success) {
print_r(error_get_last()['message']);
}

with a glance at Php Mail Documentation

Note:
When sending mail, the mail must contain a From header. This can be set with the additional_headers parameter, or a default can be set in php.ini.
Failing to do this will result in an error message similar to Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing. The From header sets also Return-Path under Windows.

Return Values


Returns TRUE if the mail was successfully accepted for delivery, FALSE
otherwise.

It is important to note that just because the mail was accepted for
delivery, it does NOT mean the mail will actually reach the intended
destination.

update
After comments just for test, remove every code in your php file an just try the simplest way to debug

<?php
// the message
$msg = "First line of text\nSecond line of text";

// use wordwrap() if lines are longer than 70 characters
$msg = wordwrap($msg,70);

// send email
if(!mail("someone@example.com","My subject",$msg)){
var_dump(error_get_last()['message']);
}
?>

PHP 'mail()' Function Not Sending Email

There may be many reasons, for example you should study what SPF is.

The $sender_email can't be any address, for example you can't put a gmail address and send emails claiming to be that sender, without any authentication, you aren't allowed to send email on behalf on that address, because I could for example send emails putting your address in the from, pretenting to be you when I'm not (I tried to use simple words)

You should use in the From something ending in @yourdomain.com, and set up SPF to allow your server's IP to send emails for that domain. OR otherwise send emails through SMTP (with PHPmailer, for example, it's very easy)

Mail function is not working in PHP

mail($to, "Subject: $subject",$message );
echo "Thank you for using our mail form";

instead of this ,first check if the mail is sent

$mail=mail($to, "Subject: $subject",$message );
if($mail){
echo "Thank you for using our mail form";
}else{
echo "Mail sending failed.";
}

By this actually u can know whether your mail function in working or not

if it is not working.the problem can be with SMTP settings in your localhost

enable errors in php if not enabled using

ini_set('display_errors',1);

PHP mail function sends to Gmail and Live but doesn't send to my own email

Do move to PHPMailer. Default php mail functions do not support modern security features. You can see that emails you received in gmail have a red padlock icon. Some of the mailboxes will never receive an unsecure email.



Related Topics



Leave a reply



Submit