因此,我正在尝试按照此处的说明进行操作
http://www.9lessons.info/2011/07/send-mail-using-smtp-and-php.html
使用PHP使用我的gmail帐户发送电子邮件。但是,当我尝试发送测试电子邮件时,我在Web浏览器中收到以下消息:错误:无法连接到主机“ smtp.gmail.com”
这是我的两个文件(编辑了我的个人数据)
谢谢你的帮助
<?php
print "1";
require("smtp.php");
require("sasl.php"); //SASL authentication
$from="[email protected]";
$smtp=new smtp_class;
$smtp->host_name="smtp.gmail.com"; // Or IP address
$smtp->host_port=465;
$smtp->ssl=0;
$smtp->start_tls=1;
$smtp->localhost="localhost";
$smtp->direct_delivery=0;
$smtp->timeout=10;
$smtp->data_timeout=0;
$smtp->debug=1;
$smtp->html_debug=1;
$smtp->pop3_auth_host="";
$smtp->user="[email protected]"; // SMTP Username
$smtp->realm="";
$smtp->password="House22"; // SMTP Password
$smtp->workstation="";
$smtp->authentication_mechanism="";
print "3";
if($smtp->SendMessage(
$from,
array(
$to
),
array(
"From: $from",
"To: $to",
"Subject: $subject",
"Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z")
),
"$message"))
{
print "Message sent to $to OK.";
}
else
print "Cound not seend the message to $to.\nError: ".$smtp->error;
print "4";
?>
==============================
<?php
$to="[email protected]";
$fn="First Name";
$ln="Last Name";
$name=$fn.' '.$ln;
$from="[email protected]";
$subject = "Welcome to Website";
$message = "Dear $name,
Your Welcome Message.
Thanks
www.website.com
";
include('smtpwork.php');
?>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句