PHP code example of lyignore / sendemail

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

    

lyignore / sendemail example snippets

shell
// 引入composer中的组件
' =>[
        'DB_CONNECTION' => 'mysql',
        'DB_HOST' => 'localhost',
        'DB_PORT' => '33060',
        'DB_DATABASE' => 'test',
        'DB_USERNAME' => 'homestead',
        'DB_PASSWORD' => '',
    ],
    'email' => [
        'EMAIL_SENDSERVER'=>'smtp.mxhichina.com',
        'EMAIL_USERNAME' => '[email protected]',
        'EMAIL_PASSWORD' => 'Aikaka12',
        'EMAIL_PORT' => '465',
        'EMAIL_TYPE' => 'ssl',
    ],
];
$sendemail = new \Lyignore\Sendemail\SendEmail($config);

// 判断是查询从上次到这次期间生成的数据还是查询全部的数据,test.txt为临时文件名称,可自定义
$sendemail->setTimeLimit('test.txt');
// 查询的sql语句,预查询,可传入第二个参数,SQL语句用 ?代替变量
$datas = $sendemail->getData("SELECT * FROM `users` WHERE `email` = ? ", ['admin']);
// 按照配置自动发送邮件, 可直接配置邮箱,也可用别名
$receivers = ['[email protected]', '[email protected]' => 'test'];
$res = $sendemail->send($receivers);

// 也可以按照查询的数据生成Excel文件,SendEmail->send()会自动调用生成Excel方法,返回Excel的临时路径
$path = $sendemail->createExcel();