Mail being stupid

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Mail being stupid

Post by magicrobotmonkey »

I'm trying to do mime mail heres my headers

Code: Select all

<?php

$headers ="
From: Cml Admin <assessments@xxxxxx.com>
To: Aaron Bassett <abassett@xxxxxx.com>
Subject: Here is your stuff!
Date: Wed, 20 Jun 2001 20:18:47 -0400
MIME-Version: 1.0
Content-Type: text/plain
charset=iso-8859-1
Content-Transfer-Encoding: 7bit
Why??!";
?>
And here's the body of the message:
charset=iso-8859-1
Content-Transfer-Encoding: 7bit
Hello from Zend.com!

and here's the mail fxn:

Code: Select all

<?php
include "help.inc";

echo $headers;

 mail("abassett@cml-1885.com", "hip", " ",$headers);
?>
So why does that shtuff show up when it should be getting processed or whatever? Think its my server? I dont know how to test it Thanks
Last edited by magicrobotmonkey on Wed Mar 24, 2004 6:16 pm, edited 1 time in total.
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

Try adding to "\r\n" to the end of each headers. Concatenate the string using the dot notation. Something like this:

Code: Select all

$header = "From: Cml Admin <assessments@xxxxxx.com>\r\n"
                      . "To: Aaron Bassett <abassett@xxxxxx.com>\r\n"
                      . "Subject: Here is your stuff!\r\n"
                      . "Date: Wed, 20 Jun 2001 20:18:47 -0400\r\n"
                      . "MIME-Version: 1.0\r\n"
                      . "Content-Type: text/plain\r\n" 
                      . "charset=iso-8859-1\r\n"
                      . "Content-Transfer-Encoding: 7bit"
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

I have this:

Code: Select all

<?php

$headers =
"From: Cml Admind <assessments@xxxxxxxxxcom> \r\n"
."To: Aaron Bassett <abassett@xxxxxxxxx.com> \r\n"
."Subject: Here's your stuff \r\n"
."Date: Wed, 20 Jun 2001 20:18:47 -0400 \r\n"
."MIME-Version: 1.0 \r\n"
."Content-Type: text/plain; \r\n"
."charset=iso-8859-1 r\n"
."Content-Transfer-Encoding: 7bit \r\n"
."Hello from The Company!";

?>
And it still doesn't work. And when It echos to the webpage when I run it it shows it witout the line breaks. I tried changing them to just \n and htat didnt work either.
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

magicrobotmonkey wrote:

Code: Select all

<?php

$headers =
"From: Cml Admind <assessments@xxxxxxxxxcom> \r\n"
."To: Aaron Bassett <abassett@xxxxxxxxx.com> \r\n"
."Subject: Here's your stuff \r\n"
."Date: Wed, 20 Jun 2001 20:18:47 -0400 \r\n"
."MIME-Version: 1.0 \r\n"
."Content-Type: text/plain; \r\n"
."charset=iso-8859-1 r\n"
."Content-Transfer-Encoding: 7bit \r\n"
."Hello from The Company!";

?>
I notice two things. First the whitespace just before each "\r\n" this could be a problem. Second "Hello from The Company" isn't a header looks like the massage and doesn't belong there.
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

Yea but thats where the body goes in mime! Anyways, I eventually got it working with a little script I found in the online docs. But now im trying to send a pdf file. Can anyone point me towards and info about sending pdf through mime? thanks
TheBentinel.com
Forum Contributor
Posts: 282
Joined: Wed Mar 10, 2004 1:52 pm
Location: Columbus, Ohio

Post by TheBentinel.com »

Yeah, toss in another \r\n after your headers:

Code: Select all

<?php

$headers =
"From: Cml Admind <assessments@xxxxxxxxxcom> \r\n"
."To: Aaron Bassett <abassett@xxxxxxxxx.com> \r\n"
."Subject: Here's your stuff \r\n"
."Date: Wed, 20 Jun 2001 20:18:47 -0400 \r\n"
."MIME-Version: 1.0 \r\n"
."Content-Type: text/plain; \r\n"
."charset=iso-8859-1 r\n"
."Content-Transfer-Encoding: 7bit \r\n"
."\r\n"
."Hello from The Company!";

?>
Give that a whirl.
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

oh i see what you mean
Post Reply