I'm working on a project that requires a specific button on a page to send an email out. It works as a sort of reminder function for the client, so when it's clicked they will receive an email to let them know that they need to check something.
I think I almost have it working, but for some reason it keeps failing instead of actually sending the email out. It could be the way that I have it set out, but I have tried using the "action" on the form to run the php through a seperate file, but it still does the same. I currently have it like this:
<form method='post'>
<button type='submit' name='reminder_btn'>
Send Reminder
</button>
</form>
<?php
if(isset($_POST['reminder_btn'])){
$email = "hello@email.com";
$subject = "Company Reminder";
$message = "
<html>
<head>
<title>Company</title>
</head>
<body>
<p>Hello!</p>
<p>You have a reminder. Please check the website.</p>
<p>Thanks!</p>
</body>
</html>
";
$mailheaders[] = "From: Company Name";
$mailheaders[] = "Reply-To: hello@email.com";
$mailheaders[] = "MIME-Version: 1.0";
$mailheaders[] = "Content-type: text/html; charset=iso-8859-1";
if(mail($email, $subject, $message, implode("\r\n", $mailheaders))) {
echo "Reminder sent.";
} else {
echo "Something has gone wrong. Try again.";
}
}
I'm sure I've had it working like this on something else before, but all I'm getting is the "Something has gone wrong" message each time.
Obviously I've got something wrong but I don't understand what it is, so any assistance here would be much appreciated.