-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Example setup for GreenMail and nodemailer
Test setup for reproducing #380
- Loading branch information
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM node:lts-alpine | ||
|
||
ENV NODE_ENV=production \ | ||
NPM_CONFIG_PRODUCTION=true | ||
|
||
WORKDIR /nodemailer | ||
RUN addgroup nodemailer && \ | ||
adduser -S nodemailer nodemailer && \ | ||
chown -R nodemailer:nodemailer /nodemailer | ||
USER nodemailer:nodemailer | ||
COPY --chown=nodemailer server.js /nodemailer/server.js | ||
RUN npm install --save nodemailer | ||
|
||
ENTRYPOINT [ "node","/nodemailer/server.js" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
GreenMail test setup with nodemailer | ||
========= | ||
|
||
This is a POC showing a GreenMail and [nodemailer](https://github.com/nodemailer/nodemailer) setup, configuring nodemailer to send a single message to GreenMail. | ||
|
||
Run `docker-compose up --build` and use eg Thunderbird to verify | ||
|
||
|Port|Description| | ||
|----|-----------| | ||
|3025| GreenMail SMTP | | ||
|3143| GreenMail IMAP | | ||
|8080| GreenMail API | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
version: '3' | ||
services: | ||
greenmail: | ||
image: greenmail/standalone:1.6.3 | ||
environment: | ||
# Enable GreenMail verbose mode | ||
- GREENMAIL_OPTS=-Dgreenmail.setup.test.smtp -Dgreenmail.setup.test.imap -Dgreenmail.setup.api -Dgreenmail.hostname=0.0.0.0 -Dgreenmail.auth.disabled -Dgreenmail.verbose | ||
ports: | ||
- "3025:3025" | ||
- "3143:3143" | ||
- "8080:8080" | ||
nodemailer: | ||
build: | ||
context: . | ||
links: | ||
- greenmail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// From https://nodemailer.com/about/#example | ||
|
||
"use strict"; | ||
const nodemailer = require("nodemailer"); | ||
|
||
// async..await is not allowed in global scope, must use a wrapper | ||
async function main() { | ||
// create reusable transporter object using the default SMTP transport | ||
let transporter = nodemailer.createTransport({ | ||
host: "greenmail", | ||
port: 3025, | ||
secure: false, | ||
//auth: { | ||
// user: 'foo', | ||
// pass: 'bar', | ||
//}, | ||
debug: true, | ||
logger: true, | ||
}); | ||
|
||
// send mail with defined transport object | ||
let info = await transporter.sendMail({ | ||
from: '"Fred Foo 👻" <[email protected]>', // sender address | ||
to: "[email protected], [email protected]", // list of receivers | ||
subject: "Hello ✔", // Subject line | ||
text: "Hello world?", // plain text body | ||
html: "<b>Hello world?</b>", // html body | ||
}); | ||
|
||
console.log("Message sent: %s", info.messageId); | ||
} | ||
|
||
main().catch(console.error); | ||
|