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 scripts send mail as user@servername.com

Discussion in 'E-mail Discussions' started by cwalke32477, Jan 7, 2011.

  1. cwalke32477

    cwalke32477 Well-Known Member

    Joined:
    Mar 2, 2010
    Messages:
    94
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Atlanta, Georgia
    cPanel Access Level:
    Root Administrator
    How can I make php scripts send mail as user@account.com instead of user@servername.com?
    I would like to set this universally.
    I know each site admin can do it by editing the php code, but I know there is a way to have it as default serverwide, as I have had a server in the past that sent it as such.

    Any advice appreciated, thanks
     
  2. mtindor

    mtindor Well-Known Member

    Joined:
    Sep 14, 2004
    Messages:
    1,279
    Likes Received:
    36
    Trophy Points:
    48
    Location:
    inside a catfish
    cPanel Access Level:
    Root Administrator
    Really? I don't believe that would ever be possible, unless each user had their own php.ini and it was specified in the php.ini. Otherwise, I believe the only option is for the client to do it within their own PHP code. Think about it -- how would the server ever know to send it out as "such_and_such@domain.com". PHP does not have access to anything that would tell it the such_and_such@domain.com for each and every domain.

    NOTE: You may be able to edit the core PHP.INI file and set one single address that is used as the default sender address.... if that's what you are asking.

    Mike
     
  3. cwalke32477

    cwalke32477 Well-Known Member

    Joined:
    Mar 2, 2010
    Messages:
    94
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Atlanta, Georgia
    cPanel Access Level:
    Root Administrator
    Unfortunately I have no idea how the last server was configured, as it was setup for me, and was a VPS server.
    This new one is a full dedicated that I had to setup and configure.
    But all the accounts on it were sending mail under user@userdomain
     
  4. JawadArshad

    JawadArshad Well-Known Member
    PartnerNOC

    Joined:
    Apr 8, 2008
    Messages:
    447
    Likes Received:
    4
    Trophy Points:
    18
    Location:
    PK
    cPanel Access Level:
    DataCenter Provider
    You can resolve this by building proper headers in your scripts via mail() and ensure you use the fifth parameter given below.

    Code:
    mail($to, $message, $subject, "From: $from", [B]"-f$from"[/B]);
    
    You can check official PHP mail() function documentation by clicking at this link.

    Additionally you can check this link as a reference.

     
Loading...

Share This Page