Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8488743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:37:52+00:00 2026-06-10T21:37:52+00:00

I need to send a pdf with mail, is it possible? $to = xxx;

  • 0

I need to send a pdf with mail, is it possible?

$to = "xxx";
$subject = "Subject" ;
$message = 'Example message with <b>html</b>';
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: xxx <xxx>' . "\r\n";
mail($to,$subject,$message,$headers);

What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:37:54+00:00Added an answer on June 10, 2026 at 9:37 pm

    I agree with @MihaiIorga in the comments – use the PHPMailer script. You sound like you’re rejecting it because you want the easier option. Trust me, PHPMailer is the easier option by a very large margin compared to trying to do it yourself with PHP’s built-in mail() function. PHP’s mail() function really isn’t very good.

    To use PHPMailer:

    • Download the PHPMailer script from here: http://github.com/PHPMailer/PHPMailer
    • Extract the archive and copy the script’s folder to a convenient place in your project.
    • Include the main script file — require_once('path/to/file/class.phpmailer.php');

    Now, sending emails with attachments goes from being insanely difficult to incredibly easy:

    use PHPMailer\PHPMailer\PHPMailer;
    use PHPMailer\PHPMailer\Exception;
    
    $email = new PHPMailer();
    $email->SetFrom('you@example.com', 'Your Name'); //Name is optional
    $email->Subject   = 'Message Subject';
    $email->Body      = $bodytext;
    $email->AddAddress( 'destinationaddress@example.com' );
    
    $file_to_attach = 'PATH_OF_YOUR_FILE_HERE';
    
    $email->AddAttachment( $file_to_attach , 'NameOfFile.pdf' );
    
    return $email->Send();
    

    It’s just that one line $email->AddAttachment(); — you couldn’t ask for any easier.

    If you do it with PHP’s mail() function, you’ll be writing stacks of code, and you’ll probably have lots of really difficult to find bugs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using cake php 2.0 version, I need to send a PDF attached
I need to send an HTML report with images from an application. The report
I need to send some information on a VxWorks message queue. The information to
We've setup some different load tests and need to generate/send the result pr. e-mail,
I have a pdf file on disk that i need to send to a
I need to be able to send out a UDP message and also receive
i'm using dompdf library to render some html content into pdf files. I actually
I need to send a PDF file using JavaMail. The PDF is currently a
HI all I need to send an dynamically generated html to server using html
Is it possible to create a .pdf file extension when using tempname? I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.