[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [msmtp-users] 2 domains with msmtp from one PHP?
Hi!
On Tue, 14 Feb 2012 14:25:29 +0100, A. Bischof wrote:
> I have msmtp running for some time and like it alot. But now I
> encountered something which I'm not able to solve by myself - maybe
> you can help me out?
>
> 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?
>
> I have php (cgi) configured with an php.ini entry to run msmtp:
> sendmail_path =sendmail_path = "/usr/bin/msmtp -t -i -d -C
> /etc/msmtprc-www-data" "/usr/bin/msmtp -t -i -d
> -C /etc/msmtprc-www-data"
>
> In msmtprc-www-data I have an default account:
>
> # cat /etc/msmtprc-www-data
> account default
> host smtp.gmail.com
> port 587
> timeout 30
> auth on
> user webmaster@...280...
> password ****
> auto_from off
> from webmaster@...280...
> maildomain one.de
> tls on
> tls_starttls on
> tls_trust_file /etc/ssl/certs/ca-certificates.crt
> logfile /var/log/msmtp.log
>
> Should I use two different accounts with different maildomains? It
> would be great if one could send me the lines I should put in or
> point me to some kind of howto or similar to solve this problem.
>
> Any help is greatly appreciated.
The 'maildomain' command is only used when 'auto_from' is on, to
construct an envelope from address. But you already set this with the
'from' command.
You should probably define two accounts in your msmtp configuration
file. Since they will be very similar, you can put all common
settings in a 'defaults' section, and put only the differing commands
into account sections:
-----------
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