【发布时间】:2015-08-28 10:22:52
【问题描述】:
if($sql)
{
require("master/PHPMailerAutoload.php");
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "mail.php.net";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "krajesh@php.net";
$mail->Password = "password";
$mail->SetFrom("krajesh@php.net");
$mail->Subject = "subject";
$mail->Body = "<table cellpadding='0' cellspacing='0' border='0' bgcolor='#006699' style='border:solid 10px #006699; width:550px;'>
<tr bgcolor='#006699' height='25'>
<td><img src='logo.jpg' border='0' width='200' height='60' /></td>
</tr>
<tr bgcolor='#FFFFFF'><td> </td></tr>
<tr bgcolor='#FFFFFF' height='30'>
<td valign='top' style='font-family:Arial; font-size:12px; line-height:18px; text-decoration:none; color:#000000; padding-left:20px;'><b> Login details from $website_name </b></td></tr>
<tr bgcolor='#FFFFFF' height='35'>
<td style='padding-left:20px; font-family:Arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>Username : $email </td>
</tr>
<tr bgcolor='#FFFFFF' height='35'>
<td style='padding-left:20px; font-family:Arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>Password :$password</td>
</tr>
<tr bgcolor='#FFFFFF' height='35'>
<td style='padding-left:20px; font-family:Arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'><a href='$website_url/index.php?activate=".$actvateid."' style='font-family:Arial; font-size:11px; font-weight:bold; text-decoration:none; color:#2200CC;'>Click Here</a> to activate your account</td>
</tr>
</table>";
$mail->AddAddress($email);
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "<script> window.location='index.php?sendsus'; </script>";
exit;
}
}
是我在代码中犯了错误还是我必须更改邮件功能本身? 邮件功能在本地工作,但不适用于 gmail.. 我也尝试过现场但 gmail 不工作..
【问题讨论】:
-
“不工作”绝不是一个充分的问题描述。
-
“邮件功能不适用于 gmail” -
$mail->Host = "mail.php.net";?你那里也有账户?krajesh@php.net哇。你会认为你可以解决自己的邮寄问题。 -
另外,这是stackoverflow.com/q/30664520的转贴
-
不,我只是举个例子,但我在个人网站上有帐户.. 名称为 krajesh@xyzexample.com