By brian
I configured my server to send SMTP (Gmail) via PHP using this tutorial. https://www.digitalocean.com/community/tutorials/how-to-use-gmail-or-yahoo-with-php-mail-function.
“For Gmail, use the following settings: account gmail tls on tls_certcheck off auth on host smtp.gmail.com port 587 user user1@gmail.com from user1@gmail.com password yourgmailPassw0rd This file can also have more than one account, just ensure that the “account” value is unique for each section. Save the file and use chmod to make this file readable only by the owner since it contains passwords. This step is mandatory because msmtp won’t run if the permissions are more than 600.”
It says this file can have more than one account so I have SMTP connections for 2 websites in the file. Both have a unique name and are configured to send with a custom from address (Gmail is able to send mail as these addresses, both have been tested). My problem is the server has one php.ini file where sendmail_path has a -a ACCOUNT1 flag. How can I configure sendmail_path to send from whichever account in my MSMTPRC file the from address belongs to?
Thank you for any advice.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
I found a solution that seems to be working correctly. My master php.ini sendmail_path has the MSMTP account for my main website. In the apache virtual host files (I had one for HTTP and one for HTTPS) for my second website I added this…
<Directory /var/www/domain.com> php_admin_value sendmail_path “Custom path for this domain only” </Directory>
I am now receiving mail from the correct account and seeing the message in my google workspace sent items under the correct user.
Hi @brianScubadiver,
To be honest, I’ve never had to find such a solution so far, what you found however is a really good solution, thank you for sharing it with the community!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.