Send Email with Attachment in PHP, Send Attachment in Email in PHP

Send Email Attachment in PHP


Hello friends today i am going to provide a tutorial regarding how to send email attachment in PHP. For a normal mail sending you can visit my previous article in which you will learn how to send mail in php how to send email in php In this tutorial you will get the whole code and its really a very short code to send the attachment. Sending an email attachment in php is not an easy task many time you will get the errors like file is of 0 kb, file name is something else, email is delivered but no you dont get the mail etc. In this tutorial / Example you will get he procedure of how to send the email attachment in php.

Demo Link

Things we need to send email attachment in php

  • HTML Form
  • PHP Code

Email sending HTML Form

First we will start with the html for. In html form we will use the these text fields

  • To – On which mail is delivered
  • Message – Message which is to be delivered
  • Subject – Subject for the Email
  • Attachment – Email attachment which you want to send

Below is the HTML code for email sending

Now we have finished with our html form. Lets move to our PHP code

Email attachment php code

Here will write the PHP code for the attachment sending with the help of php.


First we will receive our data and retain that data below is the code

Now we will send the email with attachment in php

From the above demo you can check this or click the below link to check it on separate page. Below is the working code you can download it also.

EAttachment
EAttachment
emailAttachment.rar
1.1 KiB
3614 Downloads
Details...

14 Comments

  1. I actually have the same problem with the other commenters, I used your code but there was no mail.

  2. bhuvaneswari.s

    November 5, 2015 at 08:19

    haaii,.. its not working.. i got a success mail message.. bt i could not get any mail.

  3. Hi, Vivek.. i’m also using this code. mail sent message displayed , but i dont have received any other mail and attachements. pls help me.. thanks in advance…

  4. vivek sir thanx for provide the code……………………….
    but i a have problem …
    the file attach properly but it size 0 bite…….
    plz help me…………. i m wait your replay

  5. Thank you so much for this tutorial.
    I have use your code, it sent attachments successfully, but there message body is empty.
    Can you please help me for this problem.
    I am testing it on Linux hosting.
    Please help me for this.
    Thanks in advance.

  6. thanks bro…. thank you very much…. your are the best

  7. Hi Vivek Sir,

    i

  8. Your The Best Dude..ThankYou

  9. ehen i run you demo http://vivekmoyal.in/testing/emailAttachment.php it works .. even i got email with attachment .. but when i apply this code in my file .. no mail .. 🙁

Leave a Reply

Your email address will not be published.

*

Shares