I have a webapp that logs fatal errors (due to bugs in the code, basically) and also reports them via email to a gmail account using smtp.gmail.com:465. This has worked fine for years, and the system is stable so it's a while since I last had a fatal error (Oct 2017). However, the other day I did something stupid while testing a bugfix and it caused a fatal error report. The email wasn't sent and I got this:
javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465;
nested exception is:
java.net.ConnectException: Connection refused: connect
I can connect via telnet:
$ telnet smtp.gmail.com 465
Trying 74.125.133.109...
Connected to gmail-smtp-msa.l.google.com.
Escape character is '^]'.
I'm assuming it's something to do with Gmail's security which means that you have to do some sort of special configuration if you want to use Thunderbird or something instead of Gmail's dreadful web interface. Can anyone tell me what I should do to get this working?
It turns out it was Gmail being cute. The underlying error was an "authentication refused", but it was being wrapped in a "connection refused" exception elsewhere. I finally figured out how to tell Gmail to allow access from an insecure app, and that solved it.
Related
I am building a Jenkins server on my AWS EC2 instance. After building finish, I want to send email to stakeholder.
I am using STMP with smtp.sendgrid.net in port 587.
But I sometime can not send email. The log from jenkins says
MessagingException message: Could not connect to SMTP host:
smtp.sendgrid.net, port: 587
I access to EC2 instance and telnet to sendgrid. It says:
[hostname#domain ~]$ telnet smtp.sendgrid.net 587
Trying 161.202.148.179...
telnet: connect to address 161.202.148.179: Connection timed out
Trying 161.202.148.182...
telnet: connect to address 161.202.148.182: Connection timed out
Trying 169.38.103.39...
Connected to smtp.sendgrid.net.
Escape character is '^]'.
220 SG ESMTP service ready at ismtpd0004p1maa1.sendgrid.net
I understand that mean I can only access to some ip coming from smtp.sendgrid domain. I am sure to open all outbound rules for EC2. Because the problem happens sometimes, so anyone could give me any suggestion for this situaions.I intend to use IP instead of domain, but it just a workaround, IP can change anytime.
Please help me.
I had a similar issue, if your EC2 outbound rules are opened then you should ensure that you provide SMTP authentication along with your SMTP server and SMTP port and your DNS resolvers are good enough.
Sendgrid expects username and password.
username: it's "apikey", It might have to be encoded in base64 "YXBpa2V5".
password: it's your API Key, get it from Sendgrid and save it here. It might have to be encoded in base64.
I tried base64 encoded and it didn't work, so I tried without the encoding and it worked.
If your problem is not related to the authentication, you could review your DNS resolver, probably the problem would be there.
I am trying to send emails from my Odoo 10 installation. For this I have configured the outgoing mail server with Gmail SMTP as follows:
SMTP Server: smtp.gmail.com
SMTP Port: 465
Priority: 10
Connection Security: SSL/TLS
I have also configured my Gmail account to accept less secure connections from outside and when I run the test from Odoo's email configuration menu I get the following message:
Connection Test Succeeded! Everything seems properly set up!
BUT: If I try to send a real mail with Odoo I get the following error reason:
Mail Delivery Failed
Mail delivery failed via SMTP server 'localhost'.
error: 111
Connection refused
I don't know what to do, I searched for it on the internet but found nothing. Hope somebody can help me. Many thanks in advance.
From the error its clear that Odoo is trying to send emails using "SMTP server 'localhost'".
By default Odoo will create a localhost server in outgoing mail configuration menu. So you must set the "Priority" field in the form. Set the GMail server priority as "1"and localhost as "2" or any other value.
Priority: The priority of your mail server. The lower the number the
higher the priority. This will mean that the e-mail server with the
lowest number will be used the most.
I need to send an email with a software called ScadaBR (which is for industrial supervision). As my "SMTP host" I use the name of the company server that we use to send emails with port 25 because we don't use any authentication. However I can't connect to the server from the software, it gives me the error "connection failed with the server".
The full error is:
Failed to send email titled "ScadaBR test email" to "FRWLT#bost.com".
Message: "Mail server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP host: smtp-eu.app.corp, port: 25; nested exception is: java.net.SocketException: Unrecognized Windows Sockets error: 10107: connect"
The email destination is FRWLT#bost.com and the server name is smtp-eu.app.corp.
I tried to use the gmail server but in the company where I work use some firewal seems to stop any kind of connection with the port 587 (the port that connects with the gmail server).
I have an positive answer when I try to ping the server and also I have a positive answer when I try the connection via "putty" with telnet.
Can anyone help me connecting to the SMTP server?
I want to send an email with a software that I use called ("ScadaBR" it's for industriel supervision).
I use the name of the server that my company uses to send emails in the "SMTP host", with the port 25. but I have an error "connection failed with the server"
This is the error:
Failed to send email titled "ScadaBR test email" to "FRWLT#bost.com".
Message: "Mail server connection failed; nested exception is
javax.mail.MessagingException: Could not connect to SMTP host:
smtp-eu.app.corp, port: 25; nested exception is:
java.net.SocketException: Unrecognized Windows Sockets error: 10107:
connect"
The email destination is:FRWLT#bost.com
The server name is : smtp-eu.app.corp
Can anyone help me please?
Seeing smtp-eu.app.corp is a .corp address, it's an address in your Local Network? If so, is that server reachable from the webserver hosting the site?
Also some SMTP servers require an username and password or the IP address of the webserver (if it's on the same LAN) must be allowed to send mail from it's IP address through the SMTP server.
If it's an application running on your local computer, could you test with a programm like "putty" to connect to smtp-eu.app.corp on port 25 (choosing telnet as connection method) to see if you can connect to it
Could you provide more details on the situation (if this isn't the answer)?
I could successfully send e-mail notification in Hudson using gmail as the smtp server.
But when I try to configure our own smtp server, it gives the following error when trying to send the test mail:
Failed to send out e-mail
javax.mail.MessagingException: Exception reading response;
nested exception is:
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
Are there any special configurations with the e-mail notifications???
Edit:
Also does it require enforcing the security certificate and if so is there a way to achieve it???
Thanks
Please try using the following settings:
SMTP SERVER : smtp.gmail.com
use SMTP Authentication : true
use SSL : true
SMTP port : 465
I had this problem too. My solution was to make all the necessary configuration (check ssl box and stuff) and CLICK THE SAVE BUTTON before use the test mail.
i just had this issue before clicking the save button.
Changing the SMTP port from 587 to 465 also resolved this issue for me, even though I'm using an alternative SMTP service:
SMTP server: smtp.mandrill.com
Use SMTP Authentication: true
Use SSL: true
SMTP Port: 465
From what I can tell (disclaimer: I am by no means a Hudson/Jenkins expert)
the Hudson/Jenkins email plugin supports SSL encrypted SMTP communication - however this implementation requires that communications are encrypted from the get go.
When connecting on port 587, the server on the other end may expect a STARTTLS command (see this SSL vs TLS vs STARTTLS article). This command is sent using plain-text to 'upgrade' the connection to use SSL/TLS.
Hudson/Jenkins instead attempts to start negotiating SSL on port 587, which is promptly rejected, resulting in the following error:
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
I also tried adding additional JAVA options "-Dmail.smtp.starttls.enable=true" (configured in /etc/default/jenkins on Unbuntu) to enable TLS:
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Dmail.smtp.starttls.enable=true"
Unfortunately this didn't resolve the issue for me.
After changing the port to 465, the SSL negotiation occurred correctly and the communication succeeded.
Hope that helps.