{"action":"created","issue":{"url":"https://api.github.com/repos/jenkinsci/email-ext-plugin/issues/109","labels_url":"https://api.github.com/repos/jenkinsci/email-ext-plugin/issues/109/labels{/name}","comments_url":"https://api.github.com/repos/jenkinsci/email-ext-plugin/issues/109/comments","events_url":"https://api.github.com/repos/jenkinsci/email-ext-plugin/issues/109/events","html_url":"https://github.com/jenkinsci/email-ext-plugin/pull/109","id":111974014,"number":109,"title":"Add post-send script feature","user":{"login":"weisslj","id":99803,"avatar_url":"https://avatars.githubusercontent.com/u/99803?v=3","gravatar_id":"","url":"https://api.github.com/users/weisslj","html_url":"https://github.com/weisslj","followers_url":"https://api.github.com/users/weisslj/followers","following_url":"https://api.github.com/users/weisslj/following{/other_user}","gists_url":"https://api.github.com/users/weisslj/gists{/gist_id}","starred_url":"https://api.github.com/users/weisslj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weisslj/subscriptions","organizations_url":"https://api.github.com/users/weisslj/orgs","repos_url":"https://api.github.com/users/weisslj/repos","events_url":"https://api.github.com/users/weisslj/events{/privacy}","received_events_url":"https://api.github.com/users/weisslj/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-17T17:12:14Z","updated_at":"2015-12-01T15:20:56Z","closed_at":"2015-10-27T03:20:15Z","pull_request":{"url":"https://api.github.com/repos/jenkinsci/email-ext-plugin/pulls/109","html_url":"https://github.com/jenkinsci/email-ext-plugin/pull/109","diff_url":"https://github.com/jenkinsci/email-ext-plugin/pull/109.diff","patch_url":"https://github.com/jenkinsci/email-ext-plugin/pull/109.patch"},"body":"For some tasks pre-send scripts are not sufficient, like rewriting the Message-ID based on the SMTP response for later In-Reply-To headers. This is needed when using Amazon Simple Email Service (AWS SES) for sending emails.\r\n\r\nOther possible use cases are scripts that act upon failed sending attempts.\r\n\r\nHere is a example post-send script that does the message id rewriting for AWS SES:\r\n\r\n```groovy\r\nimport com.sun.mail.smtp.SMTPTransport;\r\nimport java.util.regex.Matcher;\r\nimport java.util.regex.Pattern;\r\nimport hudson.plugins.emailext.ExtendedEmailPublisherDescriptor;\r\n\r\nString smtpHost = props.getProperty(\"mail.smtp.host\", \"\");\r\nString awsRegex = \"^email-smtp\\\\.([a-z0-9-]+)\\\\.amazonaws\\\\.com\\$\";\r\nPattern p = Pattern.compile(awsRegex);\r\nMatcher m = p.matcher(smtpHost);\r\nif (m.matches()) {\r\n    String region = m.group(1);\r\n    if (transport instanceof SMTPTransport) {\r\n        String response = ((SMTPTransport)transport).getLastServerResponse();\r\n        String[] parts = response.trim().split(\" +\");\r\n        if (parts.length == 3 && parts[0].equals(\"250\") && parts[1].equals(\"Ok\")) {\r\n            String MessageID = \"<\" + parts[2] + \"@\" + region + \".amazonses.com>\";\r\n            msg.setHeader(\"Message-ID\", MessageID);\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nReferences:\r\n- https://issues.jenkins-ci.org/browse/JENKINS-30854\r\n- Pull request #108\r\n- http://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-response-codes.html"},"comment":{"url":"https://api.github.com/repos/jenkinsci/email-ext-plugin/issues/comments/160999253","html_url":"https://github.com/jenkinsci/email-ext-plugin/pull/109#issuecomment-160999253","issue_url":"https://api.github.com/repos/jenkinsci/email-ext-plugin/issues/109","id":160999253,"user":{"login":"slide","id":55871,"avatar_url":"https://avatars.githubusercontent.com/u/55871?v=3","gravatar_id":"","url":"https://api.github.com/users/slide","html_url":"https://github.com/slide","followers_url":"https://api.github.com/users/slide/followers","following_url":"https://api.github.com/users/slide/following{/other_user}","gists_url":"https://api.github.com/users/slide/gists{/gist_id}","starred_url":"https://api.github.com/users/slide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slide/subscriptions","organizations_url":"https://api.github.com/users/slide/orgs","repos_url":"https://api.github.com/users/slide/repos","events_url":"https://api.github.com/users/slide/events{/privacy}","received_events_url":"https://api.github.com/users/slide/received_events","type":"User","site_admin":false},"created_at":"2015-12-01T15:20:56Z","updated_at":"2015-12-01T15:20:56Z","body":"Yes, I will be doing one soon. I need to clean-up some other stuff first."}}