Issues (8)

tests/MailerTest.php (1 issue)

1
<?php
2
use PHPUnit\Framework\TestCase;
3
use tinymeng\mailer\Email;
4
5
/**
6
 * IntelligentParseTest
7
 */
8
class MailerTest extends TestCase
9
{
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
        $attachments = ['财务报表.csv'=>'http://oss-joywork.oss-cn-beijing.aliyuncs.com/miningplatform/api/6bb8b72d99de37d8e7b86243b52898ec.csv'];
37
        $email->addAttachments($attachments);//添加附件
38
//        $email->ccEmail($cc);//抄送人
39
//        $email->bccEmail($bcc);//隐性抄送人
40
        $state = $email->sendmail( $mailtitle, $mailcontent, $mailtype);
41
        var_dump($state);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($state) looks like debug code. Are you sure you do not want to remove it?
Loading history...
42
    }
43
44
}