1

My server is Red Hat Enterprise Linux Server release 7.1 . I am trying to send simple emails using localhost.

$to = 'kosala@xxxxxx.com;
    $subject = 'Fake sendmail test';
    $message = 'If we can read this, it means that our fake Sendmail setup works!';
    $headers = 'From: myemail@egmail.com' . "\r\n" .
            'Reply-To: myemail@gmail.com' . "\r\n" .
            'X-Mailer: PHP/' . phpversion();

    if (mail($to, $subject, $message, $headers)) {
        echo 'Email sent successfully!';
    } else {
        die('Failure: Email was not sent!');
    }

response is : Email sent successfully!

But i have not received any mails.My smtp port 25 is open,i checked it using below command.

nmap -sT -O localhost

Output of echo "test" | sendmail xxxx@gmail.com command is

You have new mail in /var/spool/mail/root

Thanks in advance, Kosala

Kosala Yapa
  • 64
  • 2
  • 9
  • 1
    Is it not in spam? Try sending it to a different provider - gmail might be blocking these kind of things. You should really be using a proper mail sending service provider to send emails if you do not want to end up with emails in the spam box. – Andrius Nov 18 '15 at 08:24
  • 1
    Please check first manual whether your mail service is working properly or not. To check that use this command from your console:- echo "test" | sendmail yourmail@gmail.com – Hemdip Nov 18 '15 at 08:27
  • Thanks your valuable helps. It is not inside spam box.After i execute echo "test" | sendmail yourmail@gmail.com command output was You have new mail in /var/spool/mail/root. @Hemdip – Kosala Yapa Nov 18 '15 at 08:32
  • Yea its correct but did you get email in your inbox by using that command? – Hemdip Nov 18 '15 at 08:38
  • I did not get. any mails. @Hemdip – Kosala Yapa Nov 18 '15 at 08:41
  • Please check your mail delivery status using this command :- tail -f /var/log/mail.log – Hemdip Nov 18 '15 at 09:54
  • I used `tail -f /var/log/maillog` command to view the log. then i saw **stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com** for gmail addresses and **stat=Sent** for other email addresses. but i did not receive the email @Hemdip – Kosala Yapa Nov 18 '15 at 10:35
  • @John Conde .This is a configuration problem of redhat not a simple php problem. I can sent mail in my UAT server. – Kosala Yapa Nov 19 '15 at 06:08
  • I found the problem ."As of October 28th, 2015, SoftLayer no longer allows outbound connections through TCP port 25 (SMTP) on new accounts." (http://knowledgelayer.softlayer.com/content/outbound-email-port-25) @John Conde – Kosala Yapa Nov 27 '15 at 08:36

0 Answers0