Not able to send email in jenkins using aws ses

227 Views Asked by At

I am building a pipeline in jenkins. Where an email is always sent as a post action I set up smtp in aws using SES and installed email extension plugin in jenkins, I configured the email extension plugin using smtp server details. My SES is in sandbox mode so both the sender and the recipient need to be verified which ihave done. i am using same email id as sender and receiver. In jenkins I configured this email as sender using 'System Admin e-mail address' setting and successfully sent the test email. I keep getting error in pipeline.

I used below post block

always {

            mail bcc: '', body: "<br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL de build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "${currentBuild.result} CI: Project name -> ${env.JOB_NAME}", to: "[email protected]";  
            
            }

I keep geting below error

com.sun.mail.smtp.SMTPSendFailedException: 554 Message rejected: Email address is not verified. The following identities failed the check in region AP-SOUTH-1: [email protected]

I dont know where this "[email protected]" is coming as a sender in the post action but works fine in test configuration.

I inspected the file: hudson.plugins.emailext.ExtendedEmailPublisher.xml located at /var/lib/jenkins but wasnt of much help.

I tried reinstalling the email extension plugin as well many solutions refrenced in stackoverflow like

https://stackoverflow.com/questions/37528301/email-address-is-not-verified-aws-ses https://stackoverflow.com/questions/49125878/using-aws-ses-smtp-error-554-message-rejected-email-address-is-not-verified-t

Would appreciate the kind assistance.

2

There are 2 best solutions below

0
Rajeeva Gowda On

If we look into the error, looks like email is not configured properly in the jenkins or the email which you are using is not verified in the aws ses account. For me its working fine. Also check the number of emails available in sandbox quota as there is restriction. Try creating ses credentials in another region. Alternatively you can configure a regular service email[if available] using access token directly with credentials.

0
Colin Moreno Burgess On

can you clarify which email extension are you using? With Emailext you should be able to send emails like this:

def subject = "${currentBuild.result} CI: Project name -> ${env.JOB_NAME}" 

emailext(
            mimeType: 'text/html',
            replyTo: '[email protected]',
            subject: subject,
            from: '[email protected]',
            to: '[email protected]',
            body: '<br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL de build: ${env.BUILD_URL}',
            attachLog: true,
            compressLog: true,
            recipientProviders: [[$class: 'DevelopersRecipientProvider']]
    )