PHP Code for Email with Attachments
Posted: Fri May 26, 2006 11:01 am
How does one code emails with attachment? I once viewed a code for this but it got really confusing for me. Please help.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
Subject: Your subject
To: "Someone" <someone@address.com>
From: "You" <your@name.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: multipart/mixed;
boundary="some_randrom_string"Code: Select all
--some_random_string
Content-Type: text/html
Content-Transfer-Encoding: 7bit
<strong>This is a HTML email all rather annoyingly in bold!</strong>Code: Select all
base64_encode(file_get_contents($filename));Code: Select all
--some_random_string
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
Content-Dispostion: attachment;
filename="Your filename.jpg"
Content-Description: Your filename.jpg
<base 64 encoded data here>Code: Select all
Subject: Your subject
To: "Someone" <someone@address.com>
From: "You" <your@name.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: multipart/mixed;
boundary="some_randrom_string"
--some_random_string
Content-Type: text/html
Content-Transfer-Encoding: 7bit
<strong>This is a HTML email all rather annoyingly in bold!</strong>
--some_random_string
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
Content-Dispostion: attachment;
filename="Your filename.jpg"
Content-Description: Your filename.jpg
<base 64 encoded data here>
--some_random_string--