How to send email from jenkins using port number 25 - jenkins

How to send email from jenkins using port number 25.
Jenkins release version 2.235.3 SMTP port field for Extended E-mail Notification keeps getting reverted back to port no. 25 even after adding either 465 or 587 port number in that field and clicking "Apply and Save" buttons.
i have used telnet to verify whether smtp.gmail.com is accessible/open on ports 25,465 & 587.
smtp.gmail.com is accessible and open on 465 and 587, but not on port 25 & telnet gives me below message.
"telnet: Unable to connect to remote host: Network is unreachable"
how can we use port number 25 of smtp to send mails using jenkins or general.
Is it even advisable to use port no. 25 of gmail to send emails from third party vendors.

You can follow status of this issue from link here https://issues.jenkins.io/browse/JENKINS-63367
On 08/14/2020 they will be releasing a fix for it but if you do not want to wait for it you can downgrade email-ext-plugin to 2.71 and you will be able to change SMTP port number. This is an issue everyone is facing for version 2.73 and 2.74. Hope it will be fixed with 2.74 version.
If you just setup your Jenkins, you will not have an option to downgrade, instead:
uninstall plugin and then navigate to https://updates.jenkins.io/download/plugins/email-ext/ and download version 2.71
Go to Jenkins > Manage Jenkins> Manage Plugins > Advanced > Upload Plugin and choose downloaded verion and click on upload.
Let it finish installing and after that, restart your Jenkins. Now you should be able to change SMTP port without any issue!

Related

Telnet: Network is unreachable

I'm new with Ruby on Rails, so I was trying to figure out how to send emails from the server.
I have followed several tutorial without success, so decided to check the basics and see if port 25 is open, I get the following line:
$ telnet example.com 25
Trying 93.184.216.34...
Trying 2606:2800:220:1:248:1893:25c8:1946...
telnet: Unable to connect to remote host: Network is unreachable
I have read about Conection refused but I can't figure out about unreachable is my port blocked or maybe my ISP?
Any help is useful
if you using ubuntu / debian based
check your server firewall and allow port 25
sudo ufw allow 25/tcp
1. install postfix if you want to build your own smtp server
2. other Alternatif
using gmail account as smtp server in rails , action mailer with gmail as smtp
or you can register to sendgrid.com as smtp server (not free but can apply testing account for one year trial)

Jenkins email could not connect failure

I have tried with various SMTP servers but I cannot get Jenkins to send an email. I get the could not connect error - nothing else, just this error.
See the screenshot below.
Any ideas why? I am using the Jenkins docker container, firewall is off.
I do not have an email server running inside the Jenkins container. I figure I don't need one if Gmail is going to send the email for me.
Your Gmail configuration looks correct. Usually these issues come down to a firewall, but if you are sure that is not the problem it could be your Gmail account settings.
An additional configuration is required in the Gmail account from which the mail is being triggered. This step authorizes apps like Jenkins to use the Gmail account.
Gmail - Allowing less secure apps to access your account
After performing this step emails should be triggered successfully.
UNBELIEVABLE. 2 days later. Fixed.
I found that my Cloud computing provider (Scaleway) disable outgoing SMTP by default and I had to enable SMTP via their web interface. Details here.
These commands helped me to determine that outgoing SMTP was in fact as dead as a donut:
telnet smtp.gmail.com 465
openssl s_client -connect smtp.gmail.com:587 -starttls smtp
echo "Hello world" | swaks -4 --server smtp.gmail.com:587 --from user#gmail.com --to user#example.net -tls --tls-protocol sslv3 --auth PLAIN --auth-user user#gmail.com --auth-password 7654321 --h-Subject "Test message" --body -

Jenkins e-mail notification issue / Ubuntu server issue

I'm running Jenkins 1.519 on a server with Ubuntu 13.04 and I have a problem with the e-mail notification system.
When I try to get Jenkins to send an e-mail (either the test configuration button in the manage Jenkins page, or as a build step of a job) Jenkins gives me this notification: "E-mail sent successfully", but no email is actually arriving to the recipients.
Jenkins is telling me that the e-mail notifications are working properly, but nothing is actually happening when it's supposed to. No error messages are given.
Edit:
Email settings:
SMTP server: my smtp server address
Default user e-mail suffix: -
Use SMTP authentication: check
User Name: my email username
Password: my email password
Use SSL: nope
SMTP port: 25
Reply-To Address: my email address
Charset: UTF-8
Test configuration by sending e-mail: check
Test e-mail recipient: my email address.
Edit2:
So I suppose it probably isn't necessarily a Jenkins-issue, but an issue with my server? What kind of configurations are there needed on the server side to get the email-send working? Or is the Jenkins' email-system supposed to work without hassle?
Please try to check the use SSL. Here is the Email Notification set up that's working in my system. I've also tested it in Windows, mac, and linux machines and this setup works for those systems.
Need to add proper "System Admin e-mail address" in the Configure global settings of Jenkins.
I had the same issue in Linux RedHat version 6.6 and we have found the default host and port for the SMTP is not enabled in IP table, once this is enabled it started working.
Also check if the default SMTP port is enabled in the system where jenkins is installed. This could also be the reason for failed email notification through jenkins.

