Page 1 of 1

Sending mail to postfix

Posted: Fri Jun 10, 2005 12:52 pm
by jammindice
I cannot for the life of me get mail to send properly using the mail() or pear::mail.

sendmail wouldn't work right so i gave up on the mail() command and switched to pear::mail. That works much better, it actually connects to postfix but this shows up in the logs:

Jun 10 13:05:58 shaun postfix/smtpd[30174]: connect from unknown[216.xxx.xxx.xxx]
Jun 10 13:05:58 shaun postfix/smtpd[30174]: NOQUEUE: reject: RCPT from unknown[216.xxx.xxx.xxx]: 550 <support@mydomain.com>: Recipient address rejected: User unknown in virtual mailbox table; from=<joe@domain.com> to=<support@mydomain.com> proto=ESMTP helo=<localhost>
Jun 10 13:05:58 shaun postfix/smtpd[30174]: lost connection after RCPT from unknown[216.xxx.xxx.xxx]
Jun 10 13:05:58 shaun postfix/smtpd[30174]: disconnect from unknown[216.xxx.xxx.xxx]

I don't know if this is really a php question since the php half works, just doesn't send and i don't know if it's the code or postfix. I can definetly say the mail server works fine i can send email from outlook, webmail, and others to support and it works. I don't understand how i'm getting a 550 error here though. The mail server and web server are on the same box, running FreeBSD 5.1, Apache 1.3.33, php4, and postfix with mysql virtual tables.

Any suggestions?

oh yeah the x's and mydomain stuff is for security....

Thanks,
Shaun Mickey
270net Technologies
Systems Administrator

E mail

Posted: Sat Jun 11, 2005 1:55 am
by asanga
Do you use any spam gard or somthing similer like filter. then it will block your IP. or check mail server's setting. is it block your IP. if not we need to think more lets find a soloution.

Posted: Mon Jun 13, 2005 7:56 am
by jammindice
Well, yes i do run amavisd with clamav/spamassassin, but it's not a problem with either of them since it's a 550 user lookup error.

Code: Select all

require_once('Mail.php');

$recip = $_POST&#1111;'recip'];

$headers&#1111;&quote;From&quote;]    = $_POST&#1111;'email'];
$headers&#1111;&quote;To&quote;]      = $client&#1111;contact]&#1111;email]&#1111;$recip];
$headers&#1111;&quote;Subject&quote;] = $_POST&#1111;'subject'];

$recipients = $client&#1111;contact]&#1111;email]&#1111;$recip];

$body = $_POST&#1111;'msg'] . &quote;<BR> Email: &quote; . $headers&#1111;&quote;From&quote;];

function validate($the_email_address){
  return (eregi (&quote;^(&#1111;a-z0-9_]|\\-|\\.)+@((&#1111;a-z0-9_]|\\-)+\\.)+&#1111;a-z]+$&quote;, $the_email_address));
}

if ($headers&#1111;&quote;From&quote;] == '' || !(validate($headers&#1111;&quote;From&quote;]))){
  $headers&#1111;&quote;From&quote;] = 'info@mydomain.com';
}

if ($body == '' || $body == NULL || $body == 'Type your message here'){
  echo &quote;<h2>Your request could not be processed</h2><p>Please enter a valid message.&quote;;
} else {
  echo &quote;<H2>Your Request Was Sent Successfully</H2><p>Your request will be answered promptly.&quote;;

  $params&#1111;&quote;host&quote;] = &quote;mail.mydomain.com&quote;;
  $params&#1111;&quote;port&quote;] = &quote;25&quote;;

  // Create the mail object using the Mail::factory method
  $mail_object =& Mail::factory(&quote;smtp&quote;, $params);
  $mail_object->send($recipients, $headers, $body);
}
This is the code i'm using to send the email, it's like it's not sending it with the right "To:" address.

Posted: Tue Jun 21, 2005 8:41 am
by jammindice
Figured it out, the postfix version i was using had issues when mail was sent through sendmail, updated postfix and voila! everything works now.