带有Gmail SMTP设置的PHPMailer
我正在尝试使用PHPMailer脚本和我的Gmail帐户创建一个联系人表单。我已经尝试了这两种方法代码>与带有Gmail SMTP设置的PHPMailer,smtp,gmail,phpmailer,Smtp,Gmail,Phpmailer,我正在尝试使用PHPMailer脚本和我的Gmail帐户创建一个联系人表单。我已经尝试了这两种方法与$Mail->Port=465和$Mail->SMTPSecure=“tls”与$Mail->Port=587。我还在想: SMTP->错误:无法连接到服务器:找不到套接字传输“ssl”-配置PHP时是否忘记启用它?(43443944) SMTP错误:无法连接到SMTP主机。 $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; $
$Mail->Port=465代码>和$Mail->SMTPSecure=“tls”代码>与$Mail->Port=587代码>。我还在想:
SMTP->错误:无法连接到服务器:找不到套接字传输“ssl”-配置PHP时是否忘记启用它?(43443944)
SMTP错误:无法连接到SMTP主机。
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$MessageTEXT = 'This is the alternate to HTML' ;
function SendMail( $ToEmail, $MessageHTML, $MessageTEXT ) {
require_once ( 'class.phpmailer.php' ); // Add the path as appropriate
$Mail = new PHPMailer();
$Mail->IsSMTP(); // Use SMTP
$Mail->Host = "smtp.gmail.com"; // Sets SMTP server
$Mail->SMTPDebug = 2; // 2 to enable SMTP debug information
$Mail->SMTPAuth = TRUE; // enable SMTP authentication
$Mail->SMTPSecure = "ssl"; //Secure conection
$Mail->Port = 465; // set the SMTP port
$Mail->Username = 'thefloatingorange06@gmail.com'; // SMTP account username
$Mail->Password = 'password'; // SMTP account password
$Mail->Priority = 1; // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low)
$Mail->CharSet = 'UTF-8';
$Mail->Encoding = '8bit';
$Mail->Subject = 'Test Email Using Gmail';
$Mail->ContentType = 'text/html; charset=utf-8\r\n';
$Mail->From = 'jackiesylee@gmail.com';
$Mail->FromName = 'GMail Test';
$Mail->WordWrap = 900; // RFC 2822 Compliant for Max 998 characters per line
$Mail->AddAddress( $ToEmail ); // To:
$Mail->isHTML( TRUE );
$Mail->Body = '$name $email $message';
$Mail->AltBody = $MessageTEXT;
$Mail->Send();
$Mail->SmtpClose();
if ( $Mail->IsError() ) { // ADDED - This error checking was missing
return FALSE;
}
else {
return TRUE;
}
}
$ToEmail = 'thefloatingorange06@gmail.com';
$ToName = 'Jackie';
$Send = SendMail( $ToEmail, $name, $email, $message, $MessageTEXT );
if ( $Send ) {
echo "<h2> Sent OK</h2>";
}
else {
echo "<h2> ERROR</h2>";
}
die;
?>
下面的代码是我正在试用的代码。还有什么我可以尝试的,或者其他的帖子可能有解决办法吗?先谢谢你。
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$MessageTEXT = 'This is the alternate to HTML' ;
function SendMail( $ToEmail, $MessageHTML, $MessageTEXT ) {
require_once ( 'class.phpmailer.php' ); // Add the path as appropriate
$Mail = new PHPMailer();
$Mail->IsSMTP(); // Use SMTP
$Mail->Host = "smtp.gmail.com"; // Sets SMTP server
$Mail->SMTPDebug = 2; // 2 to enable SMTP debug information
$Mail->SMTPAuth = TRUE; // enable SMTP authentication
$Mail->SMTPSecure = "ssl"; //Secure conection
$Mail->Port = 465; // set the SMTP port
$Mail->Username = 'thefloatingorange06@gmail.com'; // SMTP account username
$Mail->Password = 'password'; // SMTP account password
$Mail->Priority = 1; // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low)
$Mail->CharSet = 'UTF-8';
$Mail->Encoding = '8bit';
$Mail->Subject = 'Test Email Using Gmail';
$Mail->ContentType = 'text/html; charset=utf-8\r\n';
$Mail->From = 'jackiesylee@gmail.com';
$Mail->FromName = 'GMail Test';
$Mail->WordWrap = 900; // RFC 2822 Compliant for Max 998 characters per line
$Mail->AddAddress( $ToEmail ); // To:
$Mail->isHTML( TRUE );
$Mail->Body = '$name $email $message';
$Mail->AltBody = $MessageTEXT;
$Mail->Send();
$Mail->SmtpClose();
if ( $Mail->IsError() ) { // ADDED - This error checking was missing
return FALSE;
}
else {
return TRUE;
}
}
$ToEmail = 'thefloatingorange06@gmail.com';
$ToName = 'Jackie';
$Send = SendMail( $ToEmail, $name, $email, $message, $MessageTEXT );
if ( $Send ) {
echo "<h2> Sent OK</h2>";
}
else {
echo "<h2> ERROR</h2>";
}
die;
?>
$name=$\u请求['name'];
$email=$_请求['email'];
$message=$_请求['message'];
$MessageTEXT='这是HTML的替代项';
函数SendMail($ToEmail、$MessageHTML、$MessageTEXT){
require_once('class.phpmailer.php');//根据需要添加路径
$Mail=new PHPMailer();
$Mail->IsSMTP();//使用SMTP
$Mail->Host=“smtp.gmail.com”;//设置smtp服务器
$Mail->SMTPDebug=2;//2以启用SMTP调试信息
$Mail->SMTPAuth=TRUE;//启用SMTP身份验证
$Mail->SMTPSecure=“ssl”;//安全连接
$Mail->Port=465;//设置SMTP端口
$Mail->Username=thefloatingorange06@gmail.com“;//SMTP帐户用户名
$Mail->Password='Password';//SMTP帐户密码
$Mail->Priority=1;//最高优先级-电子邮件优先级(1=高,3=正常,5=低)
$Mail->CharSet='UTF-8';
$Mail->Encoding='8bit';
$Mail->Subject='使用Gmail测试电子邮件';
$Mail->ContentType='text/html;charset=utf-8\r\n';
$Mail->Fromjackiesylee@gmail.com';
$Mail->FromName='gmailtest';
$Mail->WordWrap=900;//符合RFC 2822,每行最多998个字符
$Mail->AddAddress($ToEmail);//收件人:
$Mail->isHTML(TRUE);
$Mail->Body='$name$email$message';
$Mail->AltBody=$MessageTEXT;
$Mail->Send();
$Mail->SmtpClose();
如果($Mail->IsError()){//已添加-此错误检查丢失
返回FALSE;
}
否则{
返回TRUE;
}
}
$ToEmail=thefloatingorange06@gmail.com';
$ToName='Jackie';
$Send=SendMail($ToEmail,$name,$email,$message,$MessageTEXT);
如果($Send){
回显“发送正常”;
}
否则{
回声“错误”;
}
死亡
?>
以下代码对我有效:
$mail->IsSMTP(); // Use SMTP
$mail->Host = "smtp.gmail.com"; // Sets SMTP server
$mail->SMTPDebug = 2; // 2 to enable SMTP debug information
$mail->SMTPAuth = TRUE; // enable SMTP authentication
$mail->SMTPSecure = "tls"; //Secure conection
$mail->Port = 587; // set the SMTP port
$mail->Username = 'example1@gmail.com'; // SMTP account username
$mail->Password = 'password'; // SMTP account password
$mail->Priority = 1; // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low)
$mail->Encoding = '8bit';
$mail->Subject = 'Test Email Using Gmail';
$mail->ContentType = 'text/html; charset=utf-8\r\n';
$mail->From = 'example@dominio.com';
$mail->FromName = 'GMail Test';
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->IsHTML(true);
您是否希望我们相信您确实已阅读错误消息?如果是,在哪里以及如何启用SSL?是的,这是我在输入$Mail->Port=465
和$Mail->SMTPSecure=“SSL”
时出现的错误消息。我不确定您在哪里以及如何启用SSL,但如果这是我需要做的事情,您能为我指出正确的方向吗?快速谷歌搜索出现了