How was Postfix setup?
PHP relies heavily on how you've configured sendmail. You can set From, Reply-To, and Return-Path, but unless your mail server is properly configured, it'll still show as being sent by whatever user you are logged in as.
For example, on a Droplet I have deployed right now, the only configuration I've setup for sendmail is what was provided when I ran
sudo apt-get -y install postfix, nothing more. As a result, when mail is sent using
mail(), I see that the message was actually sent by
dev.localdomain shows is because a hostname has yet to be set for the Droplet, which you need to do. This can be done by using the
hostname command and then adding whatever you wish to use as a hostname as an option.
For example, running:
Sets my hostname and changes the sent by header I see when viewing the mail to:
That being said, when it comes to running a mail server, there's actually a lot more involvement than just installing and configuring Postfix to send mail. If you want e-mail to stay out of the SPAM box, you need to be setup to use SPF, DKIM, and potentially even DMARC (which can be setup with Postfix, but it's a bit time consuming to do so).
You also need to have proper reverse DNS setup. That can only be setup by setting the name of your Droplet to the hostname you set using the command above.
When you created the Droplet, you remember the input box at the end? That's where you can set the name of your droplet to match that of your hostname. You can optionally login to the DigitalOcean CP, click on the name of the droplet you want to modify, and then click on the droplet name and you'll see an inline-edit input pop up. You can use that to change your droplets' name after deployment.
Why does the name matter? DigitalOcean automatically creates your reverse DNS (i.e. PTR) records for you when you deploy a droplet. If the droplet name and the hostname of your droplet do not match, it won't be considered valid when a lookup is performed.
All that being said, if you're using WordPress and don't want to go through the hassle of all the above, the best thing to do would be to use an external e-mail service such as Mailgun or SendGrid, both of which offer plugins to integrate with their services.
Using an external mail service removes the need for you to rely on properly setting up and configuring a working mail server on your end.