Results 1 to 13 of 13

Thread: PHP will not send email

  1. #1
    Catprog is offline New Bee
    Join Date
    Sep 2008
    Posts
    11
    WHB Points this Month
    0.00
    WHB Points
    0.00
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PHP will not send email [solved]

    I have a problem with mail on php

    I cannot send emails with it.

    My headers are

    $headers = "From: webmaster@catprog.org" . "\r\n" .
    "Reply-To: webmaster@catprog.org" . "\r\n" .
    "X-Mailer: PHP/" . phpversion();

    return mail($To,$Subject,$Content,$headers);


    I have been able to send messages to the email specified using the horde webmail logged into webmaster@catprog.org
    Last edited by Catprog; 08-22-2014 at 04:44 PM.

  2. #2
    Alan B's Avatar
    Alan B is offline Super Moderator
    Join Date
    Jul 2007
    Location
    Toronto, Canada
    Posts
    1,439
    WHB Points this Month
    0.00
    WHB Points
    405.00
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default

    Does webmaster@catprog.org exist as a mail account on your WHB server, the same server on which you're running the PHP script?
    I am not WHB staff and I am not paid.
    I provide help in these forums on my own time.

  3. #3
    Catprog is offline New Bee
    Join Date
    Sep 2008
    Posts
    11
    WHB Points this Month
    0.00
    WHB Points
    0.00
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yes it does.

    (EDIT: unless the email settings on cpanel refer to a different server then the file maintenance )
    Last edited by Catprog; 05-22-2014 at 12:00 AM.

  4. #4
    storminternet is offline New Bee
    Join Date
    May 2014
    Posts
    1
    WHB Points this Month
    0.00
    WHB Points
    0.00
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Do you know if the server has suphp enabled. Mostly it is enabled on cPanel servers. If suphp is not enabled on server then most likely you are trying to send emails via script with the 'nobody' user. Sometimes hosts disable the option 'Prevent nobody user to send emails' in WHM
    This can be one of the reason why you are not able to send emails via php.

    Secondly for script while you use SMTP authentication following things should be included in it.

    Mailserver which is generally mail.domain.com or localhost
    SMTP port= usually 25 or if any host is using custom port. This you need to check with your host
    Username: Any valid email password
    Password: Password of email account.

  5. #5
    Catprog is offline New Bee
    Join Date
    Sep 2008
    Posts
    11
    WHB Points this Month
    0.00
    WHB Points
    0.00
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am just using the mail function on php. I do not know how to configure any of those settings.

    EDIT:

    I have now set up PEAR mail and after fiddling around, it now works.
    Last edited by Catprog; 05-31-2014 at 06:07 AM.

  6. #6
    Matt R.'s Avatar
    Matt R. is offline WeeHBie
    Join Date
    Jul 2006
    Posts
    1,423
    WHB Points this Month
    0.00
    WHB Points
    120.00
    Thanks
    1
    Thanked 6 Times in 6 Posts

    Default

    Quote Originally Posted by Catprog View Post
    I am just using the mail function on php. I do not know how to configure any of those settings.

    EDIT:

    I have now set up PEAR mail and after fiddling around, it now works.
    Can you share the settings you used? It'll be helpful for other forum members
    Matt Russell
    WebHostingBuzz CEO

    Follow me on Twitter: http://www.twitter.com/mattdrussell

  7. #7
    Catprog is offline New Bee
    Join Date
    Sep 2008
    Posts
    11
    WHB Points this Month
    0.00
    WHB Points
    0.00
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    function pearlMail($To,$Subject,$Content)
    {

    if ($To == "") {
    return true ;
    }

    require_once "Mail.php";

    $headers = "From: webmaster@catprog.org" . "\r\n" .
    "Reply-To: webmaster@catprog.org" . "\r\n" .
    "X-Mailer: PHP/" . phpversion();

    $from = "webmaster@catprog.org";

    $host = "ssl://server03.abstractdns.com";
    $port = "465";
    $username = "webmaster@catprog.org";
    $password = "******";

    $headers = array ('From' => $from,
    'To' => $To,
    'Subject' => $Subject);
    $smtp = Mail::factory('smtp',
    array ('host' => $host,
    'port' => $port,
    'auth' => true,
    'username' => $username,
    'password' => $password));


    $mail = $smtp->send($To, $headers, $Content);

    if (PEAR::isError($mail)) {
    echo("<p>" . $mail->getMessage() . "</p>");
    } else {
    echo("<p>Message successfully sent!</p>");
    }


    }

  8. #8
    palcomin is offline New Bee
    Join Date
    Jun 2014
    Posts
    1
    WHB Points this Month
    0.00
    WHB Points
    0.00
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default RE: PHP will not send email

    Did you check on web browser you receive Emails on that ID.
    Palcomonline.com

  9. #9
    inuxtech is offline New Bee
    Join Date
    Aug 2014
    Location
    india
    Posts
    7
    WHB Points this Month
    0.00
    WHB Points
    0.00
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hello,

    Check php mail function enable or not.

  10. #10
    Catprog is offline New Bee
    Join Date
    Sep 2008
    Posts
    11
    WHB Points this Month
    0.00
    WHB Points
    0.00
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    The problem was it was not connecting to the email server at all. (due to security settings)

  11. #11
    inuxtech is offline New Bee
    Join Date
    Aug 2014
    Location
    india
    Posts
    7
    WHB Points this Month
    0.00
    WHB Points
    0.00
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hello Catprog,

    Please check all email port number in firewall i.e SMTP : 25 and 465 POP3 : 110 and 995 IMAP : 143 and 993

    Thanks
    InuxTech Support

    Server Management Provider
    http://Inuxtechsupport.net

  12. #12
    owlowl157 is offline New Bee
    Join Date
    Apr 2017
    Posts
    10
    WHB Points this Month
    5.00
    WHB Points
    5.00
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hello! this complex question. Here it is necessary to think ...

  13. #13
    Bill Goldberg is offline New Bee
    Join Date
    Jan 2017
    Posts
    27
    WHB Points this Month
    5.00
    WHB Points
    15.00
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Security settings are the reason I think so.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •