PHP code example of lsys / mailsender

1. Go to this page and download the library: Download lsys/mailsender 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/ */

    

lsys / mailsender example snippets


//配置文件:dome/config/mail.php
//邮件渲染:dome/Mail/MyMail.php
//设置默认发送配置
//创建一个邮件内容
$simple=new Eml("eml_name");//eml_name 为对应配置值
$simple->set_title("aaa");//设置标题
$simple->set_body_vars(array("link"=>"http://baidu.com"));//设置内容变量
$simple->set_attachment(array(__DIR__."/test.png"));//设置附件
//创建一个发送邮件元素
$item=new Item($simple);
//添加收件人
$item->add_to("[email protected]");//LSLSlsls1212312312
try{
	//执行发送
	$send=MailSender::factory()->send($item);
	var_dump($send);
}catch (\LSYS\Exception $e){
	print_r($e->getMessage());
}