Using this together with email-templates
cfmdmedia opened this issue · comments
Hi,
is there a way to use this library together with https://github.com/forwardemail/email-templates?
Because I want to send pre-designed HTML Emails generated with dynamic parameters by Pug.
The sendMail
function in your code only accepts parameters for building the HTML Email there.
Also I want to separate Server & Client in two separated Docker containers.Do I have to pay special attention to anything?
Do you have a real example of use for this library?
Thanks a lot!
Hello @cfmdmedia ,
Yes, only if you wish to render emails using email-templates
, and then send using mail-time
.
Let me know if you need more details
Also I want to separate Server & Client in two separated Docker containers.
This is exactly the case for this library
Do I have to pay special attention to anything?
Just make sure they are using same MongoDB, and client is set as {type: 'client'}
, same for server. Let me know if you have more questions
Do you have a real example of use for this library?
Using it for years since it's first release. There's evidence other folks using it too.
Issues were pretty active at the some point, now it's in a stable state
Thanks for the quick answer.
email-templates
can return a string with the HTML, but I'm not sure what to pass as a template
in the sendMail
function, because the string contains a complete HTML page. Should I just pass {{{html}}}
then?
Is the mail queue actually stored in a separate collection in MongoDB or does it influence existing collections?
Thank you again.
email-templates can return a string with the HTML
Just use returned HTML string as { html }
option (no template needed):
const mailQueue = new MailTime({
db, // MongoDB
type: 'server', // server or client
transports, // your SMTP and/or direct transports
from(transport) {
// To pass spam-filters `from` field should be correctly set
// for each transport, check `transport` object for more options
return '"Awesome App" <' + transport.options.from + '>';
}
});
// as simple as:
mailQueue.sendMail({
to: 'user@gmail.com',
subject,
html: htmlGeneratedByEmailTemplate // <-- here
});
Is the mail queue actually stored in a separate collection in MongoDB or does it influence existing collections?
Yes, separate collection. See this line of code.
Thanks again for the quick help!
@cfmdmedia I'm glad this was quickly solved
Please support this project with:
- Star this package on GitHub;
- Like at Facebook;
- Follow on Twitter;
- Support via patreon;
- Support via PayPal;
- Check and star our other open source projects on GitHub.