Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Pls I wish to know the following about. PHP;
How are attachments sent with php.

How are html emails sent in php.
Posted

Two major methods are:

Very basic: http://www.w3schools.com/php/func_mail_mail.asp[^]

With multiple interfaces, based on the PEAR repositiory:
http://pear.php.net/package/Mail[^],
http://pear.php.net/manual/en/package.mail.mail.php[^],
http://en.wikipedia.org/wiki/PEAR[^],
http://pear.php.net/[^].

For adding "attachments", especially if you have to work on the lower level, it's important to understand that nothing is really "attached", everything is embedded in one text block of a multipart mail content, which is subdivided into "parts" each having its separate MIME content type; parts not suitable for text presentations are usually encoded in base64:
http://en.wikipedia.org/wiki/E-mail_attachment[^],
http://en.wikipedia.org/wiki/Base64[^].

This is how base64 can be used in PHP: http://php.net/manual/en/function.base64-encode.php[^].

Now, a big warning for you: sending mails out from the user data on a Web page is one of the most "popular" security holes. If such input is not properly sanitized, it is easy to turn your Web server's host into a zombie sending spam or something like that. Please see my past answer:
unable to send mail , it showing the error in below code .[^].

—SA
 
Share this answer
 
v2
Comments
Maciej Los 24-Nov-13 16:39pm    
5ed!
Sergey Alexandrovich Kryukov 24-Nov-13 17:21pm    
Thank you, Maciej.
—SA
See various solutions here[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 24-Nov-13 14:49pm    
Maybe it's fair enough, maybe not quite, hard to say. (I voted 4 this time.)
I think the problem needs a bit more of explanation, especially due to considerable vulnerability involved.
Please see my answer.
—SA
CHill60 24-Nov-13 15:13pm    
Fair comment ... I was a bit harsh ... probably because I'd seen so many "no attempt to do any research" questions today ... you'll be getting my 5
Sergey Alexandrovich Kryukov 24-Nov-13 15:49pm    
Thank you. I don't think it's harsh, it's just needed a little bit more attention. You are right that too many questions are unproductive, counter-productive or pointless...
—SA
Maciej Los 24-Nov-13 16:39pm    
+5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900