Home  >  Article  >  php教程  >  Super beautiful and convenient email sending extension tp-mailer, supports all frameworks

Super beautiful and convenient email sending extension tp-mailer, supports all frameworks

WBOY
WBOYOriginal
2016-12-05 13:27:441611browse

All ThinkPHP version frameworks and any other PHP framework are supported, and automatic loading files are supported manually
, easy to use, powerful, supports ThinkPHP's own template engine, supports HTML templates, supports plain text templates, also supports sending attachments with Chinese characters, supports embedding image metadata in emails, code calls consistently, super beautiful, developed based on SwiftMailer
Let’s take a look at the elegant use first: use mailertp5Mailer;<br> <br> $mailer = Mailer::instance();<br> $mailer->from('tianpian0805@gmail.com', 'yuan1994')<br> ->to('your-mail@domain.com')<br> ->subject('Plain text test')<br> ->text('Welcome to use Tp Mailer')<br> ->send();require_once '/path/to/tp-mailer/src/autoload.php';<br> <br> use mailertp32Mailer;<br> <br> $mailer = Mailer::instance();<br> $mailer->from('tianpian0805@gmail.com', 'yuan1994')<br> ->to('your-mail@domain.com')<br> ->subject('Multi-line text test')<br> ->line('PHPers: ')<br> ->line('Welcome to use Tp Mailer, if you find it useful, please give it a star, and you are also welcome to Fork to help improve it')<br> ->line()<br> ->line('yuan1994 <tianpian0805@gmail.com ' . date('Y-m-d'))<br /> ->attach('/path/to/filename.pdf', 'customized filename.pdf')<br> ->send();require_once '/path/to/tp-mailer/src/autoload.php';<br> <br> use mailertp31Mailer;<br> <br> $mailer = Mailer::instance();<br> $mailer->send(function($mailer, $message) {<br> $mailer->to('tianpian0805@gmail.com')<br> ->subject('Use the framework template engine to render template tests')<br> ->view('mail:test', array(<br>              'param1' => 'Parameter 1',<br>              'param2' => 'Parameter 2',<br>             'embed:image' => ROOT_PATH . 'image.jpg',<br> ));<br> });Installation:
Install using Composer (highly recommended):

Support psr-4 specification, ready to use out of the box

composer require yuan1994/tp-mailer
Download from github or download the source code directly manually:
Need to manually import the automatic loading file
Download file:

git clone https://github.com/yuan1994/tp-mailer tp-mailer

git clone https://github.com/swiftmailer/swiftmailer swiftmailer

Or click to download directly:

https://github.com/yuan1994/tp-mailer/archive/master.zip

https://github.com/swiftmailer/swiftmailer/archive/5.x.zip

Move folder:

Then manually name the two projects tp-mailer and swiftmailer respectively, and place them in the extension class library folder of your own project. These two folders must be in the same directory. The directory structure is roughly as follows:

Extension catalog
├── tp-mailer
│ └── src
├── swiftmailer
│ ├── lib
│ ├── doc
│ └── tests
Introduce autoloading files:

Import it when using it or automatically import it globally

require_once '/path/to/tp-mailer/src/autoload.php;


Project address:
https://github.com/yuan1994/tp-mailer

Document address:
https://github.com/yuan1994/tp-mailer

If you have any questions, please submit Issues
https://github.com/yuan1994/tp-mailer/issues

Other project recommendations:
tpAdmin: Backend management framework based on tp5 that supports automatic code generation and Rbac permission management
https://github.com/yuan1994/tpAdmin

WeChat_Web_Devtools Linux version: WeChat applet development tool that perfectly supports Linux system:
https://github.com/yuan1994/wechat_web_devtools

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn