sy / mail
简单的邮件库
2.0.2
2024-06-02 18:08 UTC
Requires
- php: >=5.6.0
- phpmailer/phpmailer: ^6.1
- sy/webcomponent: ^2
This package is auto-updated.
Last update: 2024-09-02 18:45:48 UTC
README
简单的邮件库
安装
使用以下命令安装最新版本
composer require sy/mail
基本用法
默认使用 php mail() 函数
<?php use Sy\Mail; $mail = new Mail('syone7@gmail.com', 'Hello world', 'This is a test mail!'); $mail->send();
使用 SMTP 服务器
<?php use Sy\Mail; $mail = new Mail('syone7@gmail.com', 'Hello world', 'This is a test mail!'); $mail->setSmtp('smtp.gmail.com', 'example@gmail.com', 'password', 'tls', 587); $mail->send();
响应式简单 HTML 邮件模板
<?php use Sy\Mail; use Sy\Mail\Template\Html; $html = new Html('This is a simple html email template!'); $mail = new Mail('syone7@gmail.com', 'Simple html template', $html); $mail->send();
<?php use Sy\Mail; use Sy\Mail\Template\Html; $html = new Html(); $html->addImage('https://picsum.photos/600/300', 'Image Alt'); $html->addParagraph('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'); $html->addButton('Go to website now!', 'https://example.com'); $html->setFooterLink('Unsubscribe', 'https://example.com', "Don't like these emails?"); $html->setPoweredBy('HTML email', 'https://example.com', 'Powered by'); $mail = new Mail('syone7@gmail.com', 'Simple html template', $html); $mail->send();