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.
Related
I'm trying to configure hMailServer on my computer to be able to send email out and also receive emails. I'm not sure if I have everything set up correctly as some tests works and some others do not so I am confused.
I have already set up in the DNS of my domain these 3 MX records:
mail.example.com
smtp.example.com
imap.example.com
Each one of those records points to the domain name of my server. I am able to connect to the web server of my domain. In my router, I have forwarded ports 25, 110, 143, 465 and 587 to my local computer running the hMailServer application. When running a port check on the web, it looks like port 25, 110 and 465 are blocked, but the rest are not.
If I open my Mozilla Thunderbird mail client, I set up an account I created in hMailServer for the domain in question.
I have also allowed the hMailServer application through my Windows firewall for both the private and public networks. I did the same for the Thunderbird email client.
I can locally send emails to myself and other local domains set up in hMailServer. However, I cannot send or receive any email to/from external recipients, like to/from Gmail or Hotmail for example. I'm getting this error message:
Error Type: SMTP
Connection to recipients server failed.
Error: Host name: 1.1.1.1 (edited) message: 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
Here are the TCP/IP ports summary in hMailServer:
The second part of my question is once I can actually send and receive email to/from external domains, how would I secure the connection (SSL/TSL...)? I already have a SSL certificate for my web server (example.com and www.example.com). Do I just need to generate another one for say mail.example.com or do email servers use a different kind of certificate?
I'm setting up an Alfresco AWS instance and trying to configure inbound email.
As per the documentation I've configured it, hosted the Alfresco mail server on port 1025, set up an iptable rule to forward port 25 --> 1025, set up an folder in Alfresco with the alias 'dropoff' and added my work email as an allowed user for sending emails. I've also ensured all the ports are open on the EC2 instance
So far so good. If I test everything from my local computer with telnet:
helo mywork.com
mail from:myname#mywork.com
rcpt to:dropoff#alfresco.mywork.com
data
From: adinihan#mywork.com
Subject: test mail from command line
this is test number 1
sent from linux box
.
Then it works. I look in the Alfresco folder and there's the test email document. However, if I use Gmail and sign into myname#mywork.com and send an email through Gmail, then it doesn't work. It sends alright and there's nothing in Alfresco logging, however the document just never appears in the Alfresco folder. The from/to address is the same as the telnet command's one.
Since I can telnet from my local computer to the instance I assume it's not an issue with ports on the EC2 instance. Why would telnet work but sending it via Gmail not?
EDIT: got an email back from Google about an hour after I sent it with the error message TLS Negotiation failed: generic::failed_precondition: starttls error (0): protocol error
EDIT 2: here are my inbound emai settings in the global properties file
# Inbound #
email.inbound.unknownUser=anonymous
email.inbound.enabled=true
email.server.enabled=true
email.server.hideTLS=false
email.server.enableTLS=true
email.server.requireTLS=false
email.server.port=1025
email.server.domain=alfresco.amritmro.com
imap.server.enabled=true
imap.server.port=1143
imap.server.host=0.0.0.0
I am able to send email using my gmail account from my grails application but when I use MS exchange server account I am getting this error
Message: Mail server connection failed; nested exception is com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.exg6.exghost.com/, 25; timeout -1;
Configuration I used is :
mail {
host = "smtp.exg6.exghost.com"
port = 25
username = "xxxx"
password = "xxxx"
props = ["mail.smtp.auth":"true",
"mail.smtp.socketFactory.port":"25",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
I am not sure what configuration to use. I tried changing port to 465 & 993 but that didn't work too. Please help
There are several things wrong with your setup. First of all, you are submitting mail to a Microsoft Exchange server (presumably), not Outlook. Outlook is a mail client and only provides end user functionality by connecting to the same server that you are trying to get the Mail plugin to connect to.
Your host name must be a valid Internet DNS host name -- therefore it must be "smtp.exg6.exghost.com". This might be all you have to do depending on the submission/relay policies in your SMTP server. Most likely you need to read on.
The SMTP protocol supports authentication and security for mail submission (new message injection) using either SSL or SASL. If you are using SSL, the default port to connect to is 465 (SMTPS port). If you are using SASL, then most servers are configured to accept new mail with authentication on port 587 (submit service port). Most SMTP servers will not accept mail submission on port 25.
In your case it looks like you are trying to connect with SSL, so you probably want to configure it using the SMTPS setup. To make sure that you have a proper setup, use a mail client like Thunderbird to try to make an SMTP connection to the server. It actually has a discovery algorithm in it that will try the common setups and report success when it has found one. Once you know what the connection parameters are, then you can proceed with configuring the Mail plugin.
I finally got this working. Turns out Microsoft provide a separate API / web-services to send email and perform all other mail related operations. This API gives developers programmatic access to Exchange Online, Exchange Online as part of Office 365, and versions of Exchange starting with Exchange Server 2007 Service Pack 1 (SP1). Click here for details.
exg6.exghost.com is host for Exchange Server 2007
And I am not sure but I think Exchange server 2007 and onwards don't use SMTP.
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.
I have no trouble sending out email with my EC2 server, but how can I check the email that is sent to me? I have an elastic IP setup and modified reverse DNS records. Do I need to install Postfix to receive email?
Ensure that port 25 is active and open on your server. Install an SMTP service on your instance ...postfix is mighty fine.
Ensure you have also set up some MX records if you want to receive email from the world...
I suppose the first thing to do is testing if you can open a telnet connection to port 25 on your server. Then you know if anything is listening for incoming mail.
If not, then you should probably install postfix as well as test your firewall settings (I seem to recall the EC2 having some sort of firewall setting for which ports to allow in the web interface)
edit: correct port number