Different msmtp accounts for PHP's mail() via FastCGI
Added by ashiso almost 14 years ago
System¶
# uname -a Linux hostname 2.6.26-2-amd64 #1 SMP Sun Jun 20 20:16:30 UTC 2010 x86_64 GNU/Linux # cat /etc/issue Debian GNU/Linux 5.0 # lighttpd -v lighttpd-1.4.19 (ssl) - a light and fast webserver Build-Date: Jan 11 2011 23:53:03
Goal¶
Each vHost should have a different msmtp account assigned to it. Users will make use of PHP scripts that utilize the mail() function. Regardless of their input for the sender parameter, msmtp should take the assigned account information to send the email via the right smtp server assigned to the vHost.
Problem¶
The config pasted above does not work.
With that config in place, requesting a PHP file (even one with just echo "test";) fails. There's no timeout, at least not under 5 minutes.
Surprisingly the following works "manually":
# cat testmail.php <?php // test mail to myself mail("alex.schmidt89@gmail.com", "Test Email to myself!", "Just a test!\n"); # /usr/local/bin/php-cgi -d sendmail_path='/usr/bin/msmtp -t -i --account=myaccount' -f testmail.php
The right account get's assigned to it, even though the php.ini uses the default msmtp acount (which is different from "myacount" of course).
I'm guessing that the assignment in the form of
"bin-path" => "/usr/local/bin/php-cgi -d sendmail_path=/usr/bin/msmtp -t -i --account=individual.com"
is a syntax error. That doesn't work either:
"bin-path" => "/usr/local/bin/php-cgi -d sendmail_path='/usr/bin/msmtp -t -i --account=individual.com'"
(Single-quotes around the sendmail_path parameter).
Question¶
If it's a simple syntax error: How can it be fixed?
If it's a more serious matter:
I'd like to keep the whole thing as simple as possible. Spawning FCGI instances manually and assigning their sockets to the vHosts is not what I like to do (as described here). Also, after googling a bit I found out that assigning a different php.ini for each vHost works fine:
fastcgi.server = ( ".php" => (( "bin-path" => "/usr/bin/php-cgi -c /home/lighttpd/cyberciti.biz/php.ini", "socket" => "/home/lighttpd/cyberciti.biz/php-cgi.socket", )) )
But all my vHosts share the same php.ini, making a bunch of different configs for each vHost just for the sake of the correct msmtp account is a bit over the top and makes maintaining multiple servers harder. So the question is, how can I make it work as simple as possible?