Error when sending email with jenkins

Viewed 58199

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?

10 Answers

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:

  1. 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.
  2. I didn't change any McAfee settings for doing this. Just switch your internet to open one.

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

Related