PHP mail function

Discussion in 'PHP' started by larryj92, Oct 8, 2011.

  1. #1
    I am using the PHP mail function this is the headers
    [COLOR=#000000][COLOR=#0000BB]$headers [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]'From: webmaster@example.com' [/COLOR][COLOR=#007700]. [/COLOR][COLOR=#DD0000]"\r\n" [/COLOR][COLOR=#007700].
        [/COLOR][COLOR=#DD0000]'Reply-To: webmaster@example.com' [/COLOR][COLOR=#007700]. [/COLOR][COLOR=#DD0000]"\r\n" [/COLOR][COLOR=#007700].
        [/COLOR][COLOR=#DD0000]'X-Mailer: PHP/' [/COLOR][COLOR=#007700]. [/COLOR][COLOR=#0000BB]phpversion[/COLOR][COLOR=#007700]();
    [/COLOR][/COLOR]
    Code (markup):
    I am facing issues with the qmail and am confused whether to use "\r\n" or just "\n"
    please share your comments on this issue.
     
    larryj92, Oct 8, 2011 IP
  2. yho_o

    yho_o Well-Known Member

    Messages:
    354
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    #2
    [COLOR=#000000]echo [/COLOR][COLOR=#800000]'hi'[/COLOR][COLOR=#000000].[/COLOR][COLOR=#000000] PHP_EOL[/COLOR][COLOR=#000000];[/COLOR][COLOR=#000000]
    echo [/COLOR][COLOR=#800000]"hi\n"[/COLOR][COLOR=#000000];[/COLOR][COLOR=#000000]
    
    $headers [/COLOR][COLOR=#000000]=[/COLOR][COLOR=#800000]"From: "[/COLOR][COLOR=#000000].[/COLOR][COLOR=#000000] PHP_EOL 
               [/COLOR][COLOR=#000000].[/COLOR][COLOR=#800000]"Reply-To: "[/COLOR][COLOR=#000000];[/COLOR]
    Code (markup):
     
    yho_o, Oct 8, 2011 IP
  3. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #3
    From the PHP manual:

    "Multiple extra headers should be separated with a CRLF (\r\n).
    Note:

    When sending mail, the mail must contain a From header. This can be set with the additional_headers parameter, or a default can be set in php.ini.

    Failing to do this will result in an error message similar to Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing. The From header sets also Return-Path under Windows.

    Note:

    If messages are not received, try using a LF (\n) only. Some poor quality Unix mail transfer agents (emphasis mine) replace LF by CRLF automatically (which leads to doubling CR if CRLF is used). This should be a last resort, as it does not comply with » RFC 2822."
     
    Rukbat, Oct 8, 2011 IP
  4. Shamrocks

    Shamrocks Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You got it!
     
    Shamrocks, Oct 11, 2011 IP