Pear의 자체 메일 라이브러리를 사용하여 이메일 보내기
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
풀어 주다: 2016-07-25 09:01:13
用pear自带的mail类库发邮件,可以用pear install 命令来安装对应的库
- $body = "点我重新生成密码";
-
- sendMail_smtp("xxxxxxxx@qq.com",'测试',$body);
-
- function sendMail_smtp($smtpemailto,$mailsubject,$mailbody){
- //error_reporting(7);
-
- require_once 'Mail.php';
- require_once 'Mail/mime.php';
-
- $from = 'admin@xxx.com';
- $to = $smtpemailto;
- $password = 'xxxxxx';
-
- $mail_config=array(
- "host"=>"smtp.ym.163.com",
- "port"=>25,
- "auth"=>true,
- "username"=>$from,
- "password"=>$password,
- "from"=>$from,
- );
-
- $hdrs = array(
- 'From'=>$from,
- 'To' => $to, //收信地址
- 'Subject'=>$mailsubject
- );
-
- $mime = new Mail_mime();
- //$mime->setTXTBody($text);
- //添加附件
- //$mime->addHTMLImage('php.gif','image/gif','12345',true);
- $mime->_build_params['html_charset'] = "utf-8";//设置编码格式
- $mime->_build_params['head_charset'] = "utf-8";//设置编码格式
- $mime->setHTMLBody($mailbody);
- $body = $mime->get();
- $hdrs = $mime->headers($hdrs);
-
- $mail = Mail::factory('smtp',$mail_config);
- $succ = $mail->send($to,$hdrs,$body);
-
- if (PEAR::isError($succ))
- {
- //echo 'Email sending failed: ' . $succ->getMessage();
- $err = 'Email sending failed: ' . $succ->getMessage();
- $content = $to."t".date('Y-m-d H:i:s')."t ".$err." rn" ;
- }
- else
- {
- //$content = $to."t".date('Y-m-d H:i:s')."t Email sent succesfully rn" ;
- return true;
-
- }
-
- }
复制代码
|
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
저자별 최신 기사
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31