Error While Sending Extended email notification from Jenkins - jenkins

i have configured extended email notification in Jenkins configure system, and created a new job and configured editable email notification, once the build is completed, email is not sent and getting the following in console Not sent to the following valid addresses: user#domain.com
and here is the debug log
RSET
DEBUG SMTP: EOF: [EOF]
DEBUG SMTP: MessagingException while sending, THROW:
com.sun.mail.smtp.SMTPSendFailedException: 451 5.7.3 STARTTLS is required to send mail [PN********6.INDPRD01.PROD.OUTLOOK.COM]
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2374)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1808)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1285)
at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:541)
at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:446)
at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:354)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:803)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:752)
at hudson.model.Build$BuildExecution.cleanUp(Build.java:187)
at hudson.model.Run.execute(Run.java:1954)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Not sent to the following valid addresses: user#domain.com
SMTPSendFailedException message: 451 5.7.3 STARTTLS is required to send mail [P******06.INDPRD01.PROD.OUTLOOK.COM]
QUIT
DEBUG SMTP: EOF: [EOF]
Here is the screenshot how i configured email notification in Configure System:

Just configure this in Jenkins options file:
JENKINS_JAVA_OPTIONS : -Djava.awt.headless=true -Dmail.smtp.starttls.enable=true
JENKINS_OPTS : -Dmail.smtp.starttls.enable=true

Add this Java argument in Jenkins.xml file for Windows or in /etc/default/jenkins for Ubuntu:
-Dmail.smtp.starttls.enable=true
Alternatively, you can try to change the SMTP port from 587 to 465. Use SSL should be true in this case.
Reference:
Jenkins SMTP TLS
https://superuser.com/questions/879361/how-to-configure-jenkins-email-notifications-through-outlook

Related

Error waiting for SSH: Packer experienced an authentication error : using vsphere-iso

