Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Php scripts send mail as user@servername.com

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

  1. cwalke32477

    cwalke32477 Well-Known Member

    Joined:
    Mar 2, 2010
    Messages:
    94
    Likes Received:
    0
    Trophy Points:
    56
    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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. mtindor

    mtindor Well-Known Member

    Joined:
    Sep 14, 2004
    Messages:
    1,342
    Likes Received:
    57
    Trophy Points:
    178
    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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. cwalke32477

    cwalke32477 Well-Known Member

    Joined:
    Mar 2, 2010
    Messages:
    94
    Likes Received:
    0
    Trophy Points:
    56
    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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. JawadArshad

    JawadArshad Well-Known Member
    PartnerNOC

    Joined:
    Apr 8, 2008
    Messages:
    458
    Likes Received:
    6
    Trophy Points:
    68
    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.

     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice