Vignesh Ravi
Vignesh Ravi

Reputation: 23

how to send email using attachments in nodejs?

This program works perfectly, but attachments files are not sent. Can anyone give me the correct solution?. Thanks in advance.

var nodemailer = require('nodemailer');
var fs=require("fs");
var smtpTransport = require('nodemailer-smtp-transport');
var transporter = nodemailer.createTransport(smtpTransport({
    service: 'Gmail',
    host: 'smtp.gmail.com',
    port: 465,
    auth: {
        user: '[email protected]',
        pass: 'xvbthhegebeb.'
    }
}));

    transporter.sendMail({
        from: "[email protected]",
        subject:" hello ji " ,
        text: "I would like to write dialogue",
        Attachments:[
            {
                'filename':'link.txt',
                'path': 'E:/STUDIES/CORE SUBJECTS/link.txt'
            }
        ],
        to: "[email protected]"
    }, function(error, info) {
        if (error) {
            return console.log(error);
        }
        console.log('Message %s sent: %s', info.messageId, info.response);
        console.log("Mail sent successfully");
    });

Upvotes: 0

Views: 1965

Answers (1)

Noel Llevares
Noel Llevares

Reputation: 16087

attachments should be lowercased. You're using Attachments.

Reference: https://nodemailer.com/message/attachments/

Upvotes: 1

Related Questions