PHP code example of tinymeng / mailer

1. Go to this page and download the library: Download tinymeng/mailer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tinymeng / mailer example snippets


use tinymeng\mailer\Email;

//******************** 配置信息 start ********************************
$config = [
    'host'  => 'smtp.qq.com',
    'port'    => '465',
    'encryption'=> 'ssl',
    'username'=> '********@qq.com',
    'password'=> '********',
    'from_address'=> '*******@qq.com',
    'from_name'=> 'TinyMeng管理员',
];
//******************** 配置信息 end ********************************


$email = Email::smtp($config);
$email->setDebug(true);//线上注释此行
$email->toEmail("[email protected]");
// $email->toEmail("[email protected],[email protected]");//多账号已逗号隔开
$mailtitle = "饭后等你,测试邮件发送";
$mailcontent = "饭后等你,测试邮件发送";
$mailtype = "html";
//$cc = "[email protected]";
//$bcc = "[email protected]";
//$attachments = ["F:\git\admin_management_api\app\command\Hello.php"];
//$email->addAttachments($attachments);//添加附件
//$email->ccEmail($cc);//抄送人
//$email->bccEmail($bcc);//隐性抄送人
$state = $email->sendmail( $mailtitle, $mailcontent, $mailtype);
if($state==""){
    exit("发送失败");
}
exit("发送成功");


$host;        //发送email Host
$port;        //端口 25 or 456
$encryption;  //加密 ssl
$username;    //邮箱用户名(发送人email)
$password;    //邮箱密码(如果是第三方请去设置里获取)
$from_address;//发送人email
$from_name;   //发送人名称
$to_address;   //接收人email
$log_file = false;//记录日志
$host_name = "localhost"; //is used in HELO command
$time_out = 30;//is used in fsockopen()