| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 31 | 
| Code Lines | 18 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php | ||
| 10 | public function testSend() | ||
| 11 |     { | ||
| 12 | |||
| 13 | //******************** 配置信息 start ******************************** | ||
| 14 | $config = [ | ||
| 15 | 'host' => 'smtp.mxhichina.com',// 邮箱的服务器地址 | ||
| 16 | 'port' => 465,// SMTP 端口 | ||
| 17 | 'from_address' => '[email protected]',// 发件人地址,一般和username一致 | ||
| 18 | 'username' => '[email protected]',// 用户名 | ||
| 19 | 'password' => 'J^*****&H',// 密码 | ||
| 20 | 'encryption' => 'ssl',// 加密方式 | ||
| 21 | ]; | ||
| 22 | //******************** 配置信息 end ******************************** | ||
| 23 | |||
| 24 | $smtpemailto = '[email protected]';//发送给谁 | ||
| 25 | $mailtitle = "测试邮件";//邮件主题 | ||
| 26 | $mailcontent = "<h1>吃饭了嘛</h1>";//邮件内容 | ||
| 27 | |||
| 28 | $email = Email::smtp($config); | ||
| 29 | $email->setDebug(true);//线上注释此行 | ||
| 30 | $email->toEmail($smtpemailto); | ||
| 31 | $mailtype = "html"; | ||
| 32 | // $cc = "[email protected]"; | ||
| 33 | // $bcc = "[email protected]"; | ||
| 34 | // $attachments = ['E:\git\phpMailer\example\sendmail.php']; | ||
| 35 | $attachments = ['http://oss-joywork.oss-cn-beijing.aliyuncs.com/miningplatform/api/6bb8b72d99de37d8e7b86243b52898ec.csv']; | ||
| 36 | $email->addAttachments($attachments);//添加附件 | ||
| 37 | // $email->ccEmail($cc);//抄送人 | ||
| 38 | // $email->bccEmail($bcc);//隐性抄送人 | ||
| 39 | $state = $email->sendmail( $mailtitle, $mailcontent, $mailtype); | ||
| 40 | var_dump($state); | ||
|  | |||
| 41 | } | ||
| 43 | } |