简体   繁体   中英

Message sent but doesnt receive by email address in PHPMailer?

Im using PHPmailer 5.4.2 and try one of its given example. It gives me true result which is "Message Sent" but the email address I have states in the code doesnt receive anything. Here is the code.

<html>
<head>
<title>PHPMailer - Mail() basic test</title>
</head>
<body>

<?php

require_once('../class.phpmailer.php');

$mail             = new PHPMailer(); // defaults to using php "mail()"

$body             = "fhgdshfgjsd";

$mail->SetFrom('verbz95@gmail.com', 'Verbo Angelo Ludovice');

$mail->AddReplyTo("verbz95@gmail.com","Verbo Angelo Ludovice");

$address = "espadadave@yahoo.com";
$mail->AddAddress($address, "John Doe");

$mail->Subject    = "PHPMailer Test Subject via mail(), basic";

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$mail->AddAttachment("images/phpmailer.gif");      // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}

?>

</body>
</html>

That's because you are trying to send email from your server via gmail without any authentification, therefore yahoo treats it as a forged/spam email. You will need to either:
- don't use **@gmail.com as a from address
- or forward your mail thru gmail smtp server (you will need to provide credentials), you can find all settings in your gmail\\settings\\pop3, imap tab

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