getting below error while running packer using vsphere-iso builder.
Error waiting for SSH: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password keyboard-interactive], no supported methods remain
config.json
"communicator": "ssh",
"ssh_username": "{{user `ssh_username`}}",
"ssh_password": "{{user `ssh_password`}}",
"ssh_timeout": "30m",
username and password is coming from Jenkins at run time. same has beed updated in autounattend.xml , if i hard-code the credential in config.json file then its working fine. dont know what's the issue
packer debug log
2022/05/09 10:16:20 packer.exe plugin: [DEBUG] Detected authentication error. Increasing handshake attempts.
2022/05/09 10:16:27 packer.exe plugin: [INFO] Attempting SSH connection to 172.16.112.59:22...
2022/05/09 10:16:27 packer.exe plugin: [DEBUG] reconnecting to TCP connection for SSH
2022/05/09 10:16:27 packer.exe plugin: [DEBUG] handshaking with SSH
2022/05/09 10:16:28 packer.exe plugin: [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password keyboard-
I got the solution as below
In autounattend.xml file password was given as plain text true , which needs to be change to false.

JavaMail and Oauth2: Exception "Can't send command to SMTP host" / "SSLHandshakeException: No appropriate protocol"

I get the following exception when trying to send a mail with JavaMail with OAuth2:
javax.mail.MessagingException: Can't send command to SMTP host (javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate))
I have already checked dozens of stackOverFlow posts and none of the solutions work.
This is my javamail config (commented out some other configs I have tried):
...
String oauth2_access_token = <procedure to aquire a token>;
Properties props = new Properties();
props.put("mail.host",config.getString("MAILSERVER"));
props.put("mail.smtp.port", config.getString("MAILPORT"));
props.put("mail.smtp.auth", "true");
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.starttls.required", "true");
props.put("mail.smtp.ssl.protocols", "TLSv1.1 TLSv1.2 TLSv1.3");
//props.put("mail.smtp.ssl.trust", "*");
props.put("mail.smtp.auth.mechanisms", "XOAUTH2");
//props.put("mail.smtp.auth.xoauth2.disable", false);
//props.put("mail.smtp.sasl.enable", "true");
//props.put("mail.smtp.auth.login.disable","true");
//props.put("mail.smtp.auth.plain.disable","true");
props.put("mail.debug", "true");
props.put("mail.debug.auth", "true");
// Connect
javax.mail.Session mailSession = javax.mail.Session.getInstance(props);
mailSession.setDebug(true);
SMTPTransport transport = (SMTPTransport) mailSession.getTransport("smtp");
transport.connect(config.getString("MAILSERVER"),
Integer.parseInt(config.getString("MAILPORT")), config.getString("MAILUSER"), oauth2_access_token);
Here is some output:
[apache-tomcat-9.0.54]: DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "smtp.office365.com", port 587, isSSL false
[apache-tomcat-9.0.54]: 220 SOMEANONYMIZEDSERVERPREFIX.outlook.office365.com Microsoft ESMTP MAIL Service ready at Wed, 16 Mar 2022 10:16:37 +0000
DEBUG SMTP: connected to host "smtp.office365.com", port: 587
[apache-tomcat-9.0.54]: EHLO MY_COMPUTER_NAME
[apache-tomcat-9.0.54]: 250-SOMEANONYMIZEDSERVERPREFIX.outlook.office365.com Hello [MY_IP_ADRESS]
250-SIZE 157286400
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250 SMTPUTF8
STARTTLS
[apache-tomcat-9.0.54]: 220 2.0.0 SMTP server ready
[apache-tomcat-9.0.54]: EHLO MY_COMPUTER_NAME
[apache-tomcat-9.0.54]: ERROR 2022-03-16 11:16:39,407 [..MyProgramException..] - javax.mail.MessagingException: Can't send command to SMTP host (javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate))
I think it has to do with issuing the AUTH command because it is not listed in output. The connection over TLS is established successfully so I think the SSLHandshake Exception might be misleading. So what gives?
Might it have to do with the token? The scope I had to use for the token aquisition is ".default". "Mail.Send" didn't work.
I am using the newest JavaMail version 1.6.2 and AdoptOpenJdk 11.0.12.
I also double checked java.security config. TLS 1v2 and 1v3 algorithms are not disabled.
I found the solution myself. Maybe somone can make use of it:
The code above was not false to my knowledge. The actual reason was, that I should not have used a token acquisition with client credentials but only with username/password and client id.
I am not sure if JavaMail supports this because in the documentation I could not find anything about it. The rare examples about this are usually with client credentials.
As you can see above, no AUTH command was triggered because I had not the permission to do it obviously.
What I needed to do aswell was to use the Microsoft Graph API not only to aquire a token via "password/username provider" (this type) instead of the "client credential provider" (link) but also to actually trigger a send mail command via Microsoft Graph API (link).
The client credential provider was in my case not sufficient because the admin had not specified permissions to send mails.
Thus, I didn't use JavaMail anymore for this and needed another token acquisition provider.

Jenkins : getting error when we try to send notification from Jenkins : error "550 5.5.0 Invalid EHLO/HELO domain"

Jenkins : getting error when we try to send notification from Jenkins : error "550 5.5.0 Invalid EHLO/HELO domain"
Check the full error :
Not sent to the following valid addresses: prakashranasinghe555#gmail.com admin
SMTPSendFailedException message: 550 5.5.0 Invalid EHLO/HELO domain.
Next SMTPSenderFailedException message: 550 5.5.0 Invalid EHLO/HELO domain.
QUIT
221 2.0.0 closing connection u13sm8039654pfi.51 - gsmtp
Finished: SUCCESS
++++++++++
Checking for post-build
Performing post-build step
Checking if email needs to be generated
Email was triggered for: Always
Sending email for trigger: Always
Sending mail from default account using System Admin e-mail address
messageContentType = text/plain; charset=UTF-8
Collecting change authors...
build: 32
Adding recipients from project recipient list
Analyzing: prakashranas555#gmail.com
Looking for: prakashranasinghe#gmail.com
starting at: 0
firstFoundIdx: 0
firstFoundIdx-substring: prakashranasinghe555#gmail.com
=> found type: 0
Analyzing: prakashranasinghe555#gmail.com
Looking for: prakashranasinghe555#gmail.com
starting at: 0
firstFoundIdx: 0
firstFoundIdx-substring: prakashranasinghe555#gmail.com
=> found type: 0
Analyzing: prakashranasinghe555#gmail.com
Looking for: prakashranasinghe555#gmail.com
starting at: 0
firstFoundIdx: 0
firstFoundIdx-substring: prakashranasinghe555#gmail.com
=> found type: 0
Adding admin with address admin
Analyzing: admin
Looking for: admin
starting at: 0
firstFoundIdx: 0
firstFoundIdx-substring: admin
=> found type: 0
Analyzing: admin
Looking for: admin
starting at: 0
firstFoundIdx: 0
firstFoundIdx-substring: admin
=> found type: 0
Analyzing: admin
Looking for: admin
starting at: 0
firstFoundIdx: 0
firstFoundIdx-substring: admin
=> found type: 0
Adding recipients from trigger recipient list
Successfully created MimeMessage
Sending email to: prakashranasinghe555#gmail.com admin
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 25, isSSL false
220 smtp.gmail.com ESMTP u13sm8039654pfi.51 - gsmtp
DEBUG SMTP: connected to host "smtp.gmail.com", port: 25
EHLO Prakashr.Direct.local
250-smtp.gmail.com at your service, [123.231.87.10]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-PIPELINING
250 SMTPUTF8
DEBUG SMTP: Found extension "SIZE", arg "35882577"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "SMTPUTF8", arg ""
DEBUG SMTP: use8bit false
MAIL FROM:<nobody#nowhere>
550 5.5.0 Invalid EHLO/HELO domain.
DEBUG SMTP: got response code 550, with response: 550 5.5.0 Invalid EHLO/HELO domain.
RSET
250 2.1.5 Flushed u13sm8039654pfi.51 - gsmtp
DEBUG SMTP: MessagingException while sending, THROW:
com.sun.mail.smtp.SMTPSendFailedException: 550 5.5.0 Invalid EHLO/HELO domain.
;
nested exception is:
com.sun.mail.smtp.SMTPSenderFailedException: 550 5.5.0 Invalid EHLO/HELO domain.
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2374)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1808)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1285)
at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:539)
at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:444)
at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:354)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:21)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:808)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:757)
at hudson.model.Build$BuildExecution.cleanUp(Build.java:189)
at hudson.model.Run.execute(Run.java:1958)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:100)
at hudson.model.Executor.run(Executor.java:433)
Caused by: com.sun.mail.smtp.SMTPSenderFailedException: 550 5.5.0 Invalid EHLO/HELO domain.
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1817)
... 12 more
Not sent to the following valid addresses: prakashranasinghe555#gmail.com admin
SMTPSendFailedException message: 550 5.5.0 Invalid EHLO/HELO domain.
Next SMTPSenderFailedException message: 550 5.5.0 Invalid EHLO/HELO domain.
QUIT
221 2.0.0 closing connection u13sm8039654pfi.51 - gsmtp
Finished: SUCCESS
According to an answer at ServerFault to SMTP Server 550 Access denied - Invalid HELO name it's probably the line:
EHLO Prakashr.Direct.local
which doesn't have an FQDN.

