I have made a little web application project that has a contact.php page with a form to send emails. However, emails are sent neither by my localhost on my PC before uploading to the EC2, nor by the contact form on the webpage. I don't get any error messages, the emails simply don't send.
if(isset($_POST['submit'])) {
$to = "myemailaddress@mydomain.com";
$subject = wordwrap($_POST['subject'], 70);
$body = $_POST['body'];
$header = "From: " .$_POST['email'];
// send email
mail($to, $subject, $body, $headers);
}
What I need is for the EC2-hosted web contact form to sent emails through a Japanese mail server called onamae.com, and I can deal with reading and replying to the mails in Thunderbird later.
I tried watching Youtube tutorials and reading many articles, but I'm confused about what to do. Different sources offer different answers to the problem. Should I:
- try to change the php.ini and sendmail.ini files through the Linux command line in Putty?
- Install sendmail on the EC2?
- Set up receiving emails using Amazon SES or Amazon Workmail?
- Install PhpMailer on the EC2 instance and try using that?
Most of the other resources I find don't seem to have my exact problem. But I have very limited experience so maybe there's an article or video out that that DOES explain how to solve my problem and I just couldn't recognize it. Please help this noob developer out, it would be highly appreciated. Cheers.