Jenkins email notification setup

I am trying to setup email notification for my jenkins server for build failures.
Things I have tried:
1) Use my company smtp mail server with authentication - does not work. Connection refused
2) Setup my own James mail server. SMTP server - localhost. Authentication - admin,admin. Port 25. I see that my SMTP server is running. - does not work. Connection refused
3) Use my personal gmail account with authentication - Works!!!
I have followed other discussions on this topic but not got an answer.
Some say it may be a firewall issue but I am not sure how to overcome it.
Any suggestions are most welcome.
Thanks,
I had the similar problem.
I was on wireless + windows 7 and when checked internet connectivity status, IPV4 was connected to internet but IPV6 was not.
Looks like IPV6 is used as default on windows 7 but it was not able to connect to the SMTP server using it.
Started my jenkins with -Djava.net.preferIPv4Stack=true and it worked for me.
java -Djava.net.preferIPv4Stack=true -jar jenkins.war and the "Test Configuration" worked.
For Sending Email Notifications using localhost SMTP server you need to install postfix,
For Linux :
sudo apt-get install postfix
telnet localhost 25
and then try sending test email. :)
I know this is late but just in case any other person is facing problem!

Error when sending email with jenkins

I'm trying to use email sending in jenkins. I leave default values, click on 'Test configuration' button and get error:
Failed to send out e-mail
javax.mail.MessagingException: Could not connect to SMTP host:
localhost, port: 25; nested exception is: java.net.SocketException:
Permission denied: connect
at
com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1934)
at
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)
What I missed? It's not working by default?
I configured Jenkins with my gmail account using the settings as given in the image below.
I had similar problem couldn't send email via zoho. The configurations were: SMPT TLS Zoho Configurations
I just need to change system admin address in jenkins configurations to the same one in email-notifications.
Here you can find the system admin e-mail:
Manage Jenkins -> Configure System -> Jenkins Location -> System Admin e-mail address
If anyone is still having issues with emails in Jenkins, a lot has changed since then.
If you have a custom domain name for g-mail and it requires a 2-step authentication to login, for example you#yourcompany.com,
SMTP server should still be smtp.gmail.com
Default user e-mail suffix should be #yourcompany.com
Because Google no longer allows you to simply use your default e-mail password to login via any outside apps, in this case Jenkins. It is a lot more secure to let Google create a custom password for Jenkins rather than turning off G-Mail's security features to allow Jenkins access to your account.
Create the App Password here:
https://security.google.com/settings/security/apppasswords
Use the generated password in Jenkins -> Configure Systems -> E-Mail Configuration
I was also struggling with this error. Here is how I resolved it.
1. Google account settings:
Go to Gmail account settings -> Forwarding and POP/IMAP -> IMAP Access -> Enable IMAP (This is to enable both IMAP & SMTP settings)
Check configuration details that are mentioned as:
Outgoing Mail (SMTP) Server: smtp.gmail.com
Requires SSL: Yes
Requires TLS: Yes (if available)
Requires Authentication: Yes
Port for SSL: 465
Port for TLS/STARTTLS: 587
(Rather than going with settings mentioned by anyone, please checkout your account for this info as settings/configurations keep on changing. )
2. Jenkins (2.121.3) settings:
Manage Jenkins -> Configure System -> Scroll down to E-mail Notification tab -> Advanced
Use SMTP Authentication: checked
User Name: <your gmail id>
Password: <your password>
Use SSL: checked
SMTP Port: 465
Reply-To Address: Optional (I left it blank. You can give any email id you want)
Charset: UTF-8
Enable "Test configuration by sending test e-mail", give test email id and hit "test configuration" button
NOTE:
Make sure you are connected to open network (that is not antivirus protected or antivirus may block your emails). I used my phone internet instead of office internet for testing this.
I didn't change any McAfee settings for doing this. Just switch your internet to open one.
There is no SMTP server running on localhost or you don't have the permission to connect to it.
Check the configuration of Jenkins.
You probably don't have SMTP running on your machine, which is the usual state for Windows or Mac servers.
To test this, use any known mail-server for that, for example - if you have a gmail account, try this:
SMTP server: smtp.gmail.com
Default user e-mail suffix: #something.something
Sender E-mail Address: your-mail#gmail.com
If planning to use the mail-notifications as part of your build-process,
it is best to set the SMTP properly, or maybe move the Jenkins/Hudson server to a machine that supports this.
Check if your provider blocks port 25.
In order to make a proper test
telnet smtp.gmail.com 25
If you receive an answer like this:
telnet: connect to address 74.125.206.108: Connection refused
You should go with smtp authentication as described in harikrishna-pai's answer
I had same issue and managed to resolved by following,
Generate Gmail App Password,
Gmail App
In Jenkins use the app password,
Jenkin's Configuration
I Had the same issue.
After witch hunting a lot, I found a solution as below:
even turn on - less secure apps, I was struggling since 6 hour.
the second option:
And go to 
https://accounts.google.com/DisplayUnlockCaptcha
 and click Continue.  
this resolved the issue.
I had the same issue as i was using avast it blocked smtp mails so i disabled it and it worked

Resources