Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
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. The PDF file is in the same folder as the HTML file, which contains the JavaScript code to send the email using SMTPJS.

Expected result: An email is sent to the designated email address with the pdf file without any problems.

Actual result: No email was sent at all.

  1. Describe what you’ve tried

#1: Attempt by putting file name and extension in quotes like this:

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.")
);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

     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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!