0

I use XAMPP and I've set my configuration based on this answer. Also here is my script:

$msg = "First line of text\nSecond line of text";
$msg = wordwrap($msg,70);
mail("someone@example.com@gmail.com","My subject",$msg);

When I execute it, the result is a blank page without any error. But I don't see any new email in that gmail's inbox. What's wrong and how can I find the problem?

Notes:

  • I tested that by multiple different gmail accounts.
  • I've set error_reporting(E_ALL); in my script to see any error. (which there isn't any one)
  • I'm from Iran (I'm not sure it is important)
  • I've tested SMTP port, and the port numbers are the same
Community
  • 1
  • 1
stack
  • 10,280
  • 19
  • 65
  • 117

2 Answers2

1

Its quite unlikely that remote mail servers will accept mail from your desktop for various reasons (IP reputation, dns black lists, SPF,etc).

The better approach would be to use phpmailer in your PHP app and then use that to connect and send from a proper SMTP server.

Over and above that, your local PC might not even have any MTA installed so it might just be that it can't send mail.

John Mc Murray
  • 363
  • 5
  • 17
1
  1. I hope you noticed that you wrote wrong email address
  2. Try this:
$to      = 'any@example.com';
$subject = 'subject';
$message = 'hey';
$headers = 'From: me@example.com' . "\r\n" .
'Reply-To: me@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
edd
  • 64
  • 8