0

php code:

<?php
$to       = 'vickee@hotmail.com';
$subject  = 'Testing sendmail.exe';
$message  = 'Hi, you just received an email using sendmail!';
$headers  = 'From: vignesh@gmail.com' . "\r\n" .
            'Reply-To: vignesh@gmail.com' . "\r\n" .
            'MIME-Version: 1.0' . "\r\n" .
            'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
            'X-Mailer: PHP/' . phpversion();
if(mail($to, $subject, $message, $headers))
    echo "Email sent";
else
    echo "Email sending failed";
?>

I have enabled second step verification in gmail. Is the prob due to that and I get "Email sent" when I run the php code. But there are no mails in the sent or recipient's inbox or junk folder. Are there any alternative methods? If so, please comment link for step by step procedure to send emails using the service.

EDIT:

I've setup the mailing part as instructed in http://arpanthakrar.blogspot.in/2013/06/send-email-from-localhostwamp-server.html

Please do let me know if there are anyother methods or changes to be made in this method.

Vignesh Anandakumar
  • 167
  • 1
  • 3
  • 12
  • As far as I know, you can't simply use the gmail servers to send an email without proper verification. For more on that, see question: http://stackoverflow.com/questions/712392/send-email-using-the-gmail-smtp-server-from-a-php-page – icecub May 17 '15 at 05:55

1 Answers1

0

Let me clearify a bit the "sending" of E-Mail:

$to       = 'vickee@hotmail.com';
...
$headers  = 'From: vignesh@gmail.com' . "\r\n" .

that means: send an email to "vickee, coming from vignesh"

That does not mean: "Use gmail to send an email to vickee"

Instead, PHP is using the local mailer to transport the mail. The mail is passed by your box, your providers MTA etc. to vickee's inbox at hotmail.

Your gmail account is not involved in to this. So looking in to the "sent" folder of your gmail account doesn't make sense, instead look in to vickees inbox.

Edit:

The "real" sending of the mail is done by the local MTA (Mail Transfer Agent). This is either sendmail, postfix or any other local service.

It's not part of or task of PHP.

PHP is only passing the mail to the configured MTA (usually locally).

Thus: you need to check your e-mail setup first!

Axel Amthor
  • 10,980
  • 1
  • 25
  • 44
  • I didn't get any mails in vickee's inbox too. How do I check if there are any errors with sending the mail? – Vignesh Anandakumar May 17 '15 at 06:19
  • The "real" sending of the mail is done by the local MTA (Mail Transfer Agent). This is either sendmail, postfix or any other local service. It's not part of or task of PHP. PHP is only passing the mail to the configured MTA (usually locally). Thus: you need to check your e-mail setup first! – Axel Amthor May 17 '15 at 06:22
  • Probably helpfull: http://stackoverflow.com/questions/14215943/mta-for-windows-to-use-for-php-sendmail – Axel Amthor May 17 '15 at 06:27