sending mail - using php script how to set "from"

Discussion in 'Site & Server Administration' started by login, May 28, 2007.

  1. #1
    I have a script that I use on two different sites and servers. This script includes sending an email.
    On the first server the from field shows "Nobody" when receiving the email.
    On the second one the from field shows "username@myserver.hostgator.com".

    How can I change this values ?

    Thanks, green for a good answer of course :)
     
    login, May 28, 2007 IP
  2. ccasselman

    ccasselman Peon

    Messages:
    412
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Is this in the same email client?

    Can you post the header of both emails?

    Same software just different servers?
     
    ccasselman, May 28, 2007 IP
  3. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #3
    Is this in the same email client?
    yes

    Can you post the header of both emails?
    I cannot post that here:eek:

    Same software just different servers?
    Yes, totally identical.
     
    login, May 28, 2007 IP
  4. ccasselman

    ccasselman Peon

    Messages:
    412
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Some software will take and give it the name of "NoReply". Which appears to be what is happening.

    You can go into the software and set the header to set the name and email at the same time and that should make it more consistent across all servers.

    Appears 1 OS is trying to do some things for you.
     
    ccasselman, May 28, 2007 IP
  5. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #5
    Both the accounts are on hostgator, its two different hostgator servers, shared accounts. I cannot change anything else than what I can do in cPanel.
    Beside the "from" is not "NoReply", its "Nobody".
     
    login, May 28, 2007 IP
  6. ccasselman

    ccasselman Peon

    Messages:
    412
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Is the From from the same address?

    If you can't change the script, what kind of solution are you looking for?
     
    ccasselman, May 28, 2007 IP
  7. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #7
    From Outlook Express, the email headers:

    server1:From: Nobody <nobody@myserver1.hostgator.com>

    server2:From:

    I am looking for a solution in cPanel or something.
     
    login, May 28, 2007 IP
  8. ccasselman

    ccasselman Peon

    Messages:
    412
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Well this is best for HostGator or someone with that host to answer. They should know how to fix this.

    Sorry I couldn't really help. I tried.
     
    ccasselman, May 28, 2007 IP
    login likes this.
  9. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #9
    Thank you very much for your help.
     
    login, May 28, 2007 IP
  10. rkquest

    rkquest Well-Known Member

    Messages:
    828
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    140
    #10
    If you just add a "from-variable" in your mail() call, it won't work on some servers (talking based on my experience). Just make sure you include this part in your header and "from-email-address" should appear correctly wherever you host your script:

    $headers = "From: You Name <youremail@yourdomain.com>\r\n" . "X-Mailer: php";
    Code (markup):
    Then send your email, for example:

    
    $to = 'someones@email.com';
    $subject = 'The Email Subject';
    $message = 'The Email Message Itself';
    mail($to, $subject, $message, $headers);
    
    Code (markup):
     
    rkquest, May 29, 2007 IP
    login likes this.
  11. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #11
    Thanks a lot. that helped. Green to you too.
     
    login, Jun 5, 2007 IP