Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP mail does not get sent, how do I debug?

Tags:

php

email

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

like image 499
mgPePe Avatar asked Oct 27 '11 07:10

mgPePe


People also ask

Why is PHP not sending email?

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.

How do you check PHP mail () is working?

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"; } ?>

How do I debug my email server?

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.


1 Answers

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
like image 147
Oldskool Avatar answered Nov 15 '22 18:11

Oldskool