使用方法
- public function email(){
- //邮件发送服务器
- $emailHost='smtp.163.com';
- //邮件发送端口
- $emailPort='25';
- //邮件发送超时时间
- $emailTimeout='20';
- //发件人邮箱
- $emailUserName='123456@163.com';
- //发件人邮箱密码
- $emailPassword='123456';
- //发件人姓名
- $emailFormName='abc';
- //收件人邮箱
- $toemail='123456@163.com';
- //邮件标题
- $subject='我是标题';
- //邮件内容
- $message='我是内容';
- Vendor('mailer.EMailer');
- $mailer=new \EMailer();
- //邮件配置
- $mailer->SetLanguage('zh_cn');
- $mailer->Host = $emailHost;
- $mailer->Port = $emailPort;
- $mailer->Timeout = $emailTimeout;
- $mailer->ContentType = 'text/html';//设置html格式
- $mailer->SMTPAuth = true;
- $mailer->Username = $emailUserName;
- $mailer->Password = $emailPassword;
- $mailer->IsSMTP ();
- $mailer->From = $mailer->Username; // 发件人邮箱
- $mailer->FromName =$emailFormName;
- $mailer->AddReplyTo ( $mailer->Username );
- $mailer->CharSet = 'UTF-8';
- // 发送邮件
- $mailer->AddAddress ( $toemail );
- $mailer->Subject = $subject;
- $mailer->Body = $message;
- if ($mailer->Send () === true) {
- return true;
- } else {
- $error = $mailer->ErrorInfo;
- return false;
- }
- }