1

I was trying to send an email using PHPmailer. My username and password are correct and there are no errors, But my email is not deliverd. Is there anyone that can help me out?

here's my code:

$mail = new PHPMailer();

$mail->SMTPDebug = 2;

$mail->IsSMTP();
$mail->Mailer = "smtp";
$mail->Host = "myhost";
$mail->Port = "25"; // 8025, 587 and 25 can also be used. Use Port 465 for SSL.
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Username = "myuser";
$mail->Password = "**********";

$mail->From = "from.example.com";
$mail->FromName = "fromname";
$mail->AddAddress($email, "Jordy OL");

$mail->Subject = $subject;
$mail->IsHTML(true);
$mail->msgHTML($message);
$mail->WordWrap = 50;

if(!$mail->Send()) {
    echo 'Message was not sent.';
    echo 'Mailer error: ' . $mail->ErrorInfo;
    exit;
} else {
    $mail->ErrorInfo;
    echo 'Message has been sent.';
}
aynber
  • 22,380
  • 8
  • 50
  • 63
jol123
  • 97
  • 2
  • 12
  • Possible duplicate of [PHP mail function doesn't complete sending of e-mail](https://stackoverflow.com/questions/24644436/php-mail-function-doesnt-complete-sending-of-e-mail) – aynber Aug 15 '17 at 13:19
  • 2
    Connecting to port 25, but using TLS? I suspect your configuration is incorrect. – Phylogenesis Aug 15 '17 at 13:20
  • 1
    Was the mail successfully delivered to the smtp server, or did that already fail? IS the mail not in a spam filter? Is the smpt server allowed to send mail for the given sender address? – Ivo P Aug 15 '17 at 13:20
  • the mail was succesfully deliverd to the smtp server, I have checked this in SMTPDebug – jol123 Aug 15 '17 at 13:22
  • 3
    One thing to note, `$mail->From` is supposed to hold a full email address, not just a domain name. – Phylogenesis Aug 15 '17 at 13:27
  • If the message was successfully delivered to the mail server then your code isn't the problem (though the above comment about the From address is correct - if it's invalid, PHPMailer will derive a From address automatically for your host name). You need to look in your mail server's logs to find out what happened to your messages after submission. – Synchro Aug 15 '17 at 13:31

0 Answers0