简体   繁体   English

无法使用 smtpjs 将 PDF 文件附加到 JavaScript 中的 Email

[英]Can’t Attach PDF File to Email in JavaScript Using smtpjs

  1. Summarize the problem总结问题

I am unable to attach a PDF file to an email to be sent to an email address.我无法将 PDF 文件附加到 email 以发送到 email 地址。 The PDF file is in the same folder as the HTML file, which contains the JavaScript code to send the email using SMTPJS. PDF 文件与 HTML 文件位于同一文件夹中,该文件包含 JavaScript 代码,用于使用 SMTPAB2371CEB2CBA 发送 Z0C83ZF57C783ACEBCBA。

Expected result: An email is sent to the designated email address with the pdf file without any problems.预期结果:email 被发送到指定的 email 地址与 pdf 文件没有任何问题。

Actual result: No email was sent at all.实际结果:根本没有发送 email。

  1. Describe what you've tried描述你尝试过的东西

#1: Attempt by putting file name and extension in quotes like this: #1:尝试将文件名和扩展名放在引号中,如下所示:

PFD_Articles.pdf -> 'PFD_Articles.pdf' PFD_Articles.pdf -> 'PFD_Articles.pdf'

Again, the actual result is produced, not the expected one.同样,产生的是实际结果,而不是预期的结果。

  1. Show some code显示一些代码
Email.send
(
    {
        Host: "smtp.gmail.com",
        Username: "sender@gmail.com",
        Password: "password",
        To: 'receiver@gmail.com',
        From: "sender@gmail.com",
        Subject: "<h1> ddd </h1>",
        Body: "And this is the body",
        Attachments:
            [
                {
                    name: 'PFD_Articles.pdf'
                }
            ]
    }).then
(
    alert("Successful! Please check your email inbox. Otherwise, you may have to enter your email address again.")
);

 Email.send({ Host: "smtp.gmail.com", Username: "abc@gmail.com", Password: "abc", To: receiver, From: "abc@gmail.com", Subject: emailSubject, Body: emailBody, Attachments: [ { name: list.pdf data: pdfBase64 }] }).then( ) });

This worked !这行得通! The created pdf got added to the email as an attachment创建的 pdf 作为附件添加到 email

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM