定制 ride/lib-mail 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ride/lib-mail

最新稳定版本:1.0.0

Composer 安装命令:

composer require ride/lib-mail

包简介

Mail library of the Ride framework

README 文档

README

Mail library of the PHP Ride framework.

What's In This Library

MailAddress

The MailAddress class is used to deal with email addresses. All recipients of a MailMessage are set with this class. It allows straight email addresses but also addresses in the format of name .

MailMessage

The MailMessage class is a data container of the mail to send. You can set the recipients through the To, CC and BCC field. You can flag a message as an HTML message, add attachments and more.

MimePart

The MimePart class is internally used to add attachments to a MailMessage. You can use it manually to create a custom multipart message.

Transport

The Transport interface offers a way to implement the actual sending of a mail. It's also the starting point when you want to send a mail with this library as it also acts as a factory for messages.

A generic implentation is provided is this library through the SimpleTransport class. This uses the PHP functions to send a mail.

MessageParser

The MessageParser class is a helper for the Transport implementations. It takes a MailMessage and extracts all information into a structure which can be used by the transport.

Code Sample

Check the following code sample to some of the possibilities of this library.

<?php

use ride\library\log\Log;
use ride\library\mail\transport\SimpleTransport;
use ride\library\mail\transport\Transport;
use ride\library\system\file\FileSystem;

function createTransport(Log $log) {
    // simple, create an instance
    $transport = new SimpleTransport($log);
    
    // you set some defaults to you don't have to set this to each message
    $transport->setDefaultFrom('from@domain.com');
    $transport->setDefaultReplyTo('from@domain.com');
    
    // you can set a debug address 
    // no recipients in the To, CC and BCC will receive the message, only this debug to address
    $transport->setDebugTo('me@domain.com');
    
    return $transport;
}

function sendMail(MandrillTransport $transport, FileSystem $fileSystem) {
    $message = $transport->createMessage();
    $message->setSubject('My subject');
    $message->setRecipient('to@domain.com');
    $message->addCc('To 2 <to2@domain.com>');
    $message->addBcc(array('to3@domain.com', 'To 3 <to3@domain.com>'));
    $message->setIsHtmlMessage(true);
    $message->setMessage('<html><body><p>...</p></body></html>');
    
    $file = $fileSystem->getFile('/path/to/image.png');
    
    $message->addAttachement($file, 'image/png');
    
    try {
        $transport->send($message);
    } catch (MailException $exception) {
        
    }
}

Related Modules

Installation

You can use Composer to install this library.

composer require ride/lib-mail

统计信息

  • 总下载量: 5.46k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 10
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 8
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-02-21