Put link in message body sent with Mailgun?
Solution 1:
Looking at the documentation for mailgun-js
it says:
Sending messages in MIME format can be accomplished using the sendMime() function of the messages() proxy object.
https://www.npmjs.com/package/mailgun-js#sending-mime-messages
The documentation then provides this code example:
var domain = 'mydomain.org';
var mailgun = require('mailgun-js')({ apiKey: "YOUR API KEY", domain: domain });
var MailComposer = require('nodemailer/lib/mail-composer');
var mailOptions = {
from: '[email protected]',
to: '[email protected]',
subject: 'Test email subject',
text: 'Test email text',
html: '<b> Test email text </b>'
};
var mail = new MailComposer(mailOptions);
mail.compile().build((err, message) => {
var dataToSend = {
to: '[email protected]',
message: message.toString('ascii')
};
mailgun.messages().sendMime(dataToSend, (sendError, body) => {
if (sendError) {
console.log(sendError);
return;
}
});
});
At the time of sharing this, the current version is 0.20.0
.
As the code demonstrates, with a multi-part message you will need to provide both a plain text and HTML version of the message.