2017 © Pedro Peláez
 

library mail

Wedeto Platform - SMTP Mailer

image

wedeto/mail

Wedeto Platform - SMTP Mailer

  • Thursday, June 14, 2018
  • by Wedeto
  • Repository
  • 1 Watchers
  • 1 Stars
  • 95 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 4 % Grown

The README.md

Wedeto\Mail

Mail is a class to send mails using a SMTP server. It was derived from Zend\Mail, which is the reason it is published using the New BSD license rather than MIT, like the rest of Wedeto., (*1)

Features

  • Sending of messages using SMTP
  • Use SSL or TLS as encryption
  • Authenticate using PLAIN, LOGIN or CRAM-MD5
  • Send simple text messages, or compose complex message using Mime
  • A simple interface to create HTML e-mails with embedded images and attachments

Difference from Zend\Mime

Wedeto\Mail\Mime is derived from Zend\Mime. The functionality has been extended to make it easier to use. Wedeto\Mail\Mime\Message itself can now be added as a part to a Mime multipart message, to create nested Mime structures., (*2)

This in turn allows you to send messages containing attachments, embedded images and text / html alternatives., (*3)

Differences from Zend\Mail

Wedeto\Mail is derived from Zend\Mail. However, it has been changed in fundamental ways. Every dependency on other parts of the Zend framework was stripped out. Additionally, support for other transports and protocol was stripped out. The aim of Wedeto\Mail is to be lightweight and functional, not to be a building block to create webmail application. Therefore, support for IMAP and POP was removed., (*4)

Support for alternate transports such as Sendmail and PHP's mail function was removed as well. When Sendmail is available, a SMTP server is usually also available on localhost and is therefore superfluous. PHP's mail function should not be used at all, as it's highly inefficient and inflexible., (*5)

Wedeto\Mail does not support to create a Wedeto\Mail\Message from an existing mail message. Because all POP and IMAP support has been stripped this is no longer necessary. This allowed to strip down the complex header parsing situation and store the header in a simpler structure., (*6)

A new class was added, Wedeto\Mail\HTMLMessage. This eases the construction of messages containing a HTML part, a text part, attachments and embedded images, to create a structure like:, (*7)

HTMLMessage * Message container (Wedeto\Mail\Mime\Message) * Plain text (Wedeto\Mail\Mime\Part) * HTML Container (Wedeto\Mail\Mime\Message) * HTML Message (Wedeto\Mail\Mime\Part) * Embedded image 2 (Wedeto\Mail\Mime\Attachment) * Embedded image 2 (Wedeto\Mail\Mime\Attachment) * Attachment 1 (Wedeto\Mail\Mime\Attachment) * Attachment 2 (Wedeto\Mail\Mime\Attachment), (*8)

Usage

There's one transport, Wedeto\Mail\SMTPMailer. It can be created without any argument, in which case it defaults to connecting to localhost on port 25. You can specify the following options:, (*9)

  • hostname
  • port
  • username
  • password
  • ssl (SSL or TLS)
  • auth_type (PLAIN, LOGIN, CRAM-MD5)

Provide these options in an associative array:, (*10)

use Wedeto\Mail\SMTPMailer;

$mailer = new SMTPMailer(array(
    'hostname' => 'localhost',
    ...
);

A HTML message can be composed with Wedeto\Mail\HTMLMessage:, (*11)

use Wedeto\Mail\HTMLMessage;

$msg = new HTMLMessage;
$msg->setHTML('<html><head></head><body>

Hi there

My message, (*12)

');

You can add attachments and embed images:, (*13)

$imgurl = $msg->embed('my_image.jpg');
$msg->setHTML('<html><head></head><body><h1>Hi there</h1><p>My message <img src="' . $imgurl . '" /></p>');
$msg->attach('my_document.pdf');

You can also generate the attachment or embedded image in memory and provide a stream:, (*14)

$msg->attach('my_document.pdf', $my_resource);

The correct structure will be generated. When you set the HTML, the plain text is automatically generated by converting breaks and paragraphs to newlines and stripping all HTML. However, you may want to override this to provide your own text:, (*15)

$msg->setPlain('Your mail client does not seem to render HTML. You can visit the online version here: http://your/website');

Once you are satisfied, you can use the transport to send the message., (*16)

$msg->addFrom('your@email.com', 'Your name');
$msg->addTo('their@email.com', 'Their name');
$msg->addBcc(['one@example.com', 'two@example.com']);

$mailer->send($msg);

That's it, it's sent!, (*17)

Of course, you can also compile your own message using Wedeto\Mail\Message, building a message using Wedeto\Mail\Mime\Message and Wedeto\Mail\Mime\Part, much in the same way as you can with Zend\Mail and Zend\Mime., (*18)

The Versions

14/06 2018

dev-master

9999999-dev https://wedeto.net/

Wedeto Platform - SMTP Mailer

  Sources   Download

BSD-3-Clause

The Requires

 

by Egbert van der Wal

14/06 2018

v1.0.0-beta2

1.0.0.0-beta2 https://wedeto.net/

Wedeto Platform - SMTP Mailer

  Sources   Download

BSD-3-Clause

The Requires

 

by Egbert van der Wal

17/05 2018

v1.0.0-beta1

1.0.0.0-beta1 https://wedeto.net/

Wedeto Platform - SMTP Mailer

  Sources   Download

BSD-3-Clause

The Requires

 

by Egbert van der Wal

07/04 2018

v0.9.5

0.9.5.0 https://wedeto.net/

Wedeto Platform - SMTP Mailer

  Sources   Download

BSD-3-Clause

The Requires

 

by Egbert van der Wal

17/03 2018

v0.9.4

0.9.4.0 https://wedeto.net/

Wedeto Platform - SMTP Mailer

  Sources   Download

BSD-3-Clause

The Requires

 

by Egbert van der Wal

10/03 2018

v0.9.3

0.9.3.0 https://wedeto.net/

Wedeto Platform - SMTP Mailer

  Sources   Download

BSD-3-Clause

The Requires

 

by Egbert van der Wal

06/06 2017

v0.9.2

0.9.2.0 https://wedeto.net/

Wedeto Platform - SMTP Mailer

  Sources   Download

BSD-3-Clause

The Requires

 

by Egbert van der Wal

02/06 2017

v0.9.1

0.9.1.0 https://wedeto.net/

Wedeto Platform - SMTP Mailer

  Sources   Download

BSD-3-Clause

The Requires

 

by Egbert van der Wal

30/05 2017

v0.9.0

0.9.0.0 https://wedeto.net/

Wedeto Platform - SMTP Mailer

  Sources   Download

BSD-3-Clause

The Requires

 

by Egbert van der Wal