For some reason, my PHP mail is not sending.
This is my script:
$tom = $email;
$subjm = 'Company: Forgotten password';
$msgm = "-- DO NOT REPLY TO THIS EMAIL --\nHi,\nYou have forgotten your password.\nHereby we want to supply a you a new one.\nNew password: $pass";
$msgm = wordwrap($msgm, 70);
$mail_sent = @mail($tom, $subjm, $msgm);
echo "$tom <br /> $subjm <br /> $msgm";
echo $mail_sent ? "Mail sent" : "Mail failed";
echo "<br />Your new password has been sent to the email you've signed up with.<br />If you can't find the email, please wait a few minutes or check your spam box.";
However, it always gives me “Mail failed”, and I do not see it in mailbox. I’ve checked if the correct emailadress was being produced by my script ($email), and it was. So I’m kinda lost as to why it will not send.
As a follow up to the comments, I contacted my webhost. They tell me I can’t send emails using the mail function to recipients that are not on the domain. I’m resolving the issue with them.
Edit:
I needed to add a From:, and the emailadress of From should be a @mydomain.com address, not external. It works now.