Php – Compiling email with multiple attachments in PHP

attachmentemailPHP

I need to send out an email with multiple image attachments from PHP. I currently have a test set up that uses two hard coded images. I compile the email with al the necessary headers and send it out. However, when I receive it, it only shows the first image as an attachment. The second image seems to be ignored (tested with both Groupwise and Gmail).

When I view the source of my email the following is what I see after the by the server generated headers. Apparently both attachments (images) are in there but only the first one is showing up as an attachment.

Any help would be greatly appreciated.

This is a multi-part message in MIME format.

--==Multipart_Boundary_x38e1b83d34375e183a2fdcd6a9c001f8x
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

my message text

--==Multipart_Boundary_x38e1b83d34375e183a2fdcd6a9c001f8x
Content-Type: image/gif;
 name="image1.gif"
Content-Disposition: attachment;
 filename="image1.gif"
Content-Transfer-Encoding: base64

iVBORw0KGgoAAAANSUhEUgAAABEAAAAMCAIAAAALR8HoAAABgElEQVQoFZWQzSuEURTG7z3n3Pt+

*[-- snip --]*

SaHPETExQ6HQ0BB4Z8FwTr/KHVc/AJ98jIf2BGdKAAAAAElFTkSuQmCC

--==Multipart_Boundary_x38e1b83d34375e183a2fdcd6a9c001f8x--

--==Multipart_Boundary_x38e1b83d34375e183a2fdcd6a9c001f8x
Content-Type: image/gif;
 name="image2.gif"
Content-Disposition: attachment;
 filename="image2.gif"
Content-Transfer-Encoding: base64

iVBORw0KGgoAAAANSUhEUgAAAKMAAAAyCAIAAAC/NPwxAAAAA3NCSVQICAjb4U/gAAAACXBIWXMA

*[-- snip --]*

yh4+kv39P/vticlfC0Muodov+5posktKGGb7/2pscsAoKykp2W8fTH4Exv1tEEbD3NNGwbi/y8do
mNnbKPwf2Oju7uv54J4AAAAASUVORK5CYII=

--==Multipart_Boundary_x38e1b83d34375e183a2fdcd6a9c001f8x--

Best Answer

Going from memory:

SaHPETExQ6HQ0BB4Z8FwTr/KHVc/AJ98jIf2BGdKAAAAAElFTkSuQmCC

--==Multipart_Boundary_x38e1b83d34375e183a2fdcd6a9c001f8x--
^^^ DELETE THIS LINE ^^^

--==Multipart_Boundary_x38e1b83d34375e183a2fdcd6a9c001f8x

You shouldn't have two boundaries next to each other, and the "--" at the end is only for the end of the last part.

Related Topic