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
Switch to threaded view of this topic Create a new topic Submit Reply
Re: problem sending attachement with the mail() function [message #178985] Fri, 31 August 2012 19:33 Go to next message
Eli the Bearded is currently offline  Eli the Bearded
Messages: 22
Registered: April 2011
Karma: 0
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
Re: problem sending attachement with the mail() function [message #178986 is a reply to message #178985] Fri, 31 August 2012 19:56 Go to previous message
anomit.ghosh is currently offline  anomit.ghosh
Messages: 1
Registered: August 2012
Karma: 0
Junior Member
On Saturday, 1 September 2012 01:03:15 UTC+5:30, Eli the Bearded wrote:

>
> 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

Yeah, you are right and taking Jerry's advice, I started using PHPMailer. Certainly makes life easier. Thanks for all the help, guys.
  Switch to threaded view of this topic Create a new topic Submit Reply
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: Sun Nov 10 16:21:51 GMT 2024

Total time taken to generate the page: 0.03074 seconds