“ Content-Type”在JavaScript中显示了意外的标记

问题描述 投票:1回答:1

我正在使用SMTP从我的ReactJS应用程序发送ZIP文件。我可以将PNG图片作为附件发送,而无需将任何“ Content-Type”指定为SMTP属性。

但是当我添加了Content-Type : "application/octet-stream"来发送zip文件时,它显示了[[位于“-”处的意外令牌。

我应该用什么替换它以发送zip文件?

这是我的SMTP连接代码;

sendEmail = (url, filename)=> { Email.send({ Host: "smtp.gmail.com", Content-Type : "application/octet-stream", Username : "[email protected]", Password : "xxxxxxxxxxxxxx", To : '[email protected]', From : "[email protected]", Subject : "Your file is ready! ", Body : "Body of the Email", Attachments : [ { name : filename, path : url }] }).then( message => alert("Mail Sent") ); }

这就是它呈现的内容;Image of the output
reactjs smtp zip attachment content-type
1个回答
0
投票
尝试将Content-Type替换为“ Content-Type”。像这样

Email.send({ Host: "smtp.gmail.com", "Content-Type" : "application/octet-stream", Username : "[email protected]", Password : "xxxxxxxxxxxxxx", To : '[email protected]', From : "[email protected]", Subject : "Your file is ready! ", Body : "Body of the Email",

© www.soinside.com 2019 - 2024. All rights reserved.