1

Topic: Problem sending mails with PHP

Hi,

I have a strange problem at the moment, and don't know where to look.
Got a PHP script on one of my sites, which should send an email.
PHP is running as www-data, a local system user.
However, when PHP tries to send the email, I get this:

Mar 28 17:57:28 mail postfix/smtpd[3175]: connect from derchris.eu[94.23.1.26]
Mar 28 17:57:28 mail postfix/smtpd[3175]: NOQUEUE: reject: RCPT from derchris.eu[94.23.1.26] 550 5.1.0 <www-data@derchris.eu>: Sender address rejected: User unknown in virtual mailbox table; from=<www-data@derchris.eu> to=<frontpage@myserverstats.eu> proto=ESMTP helo=<derchris.eu>
Mar 28 17:57:28 mail postfix/smtpd[3175]: disconnect from derchris.eu[94.23.1.26]

So I created the www-data Mailbox, when I now get this error:

Mar 28 17:52:58 mail postfix/smtpd[3100]: connect from derchris.eu[94.23.1.26]
Mar 28 17:52:58 mail postfix/smtpd[3100]: NOQUEUE: reject: RCPT from derchris.eu[94.23.1.26] 553 5.7.1 <www-data@derchris.eu>: Sender address rejected: not logged in; from=<www-data@derchris.eu> to=<frontpage@myserverstats.eu> proto=ESMTP helo=<derchris.eu>
Mar 28 17:52:58 mail postfix/smtpd[3100]: disconnect from derchris.eu[94.23.1.26]

What is funny is, when I login to Roundcube, and send a mail from there, it is working fine.
Now, I don't really want to have a Mailbox for the www-data user.

Anyone knows how I could get this to work, so that local users, like www-data, can send mails?

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Problem sending mails with PHP

As the message says, you need to be authenticated to send mail.

Use Pear::Mail, in other words.

3

Re: Problem sending mails with PHP

I just checked, I'm not able to send emails from the Shell either.
Trying to send a mail with root, gets me a "User unknown in virtual mailbox table" error.
I can only send mails from Shell from the mail host itself.

Mar 28 22:22:53 mail postfix/smtpd[7036]: connect from derchris.eu[94.23.1.26]
Mar 28 22:22:53 mail postfix/smtpd[7036]: NOQUEUE: reject: RCPT from derchris.eu[94.23.1.26] 550 5.1.0 <root@derchris.eu>: Sender address rejected: User unknown in virtual mailbox table; from=<root@derchris.eu> to=<frontpage@myserverstats.eu> proto=ESMTP helo=<derchris.eu>
Mar 28 22:22:53 mail postfix/smtpd[7036]: disconnect from derchris.eu[94.23.1.26]
Mar 28 22:25:39 mail postfix/pickup[5755]: 44DD9945B8: uid=0 from=<root>
Mar 28 22:25:39 mail postfix/cleanup[7092]: 44DD9945B8: message-id=<20100328212539.44DD9945B8@mail.derchris.eu>
Mar 28 22:25:39 mail postfix/qmgr[2402]: 44DD9945B8: from=<root@mail.derchris.eu>, size=312, nrcpt=1 (queue active)
Mar 28 22:25:39 mail postfix/pipe[7095]: 44DD9945B8: to=<frontpage@myserverstats.eu>, relay=dovecot, delay=0.21, delays=0.08/0.02/0/0.12, dsn=2.0.0, status=sent (delivered via dovecot service)
Mar 28 22:25:39 mail postfix/qmgr[2402]: 44DD9945B8: removed

I can see where the error is coming from, as I'm using SMTP in the first try.
Fact is, the mail server is a Virtual Machine on the same server.
So I would most likely get around this by installing the mail server on the main host, and not as a Virtual Machine.

But I'm looking for a solution to keep it as it is at the moment.

4

Re: Problem sending mails with PHP

The fact its a virtual machine makes no difference to iRedMail, doing what you're doing would produce the same errors if it was installed on the bare metal.

the "virtual mailbox table" mentioned in the error message is the LDAP database. You won't have a 'root@derchris.eu' account in LDAP, so thats why you're getting an error message when you try to send mail as root.

5

Re: Problem sending mails with PHP

Mar 28 17:52:58 mail postfix/smtpd[3100]: NOQUEUE: reject: RCPT from derchris.eu[94.23.1.26] 553 5.7.1
<www-data@derchris.eu>: Sender address rejected: not logged in;
from=<www-data@derchris.eu> to=<frontpage@myserverstats.eu> proto=ESMTP helo=<derchris.eu>
Mar 28 17:52:58 mail postfix/smtpd[3100]: disconnect from derchris.eu[94.23.1.26]

Simple mail function like PHP MAIL doesn't work because there are no possibilities for smtp - authentication.
What you need is a PHP script that do this.
A good start is phpmailer.worxware.com/
Study the sections about smtp-auth and you'll understand this issue.

mbsouth

6

Re: Problem sending mails with PHP

ricklous wrote:

The fact its a virtual machine makes no difference to iRedMail, doing what you're doing would produce the same errors if it was installed on the bare metal.

the "virtual mailbox table" mentioned in the error message is the LDAP database. You won't have a 'root@derchris.eu' account in LDAP, so thats why you're getting an error message when you try to send mail as root.

As I said, mail from the mail server is working, and I have no root LDAP account for that either.
But there is the www account which has an alias for root.
I played around with the mynetworks parameter and added the Subnets for my IP addresses, but it doesn't help.

And forget about PHP, as I only used it as an example.

So I would need to create a dummy LDAP account, and add the root and www-data alias to it.
Like with the www account for the local root?