Question

Configure Ubuntu 16.04 with LEMP to send emails for multiple websites

I am trying to configure my droplet running Ubuntu 16.04 with LEMP stack to send emails for the websites that I host for things like user registration, order status, etc.

I host several different and unrelated websites on the same server and the problem is that every configuration I have tried limits the @domain.com that the outbound emails are shown as being from. This is problematic for me as I need the email to be from the domain relative to the website that sent the email.

Perhaps I am not asking the correct question, but I haven’t found anything on how to accomplish this besides set up a complicated and dedicated mail server for the purpose, which is beyond my needs.


Submit an answer


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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Hi @joecasanova

You need to set the From and MAILFROM - you can do that from Nginx or PHP.

In Nginx you would add the following line to you location:

location ~ \.php$ {
  fastcgi_param PHP_VALUE 'sendmail_from=mail@domain.com';
  fastcgi_param PHP_VALUE 'sendmail_path=/usr/sbin/sendmail -t -f mail@domain.com -i ';
  ... other lines like fastcgi_pass ...
}

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.