用于 SMTP 的 PHPMailer 将邮件发送到收件箱,但邮件地址无效
PHPMailer for SMTP sends mail to inbox but from invalid mail address
需要帮助!!!
我在当前项目中使用 php 邮件程序。它工作成功,在成功发送邮件到另一端后,它说邮件来自 smtp 服务器帐户,而不是来自我在这里使用的 $from-
$to ="muradautorun@gmail.com";
$from ="tanvir_cse0906@yahoo.com";
我的 smtp 服务器代码在这里..
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = "muradautorun";
$mail->Password = ""; //my passsword here
这是我的完整代码-
$to ="muradautorun@gmail.com";
$from ="tanvir_cse0906@yahoo.com";
$from_name="S.M. Murad Hasan Tanvir";
$subject="A sending mail code";
$body ="This is a sending email code, the file attach here is about the coding.";
//here i use gmail as a smtp server
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = "muradautorun";
$mail->Password = ""; //my passsword here
$mail->SetFrom($from, $from_name);
$mail->addAttachment('emailSend.php'); // Add attachment(just the file url)
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to);
if(!$mail->Send()) {
echo 'Mail error: '.$mail->ErrorInfo;
}
else {
echo 'Message sent!';
}
?>
我哪里做错了我找不到请帮帮我...
提前致谢。
您需要先在您的 "muradautorun" gmail 帐户上允许以 "tanvir_cse0906@yahoo.com" 的身份发送邮件。
您可以按照以下步骤进行操作:
- 使用 "muradautorun"
登录
- 点击右上角的齿轮,选择"Settings"
- 单击 "Accounts and Import" 选项卡
- 单击 "Send mail as" 部分中的 link "Add another email address you own",然后按照说明进行操作。
需要帮助!!! 我在当前项目中使用 php 邮件程序。它工作成功,在成功发送邮件到另一端后,它说邮件来自 smtp 服务器帐户,而不是来自我在这里使用的 $from-
$to ="muradautorun@gmail.com";
$from ="tanvir_cse0906@yahoo.com";
我的 smtp 服务器代码在这里..
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = "muradautorun";
$mail->Password = ""; //my passsword here
这是我的完整代码-
$to ="muradautorun@gmail.com";
$from ="tanvir_cse0906@yahoo.com";
$from_name="S.M. Murad Hasan Tanvir";
$subject="A sending mail code";
$body ="This is a sending email code, the file attach here is about the coding.";
//here i use gmail as a smtp server
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = "muradautorun";
$mail->Password = ""; //my passsword here
$mail->SetFrom($from, $from_name);
$mail->addAttachment('emailSend.php'); // Add attachment(just the file url)
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to);
if(!$mail->Send()) {
echo 'Mail error: '.$mail->ErrorInfo;
}
else {
echo 'Message sent!';
}
?>
我哪里做错了我找不到请帮帮我... 提前致谢。
您需要先在您的 "muradautorun" gmail 帐户上允许以 "tanvir_cse0906@yahoo.com" 的身份发送邮件。
您可以按照以下步骤进行操作:
- 使用 "muradautorun" 登录
- 点击右上角的齿轮,选择"Settings"
- 单击 "Accounts and Import" 选项卡
- 单击 "Send mail as" 部分中的 link "Add another email address you own",然后按照说明进行操作。