The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

php mail() function in CRON

Discussion in 'E-mail Discussions' started by netlook, Sep 26, 2005.

  1. netlook

    netlook Well-Known Member
    PartnerNOC

    Joined:
    Mar 25, 2004
    Messages:
    335
    Likes Received:
    0
    Trophy Points:
    16
    I have problem with PHP mail() function using CRON

    This is a script:

    mail($to,$subject,$body,$headers);

    where

    $headers = "From: user@domain\nReply-To: user@domain\nReply-Path: user@domain\n";

    but when i send this e-mail by cron I get as sender user@hostname not user@domain.

    Where is the problem?

    Thanks
     
  2. bpmod

    bpmod Well-Known Member

    Joined:
    Sep 23, 2004
    Messages:
    49
    Likes Received:
    0
    Trophy Points:
    6
    Try this:

    mail($to,$subject,$body,$headers, -f user@domain);

    Thanks

    Brian
     
  3. netlook

    netlook Well-Known Member
    PartnerNOC

    Joined:
    Mar 25, 2004
    Messages:
    335
    Likes Received:
    0
    Trophy Points:
    16
    I get T_STRING error when I try this :confused:
     
  4. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    In which case you might want to try:

    Code:
    mail($to,$subject,$body,$headers, [B]"-f user@domain"[/B]);
    Incidentally, if such a relatively trivial error stumps you, I would strongly suggest that you buy a nice good book on PHP and do some thorough learning!
     
  5. netlook

    netlook Well-Known Member
    PartnerNOC

    Joined:
    Mar 25, 2004
    Messages:
    335
    Likes Received:
    0
    Trophy Points:
    16
    This problem exist only when I run this script in cron, when I open it manually in browser, in exim_mainlog I have correct sender of the message - so I think it doesn't have much with PHP, more with server configuration...
     
  6. bpmod

    bpmod Well-Known Member

    Joined:
    Sep 23, 2004
    Messages:
    49
    Likes Received:
    0
    Trophy Points:
    6
    I forgot the quotes. Mea Culpa!

    Brian
     
Loading...

Share This Page