PHPmailer DATA not accepted from server: 421 - phpmailer

if i send single line message using PHPmailer it goes with out any error.
but if I send big message (10 lines) i got following error ::.
SMTP -> FROM SERVER:250 2.5.0 Address Ok.
SMTP -> FROM SERVER:250 2.1.5 <toaddress>#gmail.com OK.
SMTP -> FROM SERVER:354 Enter mail, end with a single ".".
SMTP -> FROM SERVER:421 4.4.2 Timeout while waiting for command.
SMTP -> ERROR: DATA not accepted from server: 421 4.4.2 Timeout while waiting for command.
SMTP Error: Data not accepted.

That's about your timeout value. Find the following code in your class.phpmailer.php
var $Timeout = 10;
Then change the value to higher value.

Related

error Server terminates connection response=421 4.7.0 Try again later

response=421 4.7.0 Try again later, closing connection. (EHLO) vj23-20020a170907131700b0078db51bb303sm9553ejb.86 - gsmtp: 421 4.7.0 Try again later, closing connection. (EHLO) vj23-20020a170907131700b0078db51bb303sm9553ejb.86 - gsmtp Error: Server terminates connection. response=421 4.7.0 Try again later, closing connection. (EHLO) vj23-20020a170907131700b0078db51bb303sm9553ejb.86 - gsmtp: 421 4.7.0 Try again later, closing connection. (EHLO) vj23-20020a170907131700b0078db51bb303sm9553ejb.86 - gsmtp
I found a solution I hope it will help you I replaced nodemailer Smtp by emailjs and this will solve the problem.
https://www.npmjs.com/package/emailjs
I believe Nodemailer uses the computer's hostname in place of the name property when creating a transport. This can cause issues with some email relays such as Gmail. To fix this you can explicitly set the name property in the SMTP transport options to an arbitrary string.

Connection Refused Error When Trying to Connect to Outlook Using Python's poplib

I am trying to connect to Outlook using POP3 in python.
mailbox = poplib.POP3_SSL('outlook.office365.com', 995)
And I am getting the following error:
[WinError 10061] No connection could be made because the target machine actively refused it
I am using a VPN, and can ping 'outlook.office365.com' without issue. I also tried 'pop-mail.outlook.com' and 'pop3.live.com' as I saw them mentioned as hostnames online, and received the same error. Please let me know if there is any more useful information I can provide.
for the office 365 email settings it seems that the port for POP is 903. You can try using the settings in the web under Microsoft365 to also try fetching your email with IMAP.
Just to save you same time I wrote down some working lines using imap for fetching your emails and a simple code for sending using smtp
import smtplib
import imaplib
import ssl
def send_email():
send_port = 587
with smtplib.SMTP('smtp.office365.com', send_port) as smtp:
#Need a ehlo message before starttls
smtp.ehlo()
smtp.starttls()
# Server login
smtp.login(<user-email>, <password>)
# Email data
sender_email = <user-email>
receiver_email = <destination-email>
email_subject = <some-subjetct>
email_body = <some-body>
message = 'Subject: {}\n\n{}'.format(email_subject, email_body)
smtp.sendmail(sender_email, receiver_email, message)
smtp.quit()
def receive_email():
receive_port = 993
with imaplib.IMAP4_SSL('outlook.office365.com', receive_port) as imap:
# Server login
imap.login(<youremail>, <password>)
# Get the list of folders in you email account and some extra info.
retcode, folders = imap.list()
# status of the fetch
print ('Response code:', retcode)
# folders and info of hierarchies
print ('Response code:', folders)
imap.close()
#Test
send_email()
receive_email()
Be aware that this code needs the imap and smtp port open on your firewall.
Also use same user-email and password as you were using https://www.office.com/

Python send a mail to the user using local smtp server

I want to send a simple text message to the user from local smtp server. When i am using the following code i am getting the following error
#!/usr/bin/python
import smtplib
receivers = ['to#todomain.com']
message = "hello"
Subject: "SMTP e-mail test
This is a test e-mail message."
try:
smtpObj = smtplib.SMTP('localhost')
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent email"
except SMTPException:
print "Error: unable to send email"
i am getting the following error:
[WinError 10061] No connection could be made because the target machine actively refused it
How to resolve this error.
If this happens always, it literally means that the port is blocked by your firewall.
(What port are you listening on?)
you have to open port 25 if you want send mails from your machine.
Of course also a mail server/service should be running.

Connect to SMTP relay in Azure VM with O365 Account fails

How can I use from a VM (linux) where a Java application is running a SMTP Server/relay?
For connecting to SMTP I want to use an O365 account, so configuration looks like:
host: smtp.office365.com
port: 587
TLS: true
uid: UID-O365
pwd: PWD-O365
As response I get:
An error has occurred with sending the test email:
MailException: com.sun.mail.smtp.SMTPSendFailedException:
501 5.1.7 Invalid address [AM4P190MB0211.EURP190.PROD.OUTLOOK.COM]
;
nested exception is:
com.sun.mail.smtp.SMTPSenderFailedException: 501 5.1.7 Invalid address
[AM4P190MB0211.EURP190.PROD.OUTLOOK.COM]
remark: The application that wants to connect runs on java, what is probably unimportant
The server is telling you that the address "AM4P190MB0211.EURP190.PROD.OUTLOOK.COM" that you're using in your message as a sender or recipient address is not a valid email address. It at least needs a "#" in there somewhere. You can get more detail in the JavaMail debug output.
The solution is simple: sender email address (what was not listed above) and UID must be the same

web2py: sending email: lost connection after EHLO from localhost

I'm trying to send email in web2py using the postfix server on Centos. I can send it successfully using the gmail SMTP server, but when I change the settings to:
mail.settings.server='127.0.0.1:25'
mail.settings.login = 'user:pass'
no email gets delivered. I checked the logs and I see this:
postfix/smtpd[31521]: connect from localhost[127.0.0.1]
postfix/smtpd[31521]: lost connection after EHLO from localhost[127.0.0.1]
postfix/smtpd[31521]: disconnect from localhost[127.0.0.1]
I am able to send email successfully using the local mail command. I am new to linux, so please bear with me.
depending on your version of web2py try setting
mail.settings.tls = False

Resources