james_4k2 Posted July 6, 2009 Share Posted July 6, 2009 Greetings, I have a server with CentOS 5 and I have to send email using a php script from that server. The php mail script works in other location but in one location I have to use their smtp relay IP in order to send emails. I have tried to configure sendmail.mc but still no success. If I send just a test hello mail through telnet then it works but not with a php mail function. here is my maillog- Jul 5 20:10:42 xxx sendmail[16714]: n660AgwO016714: n660AgwP016714: return to sender: Host unknown (Name server: 101.1.1.101: host not found) Jul 5 20:10:42 xxx sendmail[16714]: n660AgwP016714: to=root, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=32592, dsn=2.0.0, stat=Sent Any suggestion will be helpful. Thanx in advance Quote Link to comment https://forums.phpfreaks.com/topic/164887-centos-sendmail-php-mail-issue/ Share on other sites More sharing options...
steviewdr Posted July 6, 2009 Share Posted July 6, 2009 Try taking a look at my sendmail config for using an external smtp server: http://wiki.kartbuilding.net/index.php/Sendmail Hope this helps. -steve Quote Link to comment https://forums.phpfreaks.com/topic/164887-centos-sendmail-php-mail-issue/#findComment-869669 Share on other sites More sharing options...
BMurtagh Posted July 7, 2009 Share Posted July 7, 2009 Hi, You can also specify in your PHP code (if PEAR support is enabled) the SMTP host, username, and password to send authenticated email. Below is just an alternate to explicitly set the SMTP server in your code instead of making changes to sendmail. <?php require_once "Mail.php"; $from = "Sandra Sender <sender@example.com>"; $to = "Ramona Recipient <recipient@example.com>"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; $host = "mail.example.com"; $username = "smtp_username"; $password = "smtp_password"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/164887-centos-sendmail-php-mail-issue/#findComment-870433 Share on other sites More sharing options...
james_4k2 Posted July 8, 2009 Author Share Posted July 8, 2009 Thanks Steve and Brendan for the reply and I tried ur suggestion and still no luck. Here is the output of my maillog found in /var/log/maillog Jul 8 13:27:24 myserver sendmail[1958]: n68HRO0e001958: from=test@test.com, size=165, class=0, nrcpts=1, msgid=<200907081727.n68HRO0e001958@clearica>, relay=root@localhost Jul 8 13:27:24 myserver sendmail[1961]: n68HROIu001961: from=<test@test.com>, size=373, class=0, nrcpts=1, msgid=<200907081727.n68HRO0e001958@clearica>, proto=ESMTP, daemon=MTA, relay=clearica. [127.0.0.1] Jul 8 13:27:24 myserver sendmail[1958]: n68HRO0e001958: to=myemail@gmail.com, ctladdr=test@test.com (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30165, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (n68HROIu001961 Message accepted for delivery) Jul 8 13:27:25 myserver sendmail[1963]: n68HROIu001961: to=<myemail@gmail.com>, delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=120373, relay=111.11.1.111, dsn=5.1.2, stat=Host unknown (Name server: 111.11.1.111: host not found) Jul 8 13:27:25 myserver sendmail[1963]: n68HROIu001961: n68HRPIu001963: DSN: Host unknown (Name server: 111.11.1.111: host not found) Jul 8 13:27:25 myserver sendmail[1963]: n68HRPIu001963: to=<test@test.com>, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=31569, relay=111.11.1.111, dsn=5.1.2, stat=Host unknown (Name server: 111.11.1.111: host not found) Jul 8 13:27:25 myserver sendmail[1963]: n68HRPIu001963: n68HRPIv001963: return to sender: Host unknown (Name server: 111.11.1.111: host not found) Jul 8 13:27:25 myserver sendmail[1963]: n68HRPIv001963: to=root, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=32593, dsn=2.0.0, stat=Sent Quote Link to comment https://forums.phpfreaks.com/topic/164887-centos-sendmail-php-mail-issue/#findComment-871252 Share on other sites More sharing options...
steviewdr Posted July 9, 2009 Share Posted July 9, 2009 Sounds like a mx record issue. You need a full proper hostname set. You also need a mx record for the domain you are sending the emails from. Do not use test@test.com Can you send emails to other people? Gmail are very picky about the email servers they recieve email from. If you can provide the exact following details, we can look into it a little more: Proper and working From email address Proper and working To email address IP and Hostname of your server sending the email. -steve Quote Link to comment https://forums.phpfreaks.com/topic/164887-centos-sendmail-php-mail-issue/#findComment-872042 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.