Sendmail not working, using mail() in PHP

I'm trying to get the mail() function in PHP working, which uses sendmail on my freebsd box. I'm pretty sure the PHP code is fine as I've used this exact script on a couple other boxes.

I've tested using sendmail from the console, and it worked fine. I receieved the message quickly, no errors, etc. But whenever I try using the mail command, I'm getting an error in /var/log/maillog , it says among other stuff "Invalid route address", here's the complete log.

sendmail[1256]: i9RMVj09001256: from=www, size=3324, class=0, nrcpts=1, msgid=<200410272231.i9RMVj09001256@DOMAIN.COM>, relay=www@localhost

sendmail[1256]: i9RMVj09001256: i9RMVj0A001256: DSN: EMAILADDRESS1, EMAILADDRESS2... Invalid route address

sm-mta[1257]: i9RMVjUr001257: from=<>, size=5160, class=0, nrcpts=1, msgid=<200410272231.i9RMVj0A001256@DOMAIN.COM>,
proto=ESMTP, daemon=Daemon0, relay=localhost [127.0.0.1]

sendmail[1256]: i9RMVj0A001256: to=www, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=34348, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (i9RMVjUr001257 Message accepted for delivery)

sm-mta[1258]: i9RMVjUr001257: to=webmaster, ctladdr=<www@DOMAIN.COM> (26/0), delay=00:00:00, mailer=local, pri=125160, dsn=5.1.1, stat=User unknown

sm-mta[1258]: i9RMVjUr001257: i9RMVjUr001258: postmaster notify: User unknown

sm-mta[1258]: i9RMVjUr001258: to=root, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=36391, relay=local, dsn=2.0.0, stat=Sent

sendmail[1256]: i9RMVj09001256: i9RMVj0A001256: DSN: EMAILADDRESS1, EMAILADDRESS2... Invalid route address

Note: I've removed the email addresses and domain names.

If you need any other information (config information, tests done, etc. just ask), all I need is to be able to send mail out using the mail function through PHP.
LVL 2
ThesolitasAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ThesolitasAuthor Commented:
ACK: I duplicated a line from the log, the last log line:

sendmail[1256]: i9RMVj09001256: i9RMVj0A001256: DSN: EMAILADDRESS1, EMAILADDRESS2... Invalid route address

Shouldn't be there, it should only be there once near the top (2nd line).
0
gheistCommented:
The problem is that addresses without @ and those @localhost are quite illegal, and next wrong thing about your mailserver is that you removed mail alias for postmaster, so you do not get any mail errors.
0
ThesolitasAuthor Commented:
This server is a dedicated server setup by a hosting company.

I didn't remove any alias's from the sendmail config, so I'm not sure why the postermaster alias wouldn't be there, but I can fix that.

As far as the @ and @localhost addresses, what would cause that?

I'm setting a from address when I use the php mail command, and this worked on two other box's of mine. The from address is for a domain that is hosted on this box.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

gheistCommented:
Do these contain @ : EMAILADDRESS1, EMAILADDRESS2 ???
0
ThesolitasAuthor Commented:
Yes, EMAILADDRESS1 and EMAILADDRESS2 are valid email address's. I replaced them with that as I didn't want them in the message.
0
gheistCommented:
what does
dig -t mx domain1 show ???
then - is dig -t a <what it showed> showing some legal IP address ???
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ThesolitasAuthor Commented:
Okay, I see there's a problem there, it seems the domain it's trying to send the mail out as is the main domain tied to the box. Here's the thing.

The box has multiple domains on it. I'm only using 1 currently (the one I'm trying to send mail out as), but it's not the domain the box is setup under.

If I check (using "dig -t mx domain") the domain I WANT to send mail out under, it's all fine. It's not fine for the main box domain though.

I'll fix the domain the box is setup with, but I'd still like to be able to send mail out using the proper domain. I'm not sure why it's not sending the mail out under the proper domain, it did on my other box. I'm guessing it's either the sendmail setup in my php.ini, or something I need to do differently with my mail command in my script.

Thanks for the help! If you have any thoughts as to why it would be sending out mail under the wrong domain they would be appreciated. Thanks again.
0
ThesolitasAuthor Commented:
Ahh, finally fixed it.

My php script for mailing was using the Cc header to copy a couple additional people on the message. I guess when I originally grabbed the code for this, it was using a semi-colon to seperate the names in the Cc header field. This worked on my other boxes, but not on this one. I found using a comma fixed the problem.

So this whole thing was failing because it didn't like the ; instead of the , in the Cc field. :\

Anyways, thanks for your help ghieist, it helped me narrow down where I was looking which ultimately led to me finding the problem, so thanks again.
0
gheistCommented:
Srtangest thing is that SMTP does not care much about what is put inside mail DATA
0
ThesolitasAuthor Commented:
Well I tried both from PHP using the mail function, and from the console using sendmail directly.

If I use a semi-colon to seperate the addresses in the Cc, or the To fields, instead of a comma, I get errors in my maillog saying:

DSN: email@domain.com, email2@domain.com... Invalid route address

It's odd, as this doesn't happen on my other machine, but I just read somewhere that though semi-colons are supported in alot of software, the RFC says comma's are the required seperator and that semicolons are not officially supported. I'm going to take a look through the RFC's and see if this is really the case.
0
gheistCommented:
what makes you think mail() in php can accept multiple destinations???

http://si.php.net/manual/en/function.mail.php
0
ThesolitasAuthor Commented:
Well it does, cause I have it working now. And I've had it working prior to this.

In their example #4 they even describe it:

/* recipients */
$to  = "mary@example.com" . ", " ; // note the comma
$to .= "kelly@example.com";

The original code I grabbed for using the mail function though used a semicolon, not a comma, and that's where some versions of sendmail have problems. Some seem to accept a semi-colon seperating the To, CC, and BCC fields, some don't.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.