0

I set up SMTP and smtp_port in php.ini file. And it's already there.

ini_set("SMTP","ssl://smtp.gmail.com");
ini_set("smtp_port","465");

Now, I am trying to send email by this:

$to      = 'email@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: email@example2.com' . "\r\n" .
        'Reply-To: email@example2.com' . "\r\n" .
        'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

ERROR:

Message: mail(): Failed to connect to mailserver at
                 "ssl://smtp.gmail.com" port 465, verify your "SMTP" and
                 "smtp_port" setting in php.ini or use ini_set()

Is this because of authentication problem? I don't want to use PHPMailer.

RNK
  • 5,582
  • 11
  • 65
  • 133
  • You may find some help here : http://stackoverflow.com/questions/16048347/send-email-using-gmail-smtp-server-through-php-mailer. – Anwar Oct 28 '14 at 16:21
  • thanks @Zeratops. But, I want to use default email functionality in PHP. Not `PHPMailer` – RNK Oct 28 '14 at 16:23

1 Answers1

0

you have to provide your gmail crendentials (login and password) to send mail via google smtp server
the php mail() function does not provide this feature
i advise you to download and use this PHP Project : https://github.com/Synchro/PHPMailer With it you can do everything : gmail credentials, attach files, write mail with HTML....
Hope that helps :)

Halayem Anis
  • 7,654
  • 2
  • 25
  • 45
  • 1
    That's an unofficial fork, better to use the official one https://github.com/PHPMailer/PHPMailer – rjdown Oct 28 '14 at 16:46