|
-
Apr 8th, 2008, 04:46 AM
#1
Thread Starter
Hyperactive Member
email() with header information
Hi,
I am trying to send email using mail() with the following header information. However the email goes from [email protected]. How do I get my mail script to send email from my email id instead of [email protected].
$headers = "From: XXXX <[email protected]>"."\n"."MIME-Version:1.0"."\r\n"."Content-type:text/html; charset=iso-8859-1"."\r\n"."X-Priority: 3"."\n"."X-MSMail-Priority: Normal"."\n"."X-Mailer: xxx"."\n"."X-MimeOLE: Produced By xxx";
mail($email, $subject, $read, $headers);
Please help.
-
Apr 8th, 2008, 10:11 PM
#2
Re: email() with header information
You've a mix of \n and \r\n between your headers. SMTP headers are delimited by \r\n.
-
Apr 9th, 2008, 02:09 AM
#3
Thread Starter
Hyperactive Member
Re: email() with header information
Thank you for the reply penagate. But this is not working. I remove all "\r\n" and there is no error mail in my inbox. Please try to cope up the situation. Thank you so much.
-
Apr 9th, 2008, 02:14 AM
#4
Re: email() with header information
No no no. The \r\n separators are required.
Try this:
$headers = "From: XXXX <[email protected]>\r\n".
"MIME-Version:1.0\r\n".
"Content-type:text/html; charset=iso-8859-1\r\n".
"X-Priority: 3\r\n".
"X-MSMail-Priority: Normal\r\n".
"X-Mailer: xxx\r\n".
"X-MimeOLE: Produced By xxx\r\n";
Sorry if I misled you.
P.S. Alternatively, you can put headers into an array, and then join them into a string. This is more manageable than hard-coding one long string.
PHP Code:
$headers = array( 'From: XXXX <[email protected]>', 'MIME-Version:1.0', 'Content-type:text/html; charset=iso-8859-1', 'X-Priority: 3', 'X-MSMail-Priority: Normal', 'X-Mailer: xxx', 'X-MimeOLE: Produced By xxx' );
mail(... join("\r\n", $headers), ...);
Last edited by penagate; Apr 9th, 2008 at 02:17 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|