I've launch an AWS LightSail Bitnami LAMP instance. client side simple html form
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple Form</title>
</head>
<body>
<form action="contact2.php" method="post">
<input name="firstName" placeholder="firstName" type="text" size="30" />
<input name="lastName" placeholder="lastName" type="text" size="30" />
<input name="email" placeholder="email" type="text" size="30" />
<input name="phone" placeholder="phone" type="text" size="30" />
<input name="subject" placeholder="subject" type="text" size="30" />
<textarea name="message" placeholder="message" type="text" size="30"></textarea>
<input name="submit" type="submit" value="Send This">
</form>
</body>
</html>
backend php code
<?php
if (!empty($_POST)) {
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$toEmail = 'mymail@mydomain.com';
$emailSubject = 'test';
$headers = ['From' => $email, 'Reply-To' => $email, 'Content-type' => 'text/html; charset=iso-8859-1'];
$body = "Name: $firstName $lastName .\n".
"Phone: $phone.\n".
"Message: $message.\n";
mail($toEmail, $emailSubject, $body, $headers);
}
?>
Calling the contact.php returns with status 200 but the email does not get sent.
The same exact code on Heruku works perfect and the email is received