Using this:
require("lib/class.phpmailer.php");
$mail = new PHPMailer();
$mail->Username = "XXX#validGoDaddyAccount.com";
$mail->Password = "xxx";
$mail->Subject = $subject;
$mail->Body= $message;
$mail->AddAddress($toAddr);
$mail->FromName = "XXXXXXXXXXXX";
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->Host = "smtpout.secureserver.net";
$mail->Port = 465;
$mail->SMTPSecure = "ssl";
$mail->SMTPAuth = true;
$mail->From = $mail->Username;
$mail->IsHTML(true);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
return true;
}
I get this response:
SMTP -> FROM SERVER:220 p3plsmtpa07-05.prod.phx3.secureserver.net ESMTP
SMTP -> FROM SERVER: 250-p3plsmtpa07-05.prod.phx3.secureserver.net hello [00.00.0.0], secureserver.net 250-HELP 250-AUTH LOGIN PLAIN 250-SIZE 31457280 250-PIPELINING 250-8BITMIME 250 OK
SMTP -> FROM SERVER:550 User XXX has exceeded their send quota
SMTP -> ERROR: MAIL not accepted from server: 550 User XXX has exceeded their send quota
The following From address failed: XXX : MAIL not accepted from server,550,User XXXm has exceeded their send quota
SMTP server error: User XXX has exceeded their send quota
Mailer Error: The following From address failed: XXX : MAIL not accepted from server,550,User XXX has exceeded their send quota
SMTP server error: User XXX has exceeded their send quota
I know about setting the SMTP Relays for GoDaddy accounts and they are set right. I can send email from this account all day long as long as I don't use PHPmailer.
see the following line
SMTP -> FROM SERVER:550 User XXX has exceeded their send quota
That's why it is rejecting.
The solution is that I needed to pre-authorize with POP prior to starting the SMTP operation:
require("lib/class.phpmailer.php");
require_once('lib/class.pop3.php');
$pop = new POP3();
$pop->Authorise('pop.server.net', 110, 30, 'username', 'password', 1);
$mail = new PHPMailer();
...
Related
I am using the below lines of code to send an email but I get the error as 'smtplib.SMTPAuthenticationError: (535, b'5.7.3 Authentication unsuccessful' . This must be due to MFA. what can I do to authenticate?
import smtplib, ssl
port = 587 # For starttls
smtp_server = "smtp.office365.com"
sender_email = "myemail#companycom"
receiver_email = "myemail#companycom"
password = input("Type your password and press enter:")
message = """\
Subject: Hi there
This message is sent from Python."""
context = ssl.create_default_context()
with smtplib.SMTP(smtp_server, port) as server:
server.ehlo() # Can be omitted
server.starttls(context=context)
server.ehlo() # Can be omitted
server.login(sender_email, password)
server.sendmail(sender_email, receiver_email, message)
The solution to this issue is to manage the app password in your account or request for service accounts to your admin which doesn't have MFA.
I am trying to send a mail via phpMailer but I got below error
2019-03-28 10:54:00 SMTP ERROR: Failed to connect to server: (0)
2019-03-28 10:54:00 SMTP connect() failed. Mailer Error: SMTP
connect() failed.
I referred below links
https://stackoverflow.com/questions/43815571/mailer-error-smtp-connect-failed
https://stackoverflow.com/questions/21088062/phpmailer-smtp-connection-error
https://stackoverflow.com/questions/43999573/phpmailer-smtp-connect-error
https://stackoverflow.com/questions/36735979/mailer-error-smtp-connect-failed
https://stackoverflow.com/questions/30476024/smtp-connect-failed-phpmailer
but after implementing the solution as mention in the above links, getting the same error.
I tried with PHP mail() function for the same credential, it's working but I wanted to send a mail via SMTP.
here is my code
require('mail/class.phpmailer.php');
require('mail/PHPMailerAutoload.php');
$mail = new PHPMailer;
$mail->SMTPDebug = 2;
$mail->isSMTP();
$mail->Mailer = "smtp";
$mail->Host = 'mail.example.com';
$mail->SMTPAuth = true;
$mail->Username = 'From#example.com';
$mail->Password = 'password';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->setFrom('From#example.com', 'from');
$mail->addAddress('To#example.com', 'To');
$mail->isHTML(true);
$mail->Subject = 'subject';
$mail->Body = 'This is message';
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
I'm trying to send mail with PHPMailer plugin via smtp.gmail.com. The sending works fine on my local computer but when I use my remote server with following code it delays the sending, normally around 30 seconds.
function sendAuthEmail($subject, $mail_body, $mailTo, $mailToTitle, $mailFrom, $fromTitle)
{
require 'PhpMailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->Username = 'no-reply#domail.com';
$mail->Password = 'password';
$mail->AddReplyTo($mailFrom, $fromTitle);
$mail->SetFrom($mail->Username, 'Domain.com');
$mail->AddAddress($mailTo, $mailToTitle);
$mail->CharSet = 'UTF-8';
$mail->Subject = $subject;
$mail->MsgHTML($mail_body);
if($mail->Send()) {
return;
} else {
die('There was an error: '.$mail->ErrorInfo.'</i>');
}
}
But when I try to use gethostbyname('smtp.gmail.com') it fails with following debug information:
2016-11-23 12:36:11 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP a47sm16079918qtc.17 - gsmtp
2016-11-23 12:36:11 CLIENT -> SERVER: EHLO www.sellercloud.com
2016-11-23 12:36:11 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [199.189.62.92] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8
2016-11-23 12:36:11 CLIENT -> SERVER: STARTTLS
2016-11-23 12:36:11 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
2016-11-23 12:36:11 SMTP Error: Could not connect to SMTP host.
2016-11-23 12:36:11 CLIENT -> SERVER: QUIT
2016-11-23 12:36:11 SERVER -> CLIENT:
2016-11-23 12:36:11 SMTP ERROR: QUIT command failed:
2016-11-23 12:36:11 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
The problem with the server turned out to be a DNS resolving issue. PHP mailer couldn't resolve smtp.gmail.com correctly, and this was the main reason why none of the known fixes worked.
If you're having similar issue, check your DNS servers.
I use phpmailer for sending emails and while it worked flawlesly until now, I noticed that sending emails got very very slow, around 2-3 minutes. The mails are sent, but the waiting time is killing me.
My code is:
protected function SendPHPMailerMail($from = null, $name = null, $subject = null, $message = null)
{
require_once ('phpmailer/PHPMailerAutoload.php');
if($from && $name && $subject && $message)
{
$mail = new PHPMailer;
//$mail->SMTPDebug = 3;
$mail->Debugoutput = 'html';
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com'; // sets GMAIL as the SMTP server
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = 'tls'; // sets the prefix to the servier
$mail->Port = 587; // set the SMTP port for the GMAIL server
$mail->Username = 'x#gmail.com'; // GMAIL username
$mail->Password = 'pass'; // GMAIL password
$mail->AddReplyTo($from, $name);
$mail->AddAddress('x#gmail.com', 'Me');
$mail->SetFrom('x#gmail.com', 'Me');
$mail->Subject = $subject;
$mail->Body = $message;
$mail->Send();
}
}
I tried debugging, there are no errors. I read in a different question thread that using gethostbyname('smtp.gmail.com'); worked for some, but not for me. I haven't changed anything on the server and this popped out of nowhere. Not sure what to do.
Thanks!
edit: used SMTPdebug=2 and this is what I get
SERVER -> CLIENT: 220 smtp.gmail.com ESMTP 90sm16517084otw.3 - gsmtp
CLIENT -> SERVER: EHLO www.host.com
SERVER -> CLIENT: 250-smtp.gmail.com at your service, [107.182.234.254]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
CLIENT -> SERVER: STARTTLS
SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
CLIENT -> SERVER: EHLO www.host.com
SERVER -> CLIENT: 250-smtp.gmail.com at your service, [107.182.234.254]250- SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
CLIENT -> SERVER: AUTH LOGIN
SERVER -> CLIENT: 334 VXNlcm5hbWU6
CLIENT -> SERVER: Y29udGFjdEBmaWxlY2x1c3Rlci5jb20=
SERVER -> CLIENT: 334 UGFzc3dvcmQ6
CLIENT -> SERVER: Z2l6bW8uMTIzcXdl
SERVER -> CLIENT: 235 2.7.0 Accepted
CLIENT -> SERVER: MAIL FROM:<x#gmail.com>
SERVER -> CLIENT: 250 2.1.0 OK 90sm16517084otw.3 - gsmtp
CLIENT -> SERVER: RCPT TO:<x#gmail.com>
SERVER -> CLIENT: 250 2.1.5 OK 90sm16517084otw.3 - gsmtp
CLIENT -> SERVER: DATA
SERVER -> CLIENT: 354 Go ahead 90sm16517084otw.3 - gsmtp
CLIENT -> SERVER: Date: Thu, 20 Oct 2016 20:44:01 +0000
CLIENT -> SERVER: To: Me <x#gmail.com>
CLIENT -> SERVER: From: Me <x#gmail.com>
CLIENT -> SERVER: Reply-To: X <sender#gmail.com>
CLIENT -> SERVER: Subject: Partnership and business development
CLIENT -> SERVER: Message-ID: <6dae364927ad751cc524f07a77f5eea1#www.host.com>
CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.16 (https://github.com/PHPMailer/PHPMailer)
CLIENT -> SERVER: MIME-Version: 1.0
CLIENT -> SERVER: Content-Type: text/plain; charset=iso-8859-1
CLIENT -> SERVER:
CLIENT -> SERVER: message
CLIENT -> SERVER:
CLIENT -> SERVER: .
SERVER -> CLIENT: 250 2.0.0 OK 1476996370 90sm16517084otw.3 - gsmtp
CLIENT -> SERVER: QUIT
SERVER -> CLIENT: 221 2.0.0 closing connection 90sm16517084otw.3 - gsmtp
I replaced the actual values of the site and emails.
I am using phpmailer class to send email from my server. Below is my code, i am able to send email with this code to valid email address. I want to receive bounce back emails on my email address farazaleem#gmail.com but i am not receiving any email when i send email to invalid email account like dsfsdfdsfsfsfsfs#rtretreert.com
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPKeepAlive = true;
$mail->Host = "smtpout.secureserver.net";
$mail->Port = 25;
$mail->Username = "xxxxxx#mydomain.com";
$mail->Password = "xxxxxxx";
$mail->SetFrom('farazaleem#gmail.com');
$mail->Subject = "Email body";
$mail->Sender = 'farazaleem#gmail.com';
$mail->MsgHTML($email_details);
$mail->AddAddress($entered_person_email, $full_name);
$mail->Send();