PHP mail has stopped working

A few days ago, when I used mail(), I worked.

But now it will not work. And I don’t know what the problem is.

$to      = 'testmail@gmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: sender@gmail.com' . "\r\n" .
    'Reply-To: sender@gmail.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

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

$mail_sent = @mail( $to, $subject, $message, $headers ); 
echo $mail_sent ? "Mail sent" : "Mail failed";

The message "Sent by mail" is displayed.

I did not touch anything in Apache or this code. I checked the code in an empty PHP file with the same result. How can I debug this problem?

+5
source share
6 answers

Could it be that E-Mail is sent perfectly, but gets into the spam filter? If possible, let me cross-configure :


A few marker points (Assuming mail () returns true and there are no errors in the error log):

  • ( "" ) ? , .
  • (, IP- spamhaus.org)? .
  • ? freemailer . , -.
  • , "-f" (), ? (. mail() PHP)
  • , , .
  • "from:" ( " " )? "error-to".

" " . . .

+11

mail(), php , sendmail_path, <sendmail_path > . (MTA).
"" php mail() , php , , . mail() == true , () MTA .

MTA , . , Google, MTA "gmail.com". MTA MTA gmail.com(forward-path). , mail() === true .
MTA MTA . , , "" gmail.com, MTA (MDA) .

, "" MTA ( , , ;-)) . , ( ) , , ( "" ), .

( . , , , /smtp; -))

... ?

  • . (/) ? . , " " ​​(sendmail, qmail,...)? ?

  • , , , - , Google .

  • MTA , php script MTA. , , , Swiftmailer ( smtp) mail(). , . script "" SMTP Google, "" Google. - , , , , script, swiftmailer "Ok", , , mail(), "true",.

+11

, , / , . , , , php. .

(justhost !), .

phpinfo(); ( )

sendmail_from   no value    no value
sendmail_path   /usr/sbin/sendmail -t -i    /usr/sbin/sendmail -t -i

, .

php:)

: script, (Perl , Linux ). , . , , ( php.ini?), . Perl script , ... , :)

+1

SMTP, , , , gmail.com.

"" $headers .

+1

, , , , - . 2 MTA ( ), . , , , .

, - - RBL, RMX, , , ... , , . , . gmail, , , , - ?

, , - , , .

.

+1
source

Try adding the -f option to the call mail()

Is email authentication only 30% activated?

0
source

All Articles