代码之家  ›  专栏  ›  技术社区  ›  lawrence999

AWS-SES发送带有附件的邮件[应用程序/pdf]节点[副本]

  •  6
  • lawrence999  · 技术社区  · 7 年前

    我有多个。pdf附件,我想将附件作为对象数组传递给 发送电子邮件 作用我阅读了AWS文件,没有关于附件的信息。


       let attachment_data = [];
        attachment_data.push({
            filename: 'ticket.pdf',
            path:'/sample/tickets/ticket.pdf',
            content: new Buffer(fs.readFileSync('/sample/tickets/ticket.pdf')).toString('base64'),
            contentType: 'application/pdf',
        });
    
    
    -----------------------------------------------------------------------
    
    
    
        function SendMail(options, template, cb) {
            for (var key in options) {
                template = template.replace('{{%' + key + '%}}', options[key]);
            }
            client.sendEmail({
                from: constants.EMAIL_FROM,
                to: options.email,
                subject: options.subject,
                message: template,    //html content
                attachments: (options.attachment)?options.attachment:null  //array of objects
            }, function(err, data, res) {
                if(err) cb(err, null);
                else cb(null,res)
           });
        }
    
    ------------------------------------------------------------------------
    am receiving email but without attachment and I looked all over the documentation and all but all I could find is this statement below which is relevant.
    
     - **The total size of the message, including attachments, must be smaller
       than 10 MB.**
    
    am using the below package [node-ses][1]
    
        var ses = require('node-ses'),
        client = ses.createClient({
            key: process.env.AWS_ACCESSKEY_ID,
            secret: process.env.AWS_SECRET_ACCESSKEY,
            amazon: process.env.SES_REGION
        });
    
    3 回复  |  直到 7 年前
        1
  •  3
  •   tile    7 年前

    易于使用此 https://nodemailer.com/transports

    SES在我看到url后花了我3个小时

        2
  •  0
  •   Sai Kishore    6 年前

    AWS SES提供了配置和发送电子邮件的有效方法。请参考以下帖子。这对我有用。 How can send PDF attachment in `Node aws-sdk` sendRawEmail function?

        3
  •  -1
  •   lawrence999    7 年前