Jump to content

Centos sendmail, php mail issue


james_4k2

Recommended Posts

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

Link to comment
Share on other sites

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>");
}
?>

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.