我正在尝试使用Xampp服务器从本地主机发送邮件。我按照下面的php.ini文件更改了php.ini和sendmail.ini文件
php.ini
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = myGmailId@gmail.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
sendmail.ini
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=myGmailId@gmail.com
auth_password=my-Gmail-Password
force_sender=myGmailId@gmail.com(optional)
mail.php
function db_forgot_password($args){
$to = $args['email'];
$query = "SELECT id FROM tbl_contact WHERE contact = '$to'";
$result = db_execute($query);
$contact_id = $result['0']['id'];
$query = "SELECT user FROM tbl_user_contact WHERE contact = '$contact_id'";
$result = db_execute($query);
$user_id = $result['0']['user'];
if(isset($user_id)){
$password = 'test123';
$subject = "Your Recovered Password";
$query = "SELECT id FROM tbl_login WHERE user = '$user_id'";
$result = db_execute($query);
$login_id = $result['0']['id'];
$query = "UPDATE tbl_login_para SET val = sha1('$password') where para = 1 AND login = '$login_id'";
$result = db_execute($query);
$message = "Please use this password to login " . $password;
if (mail($to,$subject,$message,"From : my@gmail.com")) {
echo "Email successfully sent to $to_email...";
} else {
echo "Email sending failed...";
}
succ_return($args);
}else{
warn(__FILE__, __FUNCTION__, __LINE__, 'email doesn\'t exist');
fail_return(ERR_UNAVAILABLE_USERS);
}
}
执行此API时,它会给我
<b>Warning</b>: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing
我该如何解决? 预先感谢
答案 0 :(得分:0)
从xampp服务器发送电子邮件时,您需要添加有效的电子邮件地址