我尝试在PHP邮件程序中更改来自Root用户
require 'mailer/PHPMailerAutoload.php';
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = 'localhost';
$mail->SMTPAuth = true;
$mail->Username = '';
$mail->Password = '';
$mail->SMTPSecure = 'tls';
$mail->Port = 25;
try{ $mail->addAddress('user@gmail.com', 'Poweronups');
$mail->addReplyTo($_POST['email'], 'Information');
$mail->SetFrom('info@user.com', 'user');
$mail->isHTML(false);
$mail->Subject = 'Poweron Contact Details';
$mail->Body = "Name : ".$_POST['full_name']. "\r\n" .
"Email : ".$_POST['email']. "\r\n" .
"Website : ".$_POST['website']. "\r\n" .
"Message : ".$_POST['message'];
if(!$mail->send()) {
$_SESSION['contact_alert'] = 'Message could not be sent.';
$_SESSION['contact_alert'] = 'Mailer Error: ' . $mail->ErrorInfo;
} else {
$_SESSION['contact_alert'] = 'Thank you !'. "\r\n" .
'Your message has been successfully sent . We will contact you very soon !';
$mail->addAddress($_POST['email'], 'user');
$mail->addReplyTo('info@user.com', 'Information');
$mail->isHTML(false);
$mail->Subject = 'Poweron Contact Details';
$mail->Body = "Hai ".$_POST['full_name'].". Your Contact Details Has Been Sent Successfully.The Contact Team Will Get Back To You ASAP.";
$mail->send();
}
} catch (phpmailerException $e) {
echo $e->getMessage();
在这种情况下,当我添加$ mail-> SetFrom('info @ user.com','Poweronups'); 并尝试发送邮件页面转到空白页面。没有这个它将完美地工作。但它显示root用户。