send mail with php

اشکان نصیرزاده

اشکان نصیرزاده

in php.ini
[mail function]
SMTP=smtp.gmail.com #ok
smtp_port=587 #ok
sendmail_from = my-gmail-id@gmail.com #sender google account
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" #sendmail.exe location

in sendmail.ini
[sendmail]
smtp_server=smtp.gmail.com #ok
smtp_port=587 #ok
error_logfile=error.log #ok
debug_logfile=debug.log #ok
auth_username=my-gmail-id@gmail.com #sender google account
auth_password=my-gmail-password #go to googe accound -> security tab -> get an app password
force_sender=my-gmail-id@gmail.com #sender google account
<?php
$to = "ashkan.nasirzadeh@gmail.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: webmaster@example.com" . "\r\n" .
    "CC: somebodyelse@example.com";

$returned = mail($to,$subject,$txt,$headers);