简体   繁体   中英

Unable to send email to yahoo email using PHP

My script worked as it displayed 'Message sent!' but no email was received to the indicated email. Using XAMPP btw. Appreciate the help. Thank you.

<?php
$to = 'theaccount@yahoo.com';
$subject = 'Sample Subject';
$message = 'Hi. This is a sample message.';
$headers = 'From: webmaster@august.ai.com' . "\r\n" .
    'Reply-To: no-reply@august.ai.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

echo (mail($to, $subject, $message, $headers)) ? 'Message sent!' : 'Message not sent!';
?>

Here is the info from my php.ini and sendmail.ini :

php.ini :

[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
; SMTP = theaccount@yahoo.com
; smtp_port = 25

sendmail.ini :

smtp_server=smtp.mail.yahoo.com

; smtp port (normally 25)

smtp_port=25

auth_username=theaccount+yahoo.com      
auth_password=passwordhere

You haven't "commented out" the php.ini 's SMTP configuration lines:

[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
; SMTP = theaccount@yahoo.com
; smtp_port = 25

For php.ini file, semicolons ; are used for comments. So you need to remove it from those lines:

[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
SMTP = theaccount@yahoo.com
smtp_port = 25

Try that out :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM