【问题标题】:How to send a 'files array' containing an image with nodemailer?如何使用 nodemailer 发送包含图像的“文件数组”?
【发布时间】:2021-04-19 14:22:36
【问题描述】:

我按照本教程使用 axios 和 vue 上传图片:https://serversideup.net/uploading-files-vuejs-axios/

现在我得到了一个“密钥文件”,我可以使用开发工具screenshot dev tool在里面看到我的图像@

我想按照我在此处找到的解决方案使用 nodemailer 作为附件通过电子邮件发送此图像

 attachments: [
            {filename: "photo.jpg",
            contentType:  'image/jpeg',
            streamSource: fs.createReadStream(`${file}`.path)
            },
],

但我不能让它工作。希望有人给点建议?

【问题讨论】:

    标签: json vue.js email nodemailer


    【解决方案1】:

    我认为您缺少文件的路径

    attachments: [
                        {
                            filename: fileName,
                            path: yourPath
                        }
                    ]
    
     
    

    【讨论】:

    • 谢谢你,这是我从我遵循的 thz 教程中得到的:" 在服务器端,您可以通过 file 的 key 访问文件,它是 formData.append('file ', this.file); 方法。”现在我不知道如何在 Nodemailer 中添加附件
    猜你喜欢
    • 2017-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-05
    • 2012-10-05
    • 2022-11-14
    • 2017-12-06
    • 2018-05-21
    相关资源
    最近更新 更多