Results 1 to 4 of 4

Thread: email() with header information

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    266

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

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: email() with header information

    You've a mix of \n and \r\n between your headers. SMTP headers are delimited by \r\n.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    266

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

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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
  •  



Click Here to Expand Forum to Full Width