[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [msmtp-users] 2 domains with msmtp from one PHP?



Am 15.02.2012 21:53, schrieb Martin Lambers:
On Wed, 15 Feb 2012 20:43:55 +0100, A. Bischof wrote:
Am 15.02.2012 19:18, schrieb Martin Lambers:
On Wed, 15 Feb 2012 19:02:32 +0100, A. Bischof wrote:
I have a server running php (with lighttpd, not apache) for
different domains. I have google mail accounts for the domains.
Now I must send mails from domain one.de with another sender then
domain two.de

How can this be achieved?
...
-----------
defaults
host ...
tls ...
log ...

account one
from webmaster@...280...
user webmaster@...280...
password ***

account two
from webmaster@...281...
user webmaster@...281...
password ***
------------

Now you have multiple options:
- if you can use different php.ini files for your domains, you can
     choose an account with the --account option.
- if your php scripts set a 'From' header in each mail depending
on the domain (e.g. 'From: webmaster@...280...' and 'From:
webmaster@...281...'), you can use the --read-envelope-from option of
msmtp. Then msmtp reads this From address and automatically
chooses the account that has a matching 'from' command.

Martin,

I can't get it working, would you mind having a look what's wrong?

I call from cgi/php.ini with --read-envelope-from:
sendmail_path = "/usr/bin/msmtp -t -i -d --read-envelope-from -C
/etc/msmtprc-www-data-multidomain"

(or should I put "read-envelope-from on" in the config file under
defaults?

My config files belongs to www-data and now looks like you suggested:
# cat msmtprc-www-data-multidomain
defaults
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile /var/log/msmtp.log
auto_from off
host smtp.gmail.com
port 587
timeout 30
auth on

account rheinsinn
#auto_from off
#read-envelope-from on
from webmaster@...282...
#maildomain rheinsinn.de
user webmaster@...282...
password ****


account coaching-evaluationen
#auto_from off
#read-envelope-from on
from webmaster@...283...
#maildomain coaching-evaluationen.de
user webmaster@...283...
password ****

The webscript tells me that the mail function couldn't initialized -
if I switch back to my old config it works.

Any clues?

What gets logged in /var/tmp/msmtp.log? What are the error messages?

unfortunatly nothing, neither in /var/log/msmtp.log nor in php/error.log or lighttpd/error.log

Successfull usage is debuged like this:
Feb 15 20:37:02 host=smtp.gmail.com tls=on auth=on user=webmaster@...282... from=webmaster@...283... recipients=andre.bischof@...282... mailsize=5965 smtpstatus=250 smtpmsg='250 2.0.0 OK 1329334595 w15sm8568001bku.0' exitcode=EX_OK

I assume the problem happens before, thus msmtp is not executed by phps mail function, therefore the error message by the php script (mail function couldn't get initialized).

Is there a way to test the msmtp config from the commandline?

Cheers
Frisco