I have searched for this question on stackoverflow and the rest of the internet, but I couldn't find the right answer. So this question is no duplicate.
I am using hMailServer to send a mail via WAMP, but it's simply not working. I configured hMailServer and the PHP.ini file completely and correctly to send e-mails via a gmail server, using this piece of code:
<?php
ini_set("SMTP", "smtp.gmail.com");
ini_set("smtp_port", 465);
$msg = "First line of text\nSecond line of text";
$msg = wordwrap($msg,70);
mail("design.clearmotion@gmail.com","My subject",$msg);
?>
In hMailServer I am using these settings:
Local host name: Localhost
Remote host name: smtp.gmail.com
IP port: 465
User name: design.clearmotion@gmail.com
Password: [password for my email]
Connection security: SSL/TLS
I have no idea what I'm doing wrong, because it gives me this error:
Warning: mail(): Failed to connect to mailserver at "smtp.gmail.com" port 465, verify your "SMTP" and "smtp_port"
UPDATE: Using this link: http://blog.techwheels.net/send-email-from-localhost-wamp-server-using-sendmail/, it now gives another error:
Warning: mail(): SMTP server response: 550 The address is not valid.
When I add this to the top of the code:
ini_set("SMTP","ssl:smtp.gmail.com" );
ini_set("smtp_port","465");
ini_set('sendmail_from', 'design.clearmotion@gmail.com');
It gives the same error as mentioned in the beginning.