1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Enabling PHP mail() function on my VPS

Discussion in 'Site & Server Administration' started by ChrisB, Dec 5, 2006.

  1. #1
    Hi guys, would appreciate help on this....have looked in a lot of places but still no success and godaddy does not want to help. Have a new godaddy VPS and need to enable php mail() function for my Wordpress blogs as no email verification emails are being sent. (non of my other websites send mail via php either)
    SEMrush
    error I get when doing wordpress password retrieve:
    The e-mail could not be sent.
    Possible reason: your host may have disabled the mail() function...

    I know I need to change a setting in php.ini file to enable it (or maybe I can do this directly for WHM admin panel?).

    Can you help?
     
    ChrisB, Dec 5, 2006 IP
    SEMrush
  2. CodyRo

    CodyRo Peon

    Messages:
    365
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Check your php.ini for the following:

    
    disable_functions =
    
    Code (markup):
    if mail is there, remove it :)
     
    CodyRo, Dec 5, 2006 IP
  3. ChrisB

    ChrisB Well-Known Member

    Messages:
    580
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    128
    #3
    the 'disable_functions =' is totally empty.

    Here is a direct cut and past from my php.ini file about [mail function]:

    [mail function]
    ; For Win32 only.
    ;SMTP = localhost ;
    smtp_port = 25

    ; For Win32 only.
    ;sendmail_from =chris@ceb0.com ;

    ; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
    sendmail_path = /usr/sbin/sendmail -t -i ;


    Is there anything here that needs changing?
     
    ChrisB, Dec 5, 2006 IP
  4. agnivo007

    agnivo007 Peon

    Messages:
    4,290
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    0
    #4
    is the sendmail path correct...? and is sendmail being used or any other like qmail or postfix etc ?
     
    agnivo007, Dec 6, 2006 IP
  5. max pain

    max pain Peon

    Messages:
    2,179
    Likes Received:
    521
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Found this - take a look if its of any use...

    http://wordpress.org/support/topic/24397

     
    max pain, Dec 6, 2006 IP
    Raj Kumar likes this.
  6. ChrisB

    ChrisB Well-Known Member

    Messages:
    580
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    128
    #6
    Thanks guys...

    - path to sendmail is correct and sendmail is working (I checked with godaddy support)

    maxpain - thanks but I am running WP version 2xx and the wp_mail function looks like this:

    function wp_mail($to, $subject, $message, $headers = '') {
    if( $headers == '' ) {
    $headers = "MIME-Version: 1.0\n" .
    "From: wordpress@" . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])) . "\n" .
    "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\n";
    }

    return @mail($to, $subject, $message, $headers);
    }

    You can find my php.ini info here: http://www.vidaguerrasbutt.com/1.php

    Problem still persists.
     
    ChrisB, Dec 6, 2006 IP
  7. CodyRo

    CodyRo Peon

    Messages:
    365
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Remove the @ in front of the mail() function and see if it spits out a error.
     
    CodyRo, Dec 6, 2006 IP
  8. ChrisB

    ChrisB Well-Known Member

    Messages:
    580
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    128
    #8
    Thanks for the suggestion, did this but still the same error:

    The e-mail could not be sent.
    Possible reason: your host may have disabled the mail() function...
     
    ChrisB, Dec 6, 2006 IP
  9. tanfwc

    tanfwc Peon

    Messages:
    579
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Try this in shell

    mail -s "Testing Email from `hostname`" <youremailaddress>
    Code (markup):
    It should send you a email from your MTA

    Then try to send via PHP

    <?
    
    mail("youremail", "Test Subject", "Testing");
    
    ?>
    Code (markup):
    Let me know if you still have problems
     
    tanfwc, Dec 9, 2006 IP
  10. Beenie

    Beenie Guest

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Hi all.
    Little late in the day but this may help other sufferers with the same problem. You need to open your php.ini file, scroll down to mail() and replace the value "localhost" with your SMTP Host IP address. 127.0.0.1 does not work, you will need your mailservers IP address. Save the file and try the mail, should be sorted.

    Usual Setting
    [mail function]
    ; For Win32 only.
    ;SMTP = localhost ;
    smtp_port = 25

    Change to
    [mail function]
    ; For Win32 only.
    ;SMTP = 255.197.00.454(whatever your mailserver IP is) ;
    smtp_port = 25
     
    Beenie, Mar 28, 2008 IP
  11. NeoCambell

    NeoCambell Peon

    Messages:
    456
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #11
    I was trying quite hard to get email working with WordPress on GoDaddy. After hours of continuous effort I was able to get it working :)

    Have a look at this detailed explanation on the steps I followed to get it to work.

    http://www.expertcore.org/viewtopic.php?f=74&t=1079
     
    NeoCambell, Dec 21, 2009 IP
  12. kailash

    kailash Well-Known Member

    Messages:
    1,251
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    100
    #12
    If PHP is running as nobody user make sure “Prevent the user “nobody” from sending out mail to remote addresses (PHP and CGI scripts generally run as nobody if you are not using PHPSuexec and Suexec respectively.)” option is not checked. You can check this option from WHM:

    - Login to your WHM.
    - Go to Server Configuration -> Tweak Settings.

    If you are hosting other websites too then this option should remain On. Turn off this option only if you are going to host your personal websites.

    Kailash
     
    kailash, Dec 22, 2009 IP