Reply to Re: Problem with headers using mail() function

Your name:

Reply:


Posted by Spartacus on 06/13/07 16:07

ZeldorBlat wrote:
> On Jun 13, 7:06 am, Spartacus <nos...@nowhere.com> wrote:
>> Hello,
>>
>> I know there is lots of information out there and I've taken a look, but
>> I want to learn how to do this myself. And I'm a beginner here and some
>> of it I don't understand (so no flames, RTFM or GFGI please ;)
>>
>> Here's my function:
>>
>> function send_mail($to_name, $to_email, $from_name, $from_email,
>> $subject, $message)
>> {
>> $thedate = date("r", time());
>>
>> $headers = "X-Mailer: PHPMailProgram/1.0\n";
>> $headers .= "From: \"".$from_name."\" <".$from_email.">\n";
>> $headers .= "Date: $thedate\n";
>> $headers .= "Content-Type: text/plain\n\n";
>>
>> $from = "\".$from_name."\" <".$from_email.">";
>>
>> return mail( $from, $subject, $message, $headers);
>>
>> }
>>
>> My problem is that it will never arrive with the "Name" <email address>,
>> and I can only make it work using email addresses without the names or
>> the angle brackets around the email addresses. Once I tried printing the
>> headers and the quotes and angle brackets turned up, but no names or
>> email addresses. And once an email arrived but with nothing but angle
>> brackets! (I wonder how that happened? The SMTP server must have
>> stripped things out perhaps?)
>>
>> Thanks for your time in helping me with this,
>>
>> Spartacus
>
> First, headers need to be separated by "\r\n", not just "\n". Try
> that and see if it works any better.
>

Well, the \n worked fine on both my server and my local machine, but
I've changed everything to \r\n anyway.

Everything now works, strangely enough. I must have a dud server or the
server's sendmail doesn't like names and angle brackets. Running my PHP
mailer on my machine at home works just fine using the Windows SMTP
server, name and angle brackets, no problems at all. Weird.

Thanks for your help.
Spartacus

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация