发送邮件头作为 auth_username insteall 声明的变量

问题描述

大家好,只是想知道为什么我的代码标题显示为 auth_username 而不是声明的变量

function sanitize_my_email($field) {
    $field = filter_var($field,FILTER_SANITIZE_EMAIL);
    if (filter_var($field,FILTER_VALIDATE_EMAIL)) {
        return true;
    } else {
        return false;
    }
}

$to_email = '[email protected]';
$from = '[email protected]';

$subject = 'Testing PHP Mail';
$message = 'This mail is sent using the PHP mail ';
$headers = "" .
           "Reply-To:" . $from . "\r\n" .
           "From:" . $from . "\r\n" .
           "X-Mailer: PHP/" . PHPversion();
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 

//check if the email address is invalid $secure_check
$secure_check = sanitize_my_email($to_email);
if ($secure_check == false) {
    echo "Invalid input";
} else { //send email 
    mail($to_email,$subject,$message,$headers);
    echo "This email is sent using PHP Mail";
}

这是我的输出

from:   [email protected] // this one is my auth_username instead of [email protected]
reply-to:   [email protected]
to: [email protected]
date:   Mar 9,2021,12:56 PM
subject:    Testing PHP Mail

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)