FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Re: problem sending attachement with the mail() function
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: problem sending attachement with the mail() function [message #178985] Fri, 31 August 2012 19:33 Go to previous message
Eli the Bearded is currently offline  Eli the Bearded
Messages: 22
Registered: April 2011
Karma:
Junior Member
In comp.lang.php, anomit <anomit(dot)ghosh(at)gmail(dot)com> wrote:
> I'm going wrong with the message boundaries but some help would be
> appreciated
>
> $random_hash = md5(date('r', time()));
> $subject = "your free pdf is here";
> $headers = "From: no-reply(at)my-domain(dot)com\r\nReply-To: no-
> reply(at)my-domain(dot)com";
> $headers .= "\r\nContent-type: multipart/mixed; boundary=
> \"mailer-boundary-".$random_hash."\"";

^ ^

Note use of double quotes. Very important. MIME, unlike HTML, does not
allow you to switch between single and double quotes in headers.
You are also missing the required "MIME-Version: 1.0" header.


> $attachment =
> chunk_split(base64_encode(file_get_contents('file.pdf')));
> //the body of the message with the message boundaries and
> attachment as multipart mime
> $output = "
> --mailer-boundary-$random_hash
> Content-Type: multipart/alternative; boundary='mailer-alt-
> $random_hash'

Here you not using double quotes, you are using single quotes.

> Content-Type: text/plain; charset='iso-8859-1'

And again. Also it looks like you are missing the blank line between
the multipart/mixed section's headers and the enclosed
multipart/alternative boundary.

MIME is complicated, different from HTML, and flexible in different
ways than HTML. Unless you know those details, and have a good reason
to roll your own, you are probably better off using a pre-built library.

Elijah
------
has written MIME parsers
[Message index]
 
Read Message
Read Message
Previous Topic: Stats comp.lang.php (last 7 days)
Next Topic: Is PDO an abstraction layer?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 29 03:43:43 GMT 2024

Total time taken to generate the page: 0.04745 seconds