NullPointerException when sending notification email by jenkins

I configured Jenkins to send notification by email in case of error in build.
java: open jdk 11.0.11
maven: Apache Maven 3.0.5
jenkins: 2.277.4
mailer plugin: 1.34
This is the config:
Notification par email
Serveur SMTP:smtp.gmail.com
Nom d'utilisateur:email_adress
Mot de passe:my_password
Utiliser SSL
Port SMTP:465
When i send test email everything works fine.
When a build is unstable and the mailer is triggered i get this error:
java.lang.NullPointerException
at javax.mail.internet.InternetAddress.toString(InternetAddress.java:472)
at javax.mail.internet.MimeMessage.setAddressHeader(MimeMessage.java:733)
at javax.mail.internet.MimeMessage.setFrom(MimeMessage.java:382)
at jenkins.plugins.mailer.tasks.MimeMessageBuilder.buildMimeMessage(MimeMessageBuilder.java:204)
at hudson.tasks.MailSender.createEmptyMail(MailSender.java:407)
at hudson.tasks.MailSender.createFailureMail(MailSender.java:274)
at hudson.tasks.MailSender.createMail(MailSender.java:182)
at hudson.tasks.MailSender.run(MailSender.java:112)
at hudson.tasks.Mailer.perform(Mailer.java:179)
at hudson.tasks.Mailer.perform(Mailer.java:142)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:803)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:752)
at hudson.model.Build$BuildExecution.post2(Build.java:177)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:697)
at hudson.model.Run.execute(Run.java:1932)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Can you try setting system admin email and see?
Manage Jenkins -> Configure System -> Jenkins Location -> System Admin e-mail address

Failed to send out e-mail using email plugin at Jenkins

Configured right email and password but still getting following Error :
com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 https://support.google.com/mail/?p=WantAuthError u16sm2613119pjb.2 - gsmtp
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2057)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1580)

Resources