web2py: sending email: lost connection after EHLO from localhost - linux

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

Related

Gramex SMTP Email Issue

I have to send an email from python function to multiple users with dynamic content.
I have given email details in gramex.yaml as below
email:
barcode-mail-service:
type: gmail
email: gramex.guide#gmail.com
password: alphaBetaGamma
In my python function I have implemented mail functionality as below:
def email_users(_pending_users, approval):
mailer = service.email['barcode-mail-service']
content = []
if approval == 'Approved':
content = [f"Hi {obj['user']},\n\n \
Welcome to the Service online portal!"
for obj in
_pending_users.to_dict('r')
]
else:
content = [f"Hi {obj['user']},\n\n \
Your request has been rejected by the approver!"
for obj in _pending_users.to_dict('r')
]
to_list = _pending_users['email'].tolist() #gets list of all email ids
for index in range(len(to_list)): #loops over each mail id and sends the email
mailer.mail(
to=to_list[index],
subject=f'Barcode User Access {approval}',
html=content[index]
)
When I execute the above function I get the following error:
TimeoutError: [WinError 10060] 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
How can I fix this?
This seems to be a Firewall issue. SMTP internally uses port 25 for sending email. Enable (Allow) port 25 on your system and try if that works. You would need to enable this port on the server as well during deployment.
Note: Check which port is being used for sending the email by your Email Exchange
You can check this link to enable on Windows OS

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

How is another IP sending email through my qMail?

My first question on here...
I have a VPS which I have a few small websites on and also run my email services, every now and then I see messages in my mail queue that I did not send.
Firstly my setup:
Ubuntu 12.04
Latest Plesk Panel
qMail SMTP Server
Courier-imap
Using the Plesk panel I have set up qmail to not act as an open relay, and must use SMTP authentication to send to remote accounts, also short mailbox names are not allowed only the full account names.
Today I received bounced messages, upon checking my mail queue I have found again emails in there with multiple recipients that I have not sent.
These are not being sent by a script on my server as I would see different header information with uid 33 being specified, instead I see invoked from network in the mail header, an example below...
Received: (qmail 17710 invoked from network); 2 Feb 2016 11:34:10 +0000
Received: from unknown (HELO mx1.variationdesign.co.uk) (182.190.250.238)
by lvps212-67-205-193.vps.webfusion.co.uk with ESMTPA;
2 Feb 2016 11:34:09 +0000
From: Merel de Bruin - Van de Beek <seth#variationdesign.co.uk>
Content-Type: multipart/alternative;
boundary=Apple-Mail-29D34A60-FB4E-38B5-1BBF-7DDE23285FD2
Content-Transfer-Encoding: 7bit
Mime-Version: 1.0 (1.0)
Subject: Re(4): Surprise
Message-Id: <91925fdeae7d$78ac5f73$dfad0a17$#variationdesign.co.uk>
Date: Mon, 2 Feb 2016 12:33:59 +0000
To: "sanderdejong" <sanderdejong#hotmail.com>,
"Sanne van Roon" <sannevanroon#hotmail.com>,
"Sarah Dormaar" <sarahdormaar#hotmail.com>,
"Sarah Tempelaar" <bordeaux84#hotmail.com>, "saskia middel" <s.middel#jvo.nl>,
"Saskia Roovers" <matrixspijkertje#hotmail.com>,
"sinta sinta ss" <sinta_sinta_ss#hotmail.com>,
"Sinta de Wildt" <sinta_de_wildt#hotmail.com>,
"skizonespijkertje" <skizonespijkertje#hotmail.com>,
"spijkertje matrix" <spijkertje_matrix#hotmail.com>,
"sroovers007" <sroovers007#hotmail.com>, "sroovers75" <sroovers75#hotmail.com>,
"stali n" <stali_n#hotmail.com>, "stingarts" <stingarts#hotmail.com>,
"suus rem" <suus_rem#post.com>, "svdbersselaar" <svdbersselaar#hotmail.com>,
"teresa villalobos" <teresavs#hotmail.com>, "teresavs" <teresavs#home.nl>,
"Thomas Bollen" <T.P.F.Bollen#students.uu.nl>
X-Mailer: iPad Mail (13A452)
X-PPP-Message-ID: <20160202113410.17689.25881#lvps212-67-205-193.vps.webfusion.co.uk>
X-PPP-Vhost: variationdesign.co.uk
The IP: 182.190.250.238 is nothing to do with me, I also never use mx1.variationdesign.co.uk.
Every time I want to send an email, I have to send my username and password to be able to send through this server.
My question is, how on earth is this person/people able to physically send emails through my VPS without authenticating?
I see in the logs around the same time "smtp_auth' for username seth#variationdesign.co.uk, which is odd because that is actually just an alias and not an email account, the account itself uses my full name and a couple of numbers at the end, I did this to try and stop spammers from guessing the correct username.
My server is definitely sending these emails out and I can't figure out how they are doing it, what ma I missing here?
I appreciate any help you can give me on this matter.
Kind regards
Seth
qMail SMTP Server comes with a default configuration to be a open relay, make sure you disable that and only authenticaed users can send emails. And stop your server before you get into a blacklist for spam.
https://qmail.jms1.net/relay.shtml

Griffon 1.2 - mail plugin does not look at mailhost param

I installed Griffon 1.2 and the mail plugin.
griffon install-plugin mail
I created a test:
sendMail(mailhost: '192.168.0.19',
to: 'me#home.com',
from: 'me#home.com',
subject: 'Test Mail',
text:'''
Hello
World''')
But it does not use the mailhost param. It tries to use localhost:
javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25
I verified the SMTP server via telnet commands and that works.
Line 70 from https://github.com/griffon/griffon-mail-plugin/blob/master/src/main/griffon/plugins/mail/MailSender.groovy shows that mailhost is taken into account, at least when it comes to setting properties.
However this sounds more of a bug report than an actual question. If so I'd recommend you to post the issue to the Griffon user list. If it's found to be a bug then a report should be made to http://jira.codehaus.org/browse/griffon

Resources