我尝试使用localhost XAMPP服务器将电子邮件从我的Gmail帐户发送到另一个Gmail帐户,但是它不起作用。
用于发送电子邮件的php代码:
<?php
if (isset($_POST['send'])) {
$mailto = $_POST['mail_to'];
$mailSub = $_POST['mail_sub'];
$mailMsg = $_POST['mail_msg'];
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'From: Faisal Jatt <faisaljatt369@gmail.com>' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
if(mail($mailto, $mailSub, $mailMsg, $headers)){
echo "Mail Sent";
}
else{
echo "Mail didnot Send";
}
}
?>
sendmail.ini
smtp_port=465
smtp_ssl=tls
error_logfile=error.log
debug_logfile=debug.log
auth_username=faisaljatt369@gmail.com
auth_password=mygamilpassword
pop3_server=
pop3_username=
pop3_password=
force_sender=faisaljatt369@gmail.com
force_recipient=
hostname=localhost
php.ini
SMTP=smtp.gmail.com
smtp_port=465
sendmail_from = faisaljatt369@gmail.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
extension=php_openssl.dll