I had a problem with phpmailer, Its return true but the mail is not delivered..
Here's my code.
require_once('class.phpmailer.php');
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 2; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->Host = "smtp.postmarkapp.com";
$mail->Port = 25; // or 587
$mail->Username = "XXXXXXXXX";
$mail->Password = "XXXXXXXXXXXX";
$mail->SetFrom("sudeep777#hotmail.com");
$mail->Subject = "Test";
$body = "its a test message";
$mail->AddAddress("sudeep777#gmail.com");
$mail->MsgHTML($body);
if (!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
It simply returns:
SMTP -> FROM SERVER:220 smtp.postmarkapp.com ESMTP aws-dub-smtp1
SMTP -> FROM SERVER: 250-smtp.postmarkapp.com 250-PIPELINING 250-SIZE 20480000 250-VRFY 250-ETRN 250-STARTTLS 250-AUTH PLAIN LOGIN CRAM-MD5 DIGEST-MD5 250-AUTH=PLAIN LOGIN CRAM-MD5 DIGEST-MD5 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN
SMTP -> FROM SERVER:250 2.1.0 Ok
SMTP -> FROM SERVER:250 2.1.5 Ok
SMTP -> FROM SERVER:354 End data with .
SMTP -> FROM SERVER:250 2.0.0 Ok: queued as 0AE8D259B4
Message has been sent
Why is email not delivered?
Try out
$mailer->Port=465;
$mailer->SMTPSecure="ssl"; //If this doesn't work, try 'tls'
Related
Here is my code, The same code is working gmail and yahoo but outlook or hotmail getting this issue
include("phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = 'UTF-8';
$mail->Host = "smtp.live.com";//tried smtp-mail.outlook.com,smtp.office365.com
$mail->SMTPAuth= true;
$mail->Port = 587;
$mail->Username= $account;
$mail->Password= $password;
$mail->SMTPSecure = 'tls';
$mail->From = $from;
$mail->FromName= $from_name;
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $msg;
$mail->addAddress($to);
if(!$mail->send()){
echo "Mailer Error: " . $mail->ErrorInfo;
}else{
echo "E-Mail has been sent";
}
Getting below Error.
SMTP -> FROM SERVER:220 DM5PR0101CA0036.outlook.office365.com Microsoft ESMTP MAIL Service ready at Thu, 7 Mar 2019 07:59:09 +0000
SMTP -> FROM SERVER: 250-DM5PR0101CA0036.outlook.office365.com Hello [146.148.75.233] 250-SIZE 157286400 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-STARTTLS 250-8BITMIME 250-BINARYMIME 250-CHUNKING 250 SMTPUTF8
SMTP -> FROM SERVER:220 2.0.0 SMTP server ready
SMTP -> FROM SERVER: 250-DM5PR0101CA0036.outlook.office365.com Hello [146.148.75.233] 250-SIZE 157286400 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-AUTH LOGIN XOAUTH2 250-8BITMIME 250-BINARYMIME 250-CHUNKING 250 SMTPUTF8
SMTP -> ERROR: Password not accepted from server:
SMTP -> FROM SERVER:535 5.7.3 Authentication unsuccessful [DM5PR0101CA0036.prod.exchangelabs.com]
SMTP -> ERROR: RSET failed: 535 5.7.3 Authentication unsuccessful [DM5PR0101CA0036.prod.exchangelabs.com]
SMTP Error: Could not authenticate. Mailer Error: SMTP Error: Could not authenticate.
SMTP server error: 5.7.3 Authentication unsuccessful [DM5PR0101CA0036.prod.exchangelabs.com]
I'm trying to send email over Mandrill with PHPMailer but withouth sucess (testing on localhost).
Can someone tell me where is the problem?
This is the verbose information from PHPMailer:
2014-04-27 17:51:06 SERVER -> CLIENT: 220 smtp.mandrillapp.com ESMTP
2014-04-27 17:51:06 CLIENT -> SERVER: EHLO 127.0.0.1
2014-04-27 17:51:06 SERVER -> CLIENT: 250-ip-10-107-129-238
250-PIPELINING
250-SIZE 26214400
250-STARTTLS
250-AUTH PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250 8BITMIME
2014-04-27 17:51:06 CLIENT -> SERVER: STARTTLS
2014-04-27 17:51:06 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
2014-04-27 17:51:06 CLIENT -> SERVER: QUIT
2014-04-27 17:51:16 SERVER -> CLIENT:
2014-04-27 17:51:16 SMTP ERROR: QUIT command failed: SMTP connect() failed. Message could not be sent.
Mailer Error: SMTP connect() failed.
Here is my code:
$mail = new PHPMailer;
$mail->IsSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.mandrillapp.com'; // Specify main and backup server
$mail->Port = 587; // Set the SMTP port
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'example#mail.com'; // yes, I have entered my username mail
$mail->Password = 'xxxxxxxxxxxx-xxxxxxxxx'; // yes, API key is here
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mail->From = 'from#example.com';
$mail->FromName = 'Your From name';
if($test_mode) {
$mail->SMTPDebug = 2;
$mail->AddAddress('mymail#gmail.com');
} else {
$mail->AddAddress($email);
}
$mail->IsHTML(true); // Set email format to HTML
$mail->WordWrap = 70; // Set word wrap to 70 characters
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->Subject = 'Subject';
$mail->Body = 'This is the HTML message body <strong>in bold!</strong>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->Send()) {
//redirect to
echo 'Message could not be sent.<br>';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
EDIT:
I can delete this:
$mail->SMTPSecure = 'tls';
and it will work! But now the encryption is disabled. Why is this not working with encryption enabled?
Uncoment php_openssl.dll in php.ini
Is the timezone set correctly?
include timezone definitions before loading phpmailer
date_default_timezone_set('Etc/UTC');
require '../PHPMailerAutoload.php';
$mail = new PHPMailer();
Also, if you're trying it from a gmail domain, it ught have been blocked. check at: https://security.google.com/settings/security/activity?hl=pt_BR
I'm using php plugin for PHPMailer. Its version is PHPMailer_5.2.4. I have tested the sample code of PhpMailer site.
<?php
require_once('PHPMailer_5.2.4/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
//$body = file_get_contents('contents.html');
//$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.google.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server
$mail->Username = "myuser#gmail.com"; // GMAIL username
$mail->Password = "mypass"; // GMAIL password
$mail->SetFrom('myuser#gmail.com', 'First Last');
$mail->Subject = "FeedBack";
$mail->MsgHTML("helo hru ");
$address = "whomto#domainname.com";
$mail->AddAddress($address, "MYName");
$mail->Send();
//if(!$mail->Send()) {
////echo "Mailer Error: " . $mail->ErrorInfo;
//}
//else {
//echo "Message sent!";
//}
?>
After Executing this code, I'm getting the below output. But the mail has received successfully at my receiver mail Address. But I don't want the below output message. How can I rectify it ?
SMTP -> FROM SERVER:220 mx.google.com ESMTP b3sm40861402pbu.38 - gsmtp
SMTP -> FROM SERVER: 250-mx.google.com at your service, [ipAddress]
250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES
250 CHUNKING
SMTP -> FROM SERVER:220 2.0.0 Ready to start TLS
SMTP -> FROM SERVER: 250-mx.google.com at your service, [ipAddress]
250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2
PLAIN-CLIENTTOKEN 250-ENHANCEDSTATUSCODES 250 CHUNKING
SMTP -> FROM SERVER:250 2.1.0 OK b3sm40861402pbu.38 - gsmtp
SMTP -> FROM SERVER:250 2.1.5 OK b3sm40861402pbu.38 - gsmtp
SMTP -> FROM SERVER:354 Go ahead b3sm40861402pbu.38 - gsmtp
SMTP -> FROM SERVER:250 2.0.0 OK 1383737961 b3sm40861402pbu.38 - gsmtp
SMTP -> FROM SERVER:221 2.0.0 closing connection b3sm40861402pbu.38 -
gsmtp
Just remove this line of code:
$mail->SMTPDebug = 2;
It will disable debugging output.
This is just the debug output. Set $mail->SMTPDebug to 0
Your problem is the $mail->SMTPDebug line.
Setting that value tells PHPMailer to output debug data, which is what you're seeing.
Remove that line, and you won't get the output any more.
I would like to send an email using Gmail SMTP server through PHP Mailer.
I am running Zend Server Community Edition in my machine.
Following is my code (edited to hide certain confidential information).
require_once('phpmailer/class.phpmailer.php');
$mail = new PHPMailer();
$body = "test msg";
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host = "smtp.gmail.com";
$mail->Port = "587";
$mail->Username = "<valid-id>";
$mail->Password = "<valid-password>";
$mail->SetFrom('a#b.c', 'Name');
$mail->AddReplyTo("a#b.c","Name");
$mail->Subject = "subject";
$mail->MsgHTML($body);
$address = "d#e.f";
$mail->AddAddress($address, "halo:);
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message sent!";
}
Despite following thoroughly the example from PHP Mailer wiki page, I somehow couldn't manage to send the email accordingly.
This is the error message generated by the function:
SMTP -> ERROR: Failed to connect to server: A connection attempt
failed because the connected party did not properly respond after a
period of time, or established connection failed because connected
host has failed to respond. (10060) The following From address failed:
a#b.c Mailer Error: The following From address failed: a#b.c
Please advise me regarding this matter. Thank you.
have you tried:
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = "465";
I have changed in your code my emails, my smtp user, my settings ^^^, password and the line:
$mail->AddAddress($address, "Mihai"); // you forgot a quote
used PHPMailer5.2.1 and result:
SMTP -> FROM SERVER:220 mx.google.com ESMTP gq2sm2073759bkc.13
SMTP -> FROM SERVER: 250-mx.google.com at your service, [***.***.***.***] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH 250 ENHANCEDSTATUSCODES
SMTP -> FROM SERVER:250 2.1.0 OK gq2sm2073759bkc.13
SMTP -> FROM SERVER:250 2.1.5 OK gq2sm2073759bkc.13
SMTP -> FROM SERVER:354 Go ahead gq2sm2073759bkc.13
SMTP -> FROM SERVER:250 2.0.0 OK 1345113839 gq2sm2073759bkc.13
Message sent!
Mail received:
X-Mailer: PHPMailer 5.2.1 (http://code.google.com/a/apache-extras.org/p/phpmailer/)
Hello I finally got PHPMailer to work with Google but now I am finding out that I am getting this output to the screen after the message has been sent.
SMTP -> FROM SERVER:220 mx.google.com ESMTP f34sm21891943qco.35
SMTP -> FROM SERVER: 250-mx.google.com at your service, [76.28.109.170] 250-SIZE 35651584 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH 250 ENHANCEDSTATUSCODES
SMTP -> FROM SERVER:250 2.1.0 OK f34sm21891943qco.35
SMTP -> FROM SERVER:250 2.1.5 OK f34sm21891943qco.35
SMTP -> FROM SERVER:354 Go ahead f34sm21891943qco.35
SMTP -> FROM SERVER:250 2.0.0 OK 1276700936 f34sm21891943qco.35
I was wondering if there was any way to remove this output so the users don't see it?
Set the $phpmailer->SMTPDebug property to 0, you probably left it on debug (at least, I detect some work has been done from the 'finally'). http://phpmailer.worxware.com/index.php?pg=properties
<?php
require("PHPMailer/PHPMailerAutoload.php");
$mail = new PHPMailer;
//Enable SMTP debugging. 3 disable=0
$mail->SMTPDebug = 0;
//Set PHPMailer to use SMTP.
$mail->isSMTP();
//Set SMTP host name
$mail->Host = "smtp.gmail.com";//or your domain
//Set this to true if SMTP host requires authentication to send email
$mail->SMTPAuth = true;
//Provide username and password
$mail->Username = "your email";
$mail->Password = "your email password";
//If SMTP requires TLS encryption then set it
$mail->SMTPSecure = "tls";
//Set TCP port to connect to
$mail->Port = 587;
$mail->From = "your email";
$mail->FromName = "your name";
$mail->addAddress($userMail, $uname);
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $message;
//$mail->AltBody = "This is the plain text version of the email content";
// you can also comment the echos here out
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}
?>
enter code hereCheck this image at line 8.
You can also comment out the if(!$mail->send()){ } else{} block