PHP mail returns true, but no email is being sent - "Connection refused by [127.0.0.1]" -


i working redhat linux server. few months ago, had written simple user registration system in php5 using email verification. recall working @ time. however, after testing system, find email not being sent (i've tried few email addresses different domains, checked spam folders).

as test case, tried simple code below (using actual email address $to):

<html> <head> <title>sending email using php</title> </head> <body> <?php    $to = "myemail@gmail.com";    $subject = "subject";    $message = "message";    $header = "from:webmaster@mydomain.com \r\n";    $header .= "mime-version: 1.0\r\n";    $header .= "content-type: text/html\r\n";    $ret = mail ($to,$subject,$message,$header);    if( $ret == true )      {       echo "message sent successfully.";    }    else    {       echo "message not sent.";    } ?> </body> </html> 

it echoes "message sent successfully". tried using phpmailer, gives successful message (i believe implementation uses mail() function well).

looking @ php.ini, there following:

[mail function] smtp = localhost smtp_port = 25 sendmail_path = /usr/sbin/sendmail -t -i 

i not familiar how smtp servers work. steps can take troubleshoot issue? matter of contacting server admin or there can change myself (i have root access)?

edit:
andrzej's suggestion, checked maillog file , found these 2 lines recent attempt (i replaced servername , email):

mar 11 17:11:30 myservername sendmail[23240]: s2blbu2x023240: from=apache, size=149, class=0, nrcpts=1, msgid=<201403112111.s2blbu2x023240@myservername.com>, relay=apache@localhost

mar 11 17:11:30 myservername sendmail[23240]: s2blbu2x023240: to=myemail, ctladdr=apache (48/48), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30149, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=deferred: connection refused [127.0.0.1]

deferred: connection refused [127.0.0.1]

modern sendmail relays messages local sendmail daemon running root using smtp connection 127.0.0.1:25. has been done avoid security risk of installing sendmail set root uid program.

it seems sendmail daemon/service has not been started (successfully) on computer. sendmail should report startup failure , causes log file.

it seems service sendmail restart command starts sendmail on redhat.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -