24 Commits

Author SHA1 Message Date
98b61f505d Make custom secure ports available (#51) 2021-05-03 18:02:47 +02:00
938c7ffae5 Merge pull request #50 from dawidd6/dependabot-add-v2-config-file
Upgrade to GitHub-native Dependabot
2021-04-29 23:45:28 +02:00
d892e3932a Upgrade to GitHub-native Dependabot 2021-04-29 15:35:41 +00:00
c88d504a7c README: update
[skip ci]
2021-04-25 16:45:57 +02:00
16ca24fcf8 README: missing dot
[skip ci]
2021-04-25 16:43:10 +02:00
b5690f2fd6 README: hide link
[skip ci]
2021-04-25 16:42:37 +02:00
21a68c2b95 workflows: fix 2021-04-25 16:36:40 +02:00
a305c08e85 README: name 2021-04-25 16:30:16 +02:00
f94f0e37fa workflows: fix input
[skip ci]
2021-04-25 16:23:58 +02:00
75773ecb8c workflows: adjust tests 2021-04-25 16:20:37 +02:00
63f6c7e5d2 main: don't convert markdown in plain body ever 2021-04-25 16:19:34 +02:00
b738850ab1 main: style fix 2021-04-25 16:14:13 +02:00
c938b3cb85 support multipart email (#48)
Co-authored-by: Dawid Dziurla <dawidd0811@gmail.com>
2021-04-25 16:11:54 +02:00
32390e9a18 Merge pull request #46 from dawidd6/dependabot-npm_and_yarn-actions-core-1.2.7
build(deps): bump @actions/core from 1.2.6 to 1.2.7
2021-04-14 09:14:45 +02:00
b7c5d1ceb6 build(deps): bump @actions/core from 1.2.6 to 1.2.7
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.2.6 to 1.2.7.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-14 04:58:57 +00:00
df34b4ded5 Updates README.md to reflect changes suggested in issue #43 relating to changing gmail settings (#45)
Co-authored-by: Dawid Dziurla <dawidd0811@gmail.com>
2021-04-13 20:24:22 +02:00
3ce6fdc63e Add replyTo field support (#41)
Co-authored-by: Dawid Dziurla <dawidd0811@gmail.com>
2021-04-07 19:34:58 +02:00
f1b626cfd4 main: fix 2021-04-02 09:11:00 +02:00
0037ae15ac Merge pull request #39 from dawidd6/ignore-cert
main: ignore cert if desired
2021-04-02 00:04:33 +02:00
5b924828c0 README: mention ignore_cert 2021-04-02 00:02:58 +02:00
a2f920a18b action: add ignore_cert input 2021-04-02 00:02:46 +02:00
3082f5221c main: ignore cert if desired 2021-04-02 00:00:57 +02:00
9210f61cf4 node_modules: update 2021-03-23 21:57:43 +01:00
a5a673e774 README: use example domain
Closes: #31
2021-02-22 22:16:12 +01:00
15 changed files with 214 additions and 95 deletions

24
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,24 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
time: "04:00"
pull-request-branch-name:
separator: "-"
open-pull-requests-limit: 10
ignore:
- dependency-name: nodemailer
versions:
- 6.4.18
- 6.5.0
- 6.6.0
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
time: "04:00"
pull-request-branch-name:
separator: "-"
open-pull-requests-limit: 10

View File

@ -13,12 +13,14 @@ jobs:
max-parallel: 1
matrix:
include:
- content_type: text/markdown
- subject: Plain body (attachment)
attachments: action.yml
body: file://README.md
- content_type: text/html
attachments: package.json,package-lock.json
body: |
first line
second line
- subject: HTML body (attachments)
attachments: package.json,package-lock.json
html_body: |
<!DOCTYPE html>
<html>
<body>
@ -26,16 +28,16 @@ jobs:
<p>Paragraph</p>
</body>
</html>
- content_type: text/html
- subject: Plain body (Markdown)
convert_markdown: true
body: |
# h1
## h2
### h3
**bold**
_italics_
- bullet 1
- bullet 2
body: file://README.md
- subject: HTML body (Markdown)
convert_markdown: true
html_body: file://README.md
- subject: Multipart body (Markdown)
convert_markdown: true
body: file://README.md
html_body: file://README.md
steps:
- name: Checkout code
uses: actions/checkout@v2
@ -46,10 +48,10 @@ jobs:
server_port: 465
username: ${{secrets.USERNAME}}
password: ${{secrets.PASSWORD}}
subject: ${{github.repository}}
subject: ${{matrix.subject}}
body: ${{matrix.body}}
html_body: ${{matrix.html_body}}
to: ${{github.event.pusher.email}}
from: github-actions
content_type: ${{matrix.content_type}}
convert_markdown: ${{matrix.convert_markdown}}
attachments: ${{matrix.attachments}}
convert_markdown: ${{matrix.convert_markdown}}

View File

@ -2,31 +2,63 @@
An action that simply sends a mail to multiple recipients.
Some features:
- plain text body
- HTML body
- multipart body (plain text + HTML)
- Markdown to HTML converting
- file attachments
## Usage
```yaml
- name: Send mail
uses: dawidd6/action-send-mail@v2
uses: dawidd6/action-send-mail@v3
with:
# Required mail server address:
server_address: smtp.gmail.com
# Required mail server port:
server_port: 465
# Required mail server username:
username: ${{secrets.MAIL_USERNAME}}
# Required mail server password:
password: ${{secrets.MAIL_PASSWORD}}
# Required mail subject:
subject: Github Actions job result
# Literal body:
body: Build job of ${{github.repository}} completed successfully!
# Read file contents as body:
body: file://README.md
to: obiwan@tatooine.com,yoda@dagobah.com
# Required recipients' addresses:
to: obiwan@example.com,yoda@example.com
# Required sender full name (address can be skipped):
from: Luke Skywalker # <user@example.com>
# Optional carbon copy recipients
cc: kyloren@starkiller.com,leia@alderaan.com
# Optional blind carbon copy recipients
bcc: r2d2@jakku.com,hansolo@milleniumfalcon.com
# Optional content type (defaults to text/plain):
content_type: text/html
# Optional whether this connection use TLS (default is true if server_port is 465)
secure: true
# Optional plain body:
body: Build job of ${{github.repository}} completed successfully!
# Optional HTML body read from file:
html_body: file://README.html
# Optional carbon copy recipients:
cc: kyloren@example.com,leia@example.com
# Optional blind carbon copy recipients:
bcc: r2d2@example.com,hansolo@example.com
# Optional recipient of the email response:
reply_to: luke@example.com
# Optional unsigned/invalid certificates allowance:
ignore_cert: true
# Optional converting Markdown to HTML (set content_type to text/html too):
convert_markdown: true
# Optional attachments:
attachments: attachments.zip,git.diff,./dist/static/main.js
```
## Troubleshooting
### Gmail
Gmail security settings may cause this Action to fail. This failure may involve a message in the GitHub Actions details about access being denied and an email from Google to the email account being used about a sign-in being blocked and why.
Changes in Gmail settings may be necessary to get this action to work.
1. Google treats this method of using email as a "Less Secure App". However, "Less Secure Apps" can be enabled in Google profile settings. There doesn't appear to be a static link for this, but if you go to Google profile settings while signed-in and type "less secure apps" into the search bar, the appropriate instructions will come up.
2. IMAP needs to be enabled in Gmail settings as described [here](https://support.google.com/mail/answer/7126229?hl=en).
3. If the Gmail account you're trying to use in this Action is already 2FA (Two Factor Authentication) enabled, the 2FA password will need to be provided as well, which isn't included in the default template.
Users who have had problems have reported success by doing each of these three steps or by doing the first two steps and using a Gmail account that didn't have 2FA enabled.

View File

@ -20,25 +20,33 @@ inputs:
subject:
description: Subject of mail message
required: true
body:
description: Body of mail message (might be a filename prefixed with file:// to read from)
required: true
to:
description: Recipients mail addresses (separated with comma)
required: true
from:
description: Full name of mail sender (might be with an email address specified in <>)
required: true
secure:
description: Whether this connection use TLS (default is true if server_port is 465)
required: false
body:
description: Body of mail message (might be a filename prefixed with file:// to read from)
required: false
html_body:
description: HTML body of mail message (might be a filename prefixed with file:// to read from)
required: false
cc:
description: Carbon copy recipients (separated with comma)
required: false
bcc:
description: Blind carbon copy recipients (separated with comma)
required: false
content_type:
description: Content-Type HTTP header (text/html or text/plain)
reply_to:
description: An email address that will appear on the Reply-To field
required: false
ignore_cert:
description: Allow unsigned/invalid certificates
required: false
default: text/plain
convert_markdown:
description: Convert body from Markdown to HTML (set content_type input as text/html too)
required: false

25
main.js
View File

@ -1,7 +1,7 @@
const nodemailer = require("nodemailer")
const core = require("@actions/core")
const fs = require("fs")
const showdown = require('showdown')
const showdown = require("showdown")
function getBody(bodyOrFile, convertMarkdown) {
let body = bodyOrFile
@ -22,7 +22,7 @@ function getBody(bodyOrFile, convertMarkdown) {
}
function getFrom(from, username) {
if (from.match(/.+<.+@.+>/)) {
if (from.match(/.+ <.+@.+>/)) {
return from
}
@ -36,33 +36,40 @@ async function main() {
const username = core.getInput("username", { required: true })
const password = core.getInput("password", { required: true })
const subject = core.getInput("subject", { required: true })
const body = core.getInput("body", { required: true })
const from = core.getInput("from", { required: true })
const to = core.getInput("to", { required: true })
const secure = core.getInput("secure", { required: false })
const body = core.getInput("body", { required: false })
const htmlBody = core.getInput("html_body", { required: false })
const cc = core.getInput("cc", { required: false })
const bcc = core.getInput("bcc", { required: false })
const contentType = core.getInput("content_type", { required: true })
const replyTo = core.getInput("reply_to", { required: false })
const attachments = core.getInput("attachments", { required: false })
const convertMarkdown = core.getInput("convert_markdown", { required: false })
const ignoreCert = core.getInput("ignore_cert", { required: false })
const transport = nodemailer.createTransport({
host: serverAddress,
port: serverPort,
secure: serverPort == "465",
secure: secure ? true : serverPort == "465",
auth: {
user: username,
pass: password,
}
},
tls: ignoreCert ? {
rejectUnauthorized: false
} : undefined
})
const info = await transport.sendMail({
from: getFrom(from, username),
to: to,
subject: subject,
cc: cc ? cc : undefined,
bcc: bcc ? bcc : undefined,
subject: subject,
text: contentType != "text/html" ? getBody(body, convertMarkdown) : undefined,
html: contentType == "text/html" ? getBody(body, convertMarkdown) : undefined,
replyTo: replyTo ? replyTo : undefined,
text: body ? getBody(body, false) : undefined,
html: htmlBody ? getBody(htmlBody, convertMarkdown) : undefined,
attachments: attachments ? attachments.split(',').map(f => ({ path: f.trim() })) : undefined
})
} catch (error) {

6
node_modules/.package-lock.json generated vendored
View File

@ -112,9 +112,9 @@
}
},
"node_modules/nodemailer": {
"version": "6.4.17",
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.4.17.tgz",
"integrity": "sha512-89ps+SBGpo0D4Bi5ZrxcrCiRFaMmkCt+gItMXQGzEtZVR3uAD3QAQIDoxTWnx3ky0Dwwy/dhFrQ+6NNGXpw/qQ==",
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.5.0.tgz",
"integrity": "sha512-Tm4RPrrIZbnqDKAvX+/4M+zovEReiKlEXWDzG4iwtpL9X34MJY+D5LnQPH/+eghe8DLlAVshHAJZAZWBGhkguw==",
"engines": {
"node": ">=6.0.0"
}

10
node_modules/nodemailer/CHANGELOG.md generated vendored
View File

@ -1,5 +1,15 @@
# CHANGELOG
## 6.5.0 2021-02-26
- Pass through textEncoding to subnodes
- Added support for AWS SES v3 SDK
- Fixed tests
## 6.4.18 2021-02-11
- Updated README
## 6.4.17 2020-12-11
- Allow mixing attachments with caendar alternatives

2
node_modules/nodemailer/README.md generated vendored
View File

@ -2,6 +2,8 @@
[![Nodemailer](https://raw.githubusercontent.com/nodemailer/nodemailer/master/assets/nm_logo_200x136.png)](https://nodemailer.com/about/)
> Sponsored by [Forward Email](https://forwardemail.net/?ref=nodemailer) &ndash; free email forwarding + custom domains + 100% open-source!
Send e-mails from Node.js easy as cake! 🍰✉️
[![NPM](https://nodei.co/npm/nodemailer.png?downloads=true&downloadRank=true&stars=true)](https://nodemailer.com/about/)

View File

@ -475,6 +475,7 @@ class MailComposer {
} else {
node = parentNode.createChild(element.contentType, {
filename: element.filename,
textEncoding: this.mail.textEncoding,
disableUrlAccess: this.mail.disableUrlAccess,
disableFileAccess: this.mail.disableFileAccess,
normalizeHeaderKey: this.mail.normalizeHeaderKey

View File

@ -451,7 +451,7 @@ class MimeNode {
transferEncoding = this._getTextEncoding(this.content) === 'Q' ? 'quoted-printable' : 'base64';
} else {
// we can not check content for a stream, so either use preferred encoding or fallback to QP
transferEncoding = this.transferEncoding === 'B' ? 'base64' : 'quoted-printable';
transferEncoding = this.textEncoding === 'B' ? 'base64' : 'quoted-printable';
}
} else if (!/^(multipart|message)\//i.test(contentType)) {
transferEncoding = transferEncoding || 'base64';

View File

@ -239,36 +239,64 @@ class SESTransport extends EventEmitter {
sesMessage[key] = mail.data.ses[key];
});
this.ses.sendRawEmail(sesMessage, (err, data) => {
if (err) {
this.logger.error(
{
err,
tnx: 'send'
},
'Send error for %s: %s',
messageId,
err.message
);
statObject.pending = false;
return callback(err);
let ses = (this.ses.aws ? this.ses.ses : this.ses) || {};
let aws = this.ses.aws || {};
let getRegion = cb => {
if (ses.config && typeof ses.config.region === 'function') {
// promise
return ses.config
.region()
.then(region => cb(null, region))
.catch(err => cb(err));
}
return cb(null, (ses.config && ses.config.region) || 'us-east-1');
};
getRegion((err, region) => {
if (err || !region) {
region = 'us-east-1';
}
let region = (this.ses.config && this.ses.config.region) || 'us-east-1';
if (region === 'us-east-1') {
region = 'email';
let sendPromise;
if (typeof ses.send === 'function' && aws.SendRawEmailCommand) {
// v3 API
sendPromise = ses.send(new aws.SendRawEmailCommand(sesMessage));
} else {
// v2 API
sendPromise = ses.sendRawEmail(sesMessage).promise();
}
statObject.pending = false;
callback(null, {
envelope: {
from: envelope.from,
to: envelope.to
},
messageId: '<' + data.MessageId + (!/@/.test(data.MessageId) ? '@' + region + '.amazonses.com' : '') + '>',
response: data.MessageId,
raw
});
sendPromise
.then(data => {
if (region === 'us-east-1') {
region = 'email';
}
statObject.pending = false;
callback(null, {
envelope: {
from: envelope.from,
to: envelope.to
},
messageId: '<' + data.MessageId + (!/@/.test(data.MessageId) ? '@' + region + '.amazonses.com' : '') + '>',
response: data.MessageId,
raw
});
})
.catch(err => {
this.logger.error(
{
err,
tnx: 'send'
},
'Send error for %s: %s',
messageId,
err.message
);
statObject.pending = false;
callback(err);
});
});
})
);

View File

@ -148,6 +148,12 @@
"secure": false
},
"OhMySMTP": {
"host": "smtp.ohmysmtp.com",
"port": 587,
"secure": false
},
"Postmark": {
"aliases": ["PostmarkApp"],
"host": "smtp.postmarkapp.com",

15
node_modules/nodemailer/package.json generated vendored
View File

@ -1,6 +1,6 @@
{
"name": "nodemailer",
"version": "6.4.17",
"version": "6.5.0",
"description": "Easy as cake e-mail sending from your Node.js applications",
"main": "lib/nodemailer.js",
"scripts": {
@ -20,10 +20,10 @@
},
"homepage": "https://nodemailer.com/",
"devDependencies": {
"bunyan": "1.8.14",
"chai": "4.2.0",
"bunyan": "1.8.15",
"chai": "4.3.0",
"eslint-config-nodemailer": "1.2.0",
"eslint-config-prettier": "7.0.0",
"eslint-config-prettier": "8.1.0",
"grunt": "1.3.0",
"grunt-cli": "1.3.2",
"grunt-eslint": "23.0.0",
@ -31,15 +31,14 @@
"libbase64": "1.2.1",
"libmime": "5.0.0",
"libqp": "1.1.0",
"mocha": "8.2.1",
"mocha": "8.3.0",
"nodemailer-ntlm-auth": "1.0.1",
"proxy": "1.0.2",
"proxy-test-server": "1.0.0",
"sinon": "9.2.1",
"sinon": "9.2.4",
"smtp-server": "3.8.0"
},
"engines": {
"node": ">=6.0.0"
},
"dependencies": {}
}
}

26
package-lock.json generated
View File

@ -8,15 +8,15 @@
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.2.6",
"@actions/core": "^1.2.7",
"nodemailer": "^6.4.17",
"showdown": "^1.9.1"
}
},
"node_modules/@actions/core": {
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
"integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA=="
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.7.tgz",
"integrity": "sha512-kzLFD5BgEvq6ubcxdgPbRKGD2Qrgya/5j+wh4LZzqT915I0V3rED+MvjH6NXghbvk1MXknpNNQ3uKjXSEN00Ig=="
},
"node_modules/ansi-regex": {
"version": "4.1.0",
@ -121,9 +121,9 @@
}
},
"node_modules/nodemailer": {
"version": "6.4.17",
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.4.17.tgz",
"integrity": "sha512-89ps+SBGpo0D4Bi5ZrxcrCiRFaMmkCt+gItMXQGzEtZVR3uAD3QAQIDoxTWnx3ky0Dwwy/dhFrQ+6NNGXpw/qQ==",
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.5.0.tgz",
"integrity": "sha512-Tm4RPrrIZbnqDKAvX+/4M+zovEReiKlEXWDzG4iwtpL9X34MJY+D5LnQPH/+eghe8DLlAVshHAJZAZWBGhkguw==",
"engines": {
"node": ">=6.0.0"
}
@ -275,9 +275,9 @@
},
"dependencies": {
"@actions/core": {
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
"integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA=="
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.7.tgz",
"integrity": "sha512-kzLFD5BgEvq6ubcxdgPbRKGD2Qrgya/5j+wh4LZzqT915I0V3rED+MvjH6NXghbvk1MXknpNNQ3uKjXSEN00Ig=="
},
"ansi-regex": {
"version": "4.1.0",
@ -358,9 +358,9 @@
}
},
"nodemailer": {
"version": "6.4.17",
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.4.17.tgz",
"integrity": "sha512-89ps+SBGpo0D4Bi5ZrxcrCiRFaMmkCt+gItMXQGzEtZVR3uAD3QAQIDoxTWnx3ky0Dwwy/dhFrQ+6NNGXpw/qQ=="
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.5.0.tgz",
"integrity": "sha512-Tm4RPrrIZbnqDKAvX+/4M+zovEReiKlEXWDzG4iwtpL9X34MJY+D5LnQPH/+eghe8DLlAVshHAJZAZWBGhkguw=="
},
"p-limit": {
"version": "2.3.0",

View File

@ -17,7 +17,7 @@
},
"homepage": "https://github.com/dawidd6/action-send-mail#readme",
"dependencies": {
"@actions/core": "^1.2.6",
"@actions/core": "^1.2.7",
"nodemailer": "^6.4.17",
"showdown": "^1.9.1"
}