Currently I am able to send emails in node.js using code along the lines of:
var nodemailer = require("nodemailer");
var smtpTransport = nodemailer.createTransport("SMTP",{
service: "Gmail",
auth: {
user: "gmail.user@gmail.com",
pass: "gmailpass"
}
});
smtpTransport.sendMail({
from: "My Name <me@example.com>", // sender address
to: "Your Name <you@example.com>", // comma separated list of receivers
subject: "Hello ✔", // Subject line
text: "Hello world ✔" // plaintext body
}, function(error, response){
if(error){
console.log(error);
}else{
console.log("Message sent: " + response.message);
}
});
How can I send an attachment of an uploaded image from an html form in this email? Also, can I send the image in the email without uploading it to the serve? If not, that's okay. This is my html form:
<form id="mainForm">
<input type="file" id="fileUpload">
<input type="submit" id="submit" name="submit">
</form>
How can I take the file and include it in the email I send using node.js?