1

I am trying to send the mail using the below code in localhost

I am trying to send using just inbuilt one and not just using php pear library or phpmailer

<?php
// the message
$msg = "First line of text\nSecond line of text";
// use wordwrap() if lines are longer than 70 characters
$msg = wordwrap($msg,70);
// send email
$headers = "From: xxx@gmail.com";
try {
    mail("xxx@gmail.com","My subject",$msg, $headers);
echo "mail send";
}
catch(Exception $e) {
    var_dump($e);
}
exit;

Eventhough, i have changed in my php.ini and sendmail.ini, the mail function is not working.

where i am doing wrong.

sendmail.ini

smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=auto
error_logfile=error.log
auth_username=xxx@gmail.com
auth_password=xxx

php.ini

[mail function]

SMTP = smtp.gmail.com
smtp_port = 587
sendmail_from = xxx@gmail.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

can anyone help where i am wrong..

When i am using phpmailer code, i don have any problem, am getting my email.

user3929758
  • 233
  • 2
  • 3
  • 15

0 Answers0