私はzipファイルを添付します。添付ファイルは動作しません。nodemailerの添付ファイルが動作していません
ここは私のソースコードです。
var express = require('express');
var router = express.Router();
var nodemailer = require('nodemailer');
var fs = require('fs');
var mailinfo = require('../config/mail_info').info;
var smtpTransport = nodemailer.createTransport({
host: mailinfo.host,
port: mailinfo.port,
auth: mailinfo.auth,
tls: mailinfo.tls,
debug: true,
});
router.post('/',function(req,res){
var emailsendee = req.body.emailAddress;
console.log(emailsendee);
var emailsubject = "Requested File";
var emailText = "test";
var emailFrom = '[email protected]';
var mailOptions={
from : "test <[email protected]>",
to : emailsendee,
subject : emailsubject,
html : '<h1>' + emailText+ '</h1>';
attachments : [
{
filename : '',//i just put black make you understand esaily
path : ''//what i did is under this code
}
]
};
console.log(mailOptions);
smtpTransport.sendMail(mailOptions, function(error, response){
if(error){
console.log(error);
res.end();
}else{
console.log(response);
res.end();
}
});
});
module.exports = router;
私はそれがまだ添付せずにメールを送信したファイル
enter code here
attachments:[{ fileName: 'test.log', streamSource: fs.createReadStream('./test.log'}]
を取り付けるためにこれらを試してみました。 このコードがファイルを読み取れない場合、エラーが発生します。 これは、ファイルを読むために動作していないと思います。 と私は私と同様のエラーを持っているstackoverflowでいくつかの質問を読んでください。
i固定パス - >ファイルパス 固定ストリームソース - >パス 私のnodemailerバージョンは4.0.1です。 私はzipファイルでメールを送信するのに役立ちます。