I have been trying to send email for registration, invitations and so on.
On local development, emails get sent. However once on the server no mails arrive.
I installed postfix. I was trying to setup a mail server but gave up. So currently, If I type in terminal
peter# mail [email protected]
the email arrives. However, this does not send email:
$res = mail('[email protected]', 'subj', 'bodddd');
not only that, but echoing $res
gives nothing. Neither true
nor false
.
What and how do i do to make it working?
thanx
Make sure the localhost mail server is configured Without one, PHP cannot send mail by default. You can overcome this by installing a basic mail server. For Windows you can use the free Mercury Mail. You can also use SMTP to send your emails.
to check if it is sending mail as intended; <? php $email = "[email protected]"; $subject = "Email Test"; $message = "this is a mail testing email function on server"; $sendMail = mail($email, $subject, $message); if($sendMail) { echo "Email Sent Successfully"; } else { echo "Mail Failed"; } ?>
After you have set tail on the log file try to send test email and in the other screen follow log file. After you have set tail on the log file try to send test email and in the other screen follow log file.
According to your comment above, it looks like your sendmail path is either wrong or commented out in your php.ini. It should be something like this:
sendmail_path = /usr/sbin/sendmail -t -i
If you're unsure where your sendmail binary resides, you may find it by using:
whereis sendmail
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With