"Content-Type" 在 JavaScript 中显示意外标记
"Content-Type" shows Unexpected token in JavaScript
我正在使用 SMTP 从我的 ReactJS 应用程序发送 ZIP 文件。
我可以将 PNG 图像作为附件发送,而无需将任何 "Content-Type" 指定为 SMTP 属性.
但是当我添加 Content-Type : "application/octet-stream"
用于发送 zip 文件时,它显示 Unexpected token at "-".
我应该用什么替换它来发送 zip 文件?
这是我的 SMTP 连接代码;
sendEmail = (url, filename)=> {
Email.send({
Host: "smtp.gmail.com",
Content-Type : "application/octet-stream",
Username : "xxxxx@gmail.com",
Password : "xxxxxxxxxxxxxx",
To : 'xxxxxxx@gmail.com',
From : "xxxxx@gmail.com",
Subject : "Your file is ready! ",
Body : "Body of the Email",
Attachments : [
{
name : filename,
path : url
}]
}).then(
message => alert("Mail Sent")
);
}
这是它呈现的内容;
Image of the output
尝试将 Content-Type 替换为 "Content-Type"。像这样
Email.send({
Host: "smtp.gmail.com",
"Content-Type" : "application/octet-stream",
Username : "xxxxx@gmail.com",
Password : "xxxxxxxxxxxxxx",
To : 'xxxxxxx@gmail.com',
From : "xxxxx@gmail.com",
Subject : "Your file is ready! ",
Body : "Body of the Email",
我正在使用 SMTP 从我的 ReactJS 应用程序发送 ZIP 文件。 我可以将 PNG 图像作为附件发送,而无需将任何 "Content-Type" 指定为 SMTP 属性.
但是当我添加 Content-Type : "application/octet-stream"
用于发送 zip 文件时,它显示 Unexpected token at "-".
我应该用什么替换它来发送 zip 文件?
这是我的 SMTP 连接代码;
sendEmail = (url, filename)=> {
Email.send({
Host: "smtp.gmail.com",
Content-Type : "application/octet-stream",
Username : "xxxxx@gmail.com",
Password : "xxxxxxxxxxxxxx",
To : 'xxxxxxx@gmail.com',
From : "xxxxx@gmail.com",
Subject : "Your file is ready! ",
Body : "Body of the Email",
Attachments : [
{
name : filename,
path : url
}]
}).then(
message => alert("Mail Sent")
);
}
这是它呈现的内容;
Image of the output
尝试将 Content-Type 替换为 "Content-Type"。像这样
Email.send({
Host: "smtp.gmail.com",
"Content-Type" : "application/octet-stream",
Username : "xxxxx@gmail.com",
Password : "xxxxxxxxxxxxxx",
To : 'xxxxxxx@gmail.com',
From : "xxxxx@gmail.com",
Subject : "Your file is ready! ",
Body : "Body of the Email",