I have a static index.html running on a nginx server. I have a simple form element that takes in a user’s contact details and sends a POST request to inc/sendEmail.php. I haven’t set up any mail system on my droplet so maybe that’s why it’s not sending any email? Everything code wise looks pretty solid but I’m not sure where to start to get my code to start working for me. I’m running Ubuntu 18.04 and NGINX. When I hit submit I get a ‘200 OK’ response from jquery sending the post to the PHP script but that’s as far as it goes and then it throws my error something went wrong. Any advice is appreciated.
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!
Greetings!
Thank you for posting this question here. To wrap up this post with a dedicated answer, it seems that you were able to resolve this by comparing the script at this URL to your code:
https://www.arclab.com/en/kb/php/how-to-test-and-fix-php-mail-function.html
That is a good reference, for anyone experiencing similar. However, it is also worth noting that there are a lot of complexities to sending email that did not exist several years ago. For that reason, one should also check their MTA logs to see if they can find out what happened when they sent an email. For example, if I’m sending an email to “jarland@gmail.com” and using Postfix on the droplet, I might run this to check the logs:
grep "jarland@gmail.com" /var/log/mail.log
Some more information on debugging Postfix logs (as it is the most common MTA, to the best of my knowledge):
https://easyengine.io/tutorials/mail/postfix-debugging
Jarland
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.