I tried to configure jenkins to send email notification with gmail as the POP provider but I could not succeed
SMTP server - pop.gmail.com
Default user e-mail suffix - @gmail.com
Sender E-mail Address - Foobar CI <[email protected]>
Use SMTP Authentication - yes
User Name - your.email
Password - p******d
Use SSL - yes
SMTP Port - 995
Reply-To Address - [email protected]
Charset - UTF-8
Test failed with : Connection refused
javax.mail.MessagingException: Could not connect to SMTP host: pop.gmail.com, port: 995; nested exception is: java.net.ConnectException: Connection refused: connect
Jenkins comes with an out of box facility to add an email notification for a build project. Step 1 − Configuring an SMTP server. Goto Manage Jenkins → Configure System. Go to the E-mail notification section and enter the required SMTP server and user email-suffix details.
SMTP server: Name of the mail server. If empty the system will try to use the default server (which is normally the one running on localhost ). Jenkins uses JavaMail for sending out e-mails, and JavaMail allows additional settings to be given as system properties to the container.
The hostname for the Google SMTP server is smtp.gmail.com and if you use SSL, then the correct Port is 465.
A POP server is usually just for receiving mails, not sending mails.
Below are the updated gmail SMTP server configuration :
Gmail SMTP server address: smtp.gmail.com
Gmail SMTP user name: Your full Gmail address (e.g. [email protected])
Gmail SMTP password: Your Gmail password
Gmail SMTP port: 465
Gmail SMTP TLS/SSL required: yes
This configuration is working fine for me .
Obtain application specific password
sing-in to gmail account >> navigate to settings >> privacy and security settings
setup two step verification settings (because without two step verification we cannot generate application specific password)
after setting up two step verification setting in gmail account navigate back to security and privacy settings
click on application specific password >> give the name of the application in the drop down as Jenkins (google by default does not have any specific application password setting for Jenkins) >> this will generate password note down the password generated
Note : Since the Password has a overall control over you gmail account disclosing it may lead serious consequences
Setup SMTP configuration for sending the gmail
navigate in the following path from dashboard after logging in
manage Jenkins
>> configure system
>> scroll down to email notification section
enter the following parameters
smtp server : smtp.gmail.com
default user email suffix : @gmail.com
select advanced
check smtp authentication
username : (Your gmail id)
password : (application specific password generated from previous step)
check use SSL
SMTP port : 465
Reply to address : [email protected](optional)
Charset : UTF-8 (by default it is UTF-8)
select Test configuration mail
Test e-mail recipient : <enter recipient email id >
click on test configuration which will send a test mail to the recipient e-mail id
The above configuration didn't work because of added security measures by google. 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.
https://support.google.com/accounts/answer/6010255
Go to the "Less secure apps" section in My Account. Next to "Access for less secure apps," select Turn on. (Note to G Suite users: This setting is hidden if your administrator has locked less secure app account access.)
After this emails were triggered successfully.
The following screenshot illustrates the e-mail configuration you'd need to do to send e-mails from GMail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With