maxfreck/pechkin
Composer 安装命令:
composer require maxfreck/pechkin
包简介
Pechkin is a small and easy-to-use mailing library for PHP
README 文档
README
Features
- Support for PSR-7 streams.
- Send emails with multiple To, Cc, Bcc and Reply-to addresses.
- Send emails through http/socks proxy.
- Support for raw, multipart/alternative, multipart/mixed and multipart/related emails.
Installing Pechkin
The recommended way to install Pechkin is through Composer.
Install Composer:
curl -sS https://getcomposer.org/installer | php
Next, run the Composer command to install the latest stable version of Pechkin:
php composer.phar require maxfreck/pechkin
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
You can then later update Pechkin using composer:
composer.phar update
Using Pechkin
All email metainformation (content type, file name, attachment disposition) is passed as a stream metadata.
Basic usage example:
<?php //use composer's autoloader require '../vendor/autoload.php'; use \Pechkin\CurlMailer; use \Pechkin\Streams\FileStream; use \Pechkin\fn; fn::$host = 'example.org'; $body = <<<EOD <h1>Lorem ipsum</h1> <div><img src="cid:img1"></div> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> EOD; $mailer = new CurlMailer( "smtps://smtp.example.org:465", "nemo@example.org", "Nemo's password", (object)[ 'from' => (object)['email' => 'nemo@example.org', 'name' => 'Nemo Nobody'], 'replyTo' => [ (object)['email' => 'nemo@example.org', 'name' => 'Nemo Nobody'], ], 'to' => [ (object)['email' => 'foo@example.com', 'name' => 'Mr. Foo'], ], 'subject' => "Hello, Mr. Foo", 'body' => FileStream::fromString($body, ['content-type' => 'text/html; charset="utf-8"']), 'altBody' => FileStream::fromString("This is alt body"), //'proxy' => 'socks5://127.0.0.1:8080' //See CURLOPT_PROXY for more information ] ); $mailer->addAttachment( new FileStream( 'image.png', 'r', [ 'content-type' => fn::fileMime('image.png'), 'name' => 'image.png', 'disposition' => 'inline' ] ), 'img1' //Attachment content ID ); $mailer->send();
To-Do
- Raw SMTP sender similar to PHPMailer.
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-03