I’m trying to test if mail() is working
if (mail("info@ronisfineart.com", $subject, $message, $from)) {
echo "Thank you for filling out our form, please be patient and expect a response soon.";
} else {
echo "Error!";
}
Is this correct
I’m trying to test if mail() is working
if (mail("info@ronisfineart.com", $subject, $message, $from)) {
echo "Thank you for filling out our form, please be patient and expect a response soon.";
} else {
echo "Error!";
}
Is this correct
Yup.
The mail function typically doesn’t work if you’re on a local environment like xamp. The best thing to use is a library like Swiftmailer that provides alternative methods like smtp. Another solution is to set-up something like mailcatcher to mock mailing with mail() on a local environment that doesn’t have an email server on it (most). Otherwise the only realy way to test is a on a dev server or production (god forbid).
XAMPP has its own built in functionality to emulate mail() that saves the emails in files.
thanks
News to me I haven’t used xampp in several years. The last time I used it mail didn’t work.
mail doesn’t work to send emails - there is a facility that generates files containing the email content that allows you to test that the emails are generating correctly without actually sending any emails.
I found this a couple of years ago when I upgraded XAMPP. To the best of my knowledge the version I was using before that didn’t have it.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.