Reputation: 21
I ran this PHP script in a dedicated server (OVH Kimsufi, Debian 6.0 stable).
<?php
$msg = "coucou les amis";
$sub = "test";
$head = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n";
echo mail("[email protected]", $msg, $msg, $head);
?>
Mail returned 1 but the email was never received... How to fix it ?
Upvotes: 1
Views: 3741
Reputation: 21
The problem was the exim ( = sendmail) default config. It do not allow direct SMTP sending (only local).
# dpkg-reconfigure exim4-config
Upvotes: 1
Reputation: 1629
After fixing the problem described in holodoc's post, you shall consider getting rid of mail()
, which is unreliable.
Upvotes: 0
Reputation: 61783
There is a lot that can wrong. Are you using Sendmail for example. Maybe you should inspect those logs, which probably are located at.
cat /var/log/mail.log
Or maybe your email does get send, but gets delivered in the spam folder?
I would instead advice you to outsource sending out emails using for example Sendgrid. Sendgrid is free when you sent less than 200 emails daily.
Upvotes: 1
Reputation:
You made a mistake and used $msg
in place of $sub
where subject was required as argument to the mail()
function.
$msg = "coucou les amis";
$sub = "test";
$head = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n";
echo mail("[email protected]", $sub, $msg, $head);
Upvotes: 0
Reputation: 43
It depends upon your server whether your server allow you to send mail using php or not
Upvotes: 1
Reputation: 174967
It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.
PHP has sent the message. Whether it reached its destination or not is beyond PHP's control.
Upvotes: 2