Sendmail Transport pipes the generated RFC822 message to the standard input of the sendmail
command, so it’s the same thing what the mail()
command in PHP does.
To use Sendmail Transport, set sendmail
option to true
in Nodemailer options.
The additional options to use with this transport are the following:
sendmail
command (defaults to 'sendmail'
)<CR><LF>
or Unix syntax <LF>
sendmail
command (ie. ["-f", "foo@blurdybloop.com"]
). This overrides all default arguments except for ‘-i’ and recipient list so you need to make sure you have all required arguments set (ie. the ‘-f’ flag).The command to be spawned by default looks like this:
sendmail -i -f from_addr to_addr[]
If args
property was provided then the command looks like this:
sendmail -i args[] to_addr[]
The info
argument for sendMail()
method includes the following properties:
{from:'address', to:['address']}
let transporter = nodemailer.createTransport({
sendmail: true,
newline: 'unix',
path: '/usr/sbin/sendmail'
});
transporter.sendMail({
from: 'sender@example.com',
to: 'recipient@example.com',
subject: 'Message',
text: 'I hope this message gets delivered!'
}, (err, info)=>{
console.log(info.envelope);
console.log(info.messageId);
});