PHP 示例代码: 使用 Gmail 或 Google Apps 的 SMTP Server 在线发送邮件
来源:互联网 发布:知乎 周杰伦与王力宏 编辑:程序博客网 时间:2024/04/30 03:59
TIPS:
Gmail现在的smtp和pop3都是ssl加密的
Step1. php openssl module(extension) support
Step2. download phpmailer library
Step3. change code 'class.phpmailer.php' and 'class.smtp.php'
phpmailer和smtp里加property Is_SSL(var $Is_SSL = false;)
phpmailer里的SmtpConnect方法里传递给smtp对象($this->smtp-> Is_SSL = $this-> Is_SSL ;)
smtp里的Connect方法在fsockopen调用前加上
if($this->is_ssl){ $host = 'ssl://'.$host; }
写个例子,看看ok否
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Encoding = $this->encoding;
$mail->Host = $this->***; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = $this->***; // SMTP username
$mail->Password = $this->***; // SMTP password
$mail->From = $this->***;
$mail->FromName = $this->***;
$mail->AddReplyTo($this->***,$this->***);
$mail->CharSet = $this->encoding;
$mail->Encoding = "base64";
$mail->IsHTML(true); // send as HTML
$mail->Subject = $this->subject;
$mail->Body = $this->body;
$mail->AltBody ="text/html";
$mail->AddAddress($to_email);
// $mail->SMTPDebug = true;
$mail->Is_SSL = true;
$mail->Port = 465;
// var_dump($mail);
// exit;
$mail->Send();
- PHP 示例代码: 使用 Gmail 或 Google Apps 的 SMTP Server 在线发送邮件
- PHP 示例代码: 使用 Gmail 或 Google Apps 的 SMTP Server 在线发送邮件
- 如何使用GMAIL的SMTP发送邮件
- openssl使用SMTP向gmail发送邮件
- 用 Gmail 的 SMTP 发送邮件
- 用 Gmail 的 SMTP 发送邮件
- php smtp邮件发送代码
- 如何用php通过gmail SMTP server发送邮件(免费)
- PHP使用SMTP发送邮件
- PHP使用smtp发送邮件
- php 使用smtp发送邮件
- PHP使用SMTP发送邮件
- PHP使用SMTP发送邮件报错代码535问题解决
- Python(2.7.x)使用SMTP发送邮件的简单示例
- Linux 上使用 Gmail SMTP 服务器发送邮件通知
- PHPMailer IIS下的PHP脚本使用GMAIL发送邮件
- php利用SMTP发送邮件代码
- 在PHP中使用Pear 的NetMail发送smtp邮件
- 追风
- # System.getProperty()参数大全
- PHP 示例代码: 使用 Gmail 或 Google Apps 的 SMTP Server 在线发送邮件
- poj2083
- Fedora Linux 的启动分析
- PHP 示例代码: 使用 Gmail 或 Google Apps 的 SMTP Server 在线发送邮件
- 禁止窗体拖动(重写WndProc)
- mysql常用操作总结
- Java反编译工具下载------Java Decompiler
- 上Vmware XP硬盘扩容与新增硬盘
- 对cnzz流量数据的说明
- VMware不用安装vmware Tools更改显示分辨率的方法
- mysql日志
- 收集oracle统计信息