i'm trying to create a code to send a email when a button is cliked, i fallowed this http://php.net/manual/en/function.mail.php to create the code and configured xamp by changing the code of php.ini, but it says that it cant connect to server:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP=smtp.gmail.com
; http://php.net/smtp-port
smtp_port=587
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = jun.atomo@gmail.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path sendmail_path ="\"C:\xampp\sendmail\sendmail.exe\" -t"
and senmail.ini:
smtp_server=smtp.gmail.com
smtp_port=587
auth_username=myemail@gmail.com
auth_password=myppass
i used this form to call the php script:
<form action="/prototype/views/email-script.php" method="post">
<p><input type="button" name="orcrequest" id="orcrequest" value="Enviar Orçamento" class="btn btn-default">
</form>
and this is the script:
<?php
if(isset($_POST['orcrequest']))
{
$to = 'jun_otomo@hotmail.com'; //can receive notification
$subject = 'the subject';
$message = 'hello';
$headers = 'From: jun.atomo@gmail.com' . "\r\n" .
'Reply-To: jun.atomo@gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
echo 'Email Sent.';
}
?>