Question

Wrong domain when sending mails from PHP, how to fix it?

I had to rename my droplet to send mails, and it was renamed to my domain name, because I needed to be fqdn. When sending mails using php mail() function, it worked just fine, and the mails were received from something@mydomain.com, but then I turned off my droplet, resized it, turned it on again, and now my mails that are sent using php mail are being received from something@myolddropletname that is not even a domain, so I don’t know how to fix it.

My mails look something like this:

https://ibb.co/D94XJ5X

Show comments

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

Just had to update my /etc/mailname file

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello, @Dantael

Would you mind checking that the hostname of the server is not changed back to what it was before your original change? I’m asking because you’ve mentioned that you’ve renamed the droplet in the past and now after the reboot this is no longer working for you.

In order to change the droplet’s name you can follow these steps:

  1. Login to the Digital Ocean Control Panel
  2. Click the droplet you want to rename
  3. Then, on the droplet detail window, click on the name of your droplet (you wouldn’t know you could)
  4. Change the name in the entry field and click the check mark

Make sure you also edit your droplet’s hostname internally as well. Update /etc/hostname and /etc/hosts and then reboot the droplet.

Hope that this helps!

Regards, Alex