Write e-mails to Firebase database and let them get sent with Nodemailer
This tiny daemon script monitors a configurable firebase path for emails and passes them to Nodemailer to let them get sent over SMTP or another Nodemailer transporter.
The quickest way to get this up and running as the docker-compose already contains Docker-SMTP.
git clone [email protected]:copitz/firemailer.git
cd firemailer
docker-compose up
docker run -v config.js:/opt/app/config.js copitz/firemailer
git clone [email protected]:copitz/firemailer.git
cd firemailer
cp config.example.js config.js
npm install
node app.js
- Copy config.example.js to config.js
- Set the correct Firebase URL
- Set your transport options as for nodemailer.createTransport()
Just push an Nodemailer email object to the configured path.
Assuming you set config.firebase.path
to "mails"
and the firemailer daemon is running, sending an email via firebase is as easy as:
Firebase.database().ref('mails').push({
to: '[email protected]',
from: '"Christian Opitz" <[email protected]>',
subject: 'Hello world',
text: 'Lorem ipsum dolor sit amet'
});