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 email - not able to send externally

Discussion in 'E-mail Discussions' started by zerokarma, Oct 10, 2008.

  1. zerokarma

    zerokarma Active Member

    Joined:
    Oct 6, 2008
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    6
    I'm having a problem with PHP email not sending externally, if the recepitant email is a local domain the email will be delivered without any problems but if put an external email address with a domain not on the server the email never seems to get there.

    On the Tweak Setting it is already Unchecked for the "Prevent the user "nobody" from sending out mail to remote addresses" option.

    I am also using suphp as the PHP5 handler.

    I can't seem to figure this out, any ideas?
     
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Many mail providers (including many using cPanel/WHM) now perform sender verification on mail coming into their server from an external server to ensure the 'from' address on an email is an actual email address. If this is not an actual email address, it is discarded as spam. So make sure the 'from' is an actual email address.

    There is also common speculation that a PHP script sending mail via SMTP is a better method of sending mail than relying on PHP's mail() function. In many contemporary distributed PHP scripts, all one has to do is change a few settings to switch from using mail() to using SMTP.
     
  3. zerokarma

    zerokarma Active Member

    Joined:
    Oct 6, 2008
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    6
    I dont think that is the issue in this case, I have access to the other server in which I am trying to send the email to. There is a special account on there where all spam gets dumped into I don't see any of the emails in there. After I try to send the email with the script it appears to work fine, no error notice or anything but it just never shows up at the other remote email. However when sending to a local email on the server it shows up fine.
     
  4. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    And it is only email from the script, not other email from your server, that is disappearing?
     
  5. zerokarma

    zerokarma Active Member

    Joined:
    Oct 6, 2008
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    6
    I believe its just the script/php mail

    All the other mail seems to be perfectly fine sending remotely

    One thing I did try was creating a forwarding email address that would send to the remote email. When I sent a test email to this forwarding email address it worked fine and I received the mail.

    When I set the script to send the email to this forwarding email the email still never arrives at the remote email.
     
  6. zerokarma

    zerokarma Active Member

    Joined:
    Oct 6, 2008
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    6
    OK i was checking for errors and didn't find any intially but then found this:

    What should I do to correct it?
     
  7. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Have it send mail with a from address of a valid email address on your server rather than sending it as "nobody@srv2.stealth.com"

    You may wish to consider using SMTP to send the mail if you are not sufficiently familiar with the PHP mail() function to do this.
     
  8. zerokarma

    zerokarma Active Member

    Joined:
    Oct 6, 2008
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    6
    How do you change it from sending as "nobody@srv2.stealth.com"? Is it done at the script level or elsewhere?

    How do you set PHP to send my SMTP? again is it at the script level or elsewhere?
     
  9. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Short answer: the script level.

    Long answer: you can have it be user@srv2.stealth.com (where user is their cPanel username) by using SuPHP since this will force scripts to execute as the user rather than user nobody.

    This is handled on the script level.
     
  10. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,384
    Likes Received:
    23
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    In your PHP script when you call the mail() function, make use of the fifth parameter of PHP's mail function:

    http://us3.php.net/manual/en/function.mail.php

    PHP:
    mail($to$subject$message$headers"-fsomerealaddress@example.com");
    The somerealaddress@example.com address is the address that you want bounced return messages to come to. It needs to be a valid e-mail address, one that actually accepts mail.
     
  11. zerokarma

    zerokarma Active Member

    Joined:
    Oct 6, 2008
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    6
    Thanks I will try that
     
Loading...

Share This Page