2017 © Pedro PelΓ‘ez
 

library sendmail

Send messages for the different ways.

image

pyataks/sendmail

Send messages for the different ways.

  • Friday, November 3, 2017
  • by pyatakss
  • Repository
  • 0 Watchers
  • 0 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 12 Versions
  • 0 % Grown

The README.md

Send email

Install

composer require pyataks/sendmail

Examples

SMTP configuration

$smtpConfig = [
    'host' => 'ssl://smtp.gmail.com',
    'port' => 465,
    'username' => 'username@gmail.com',
    'password' => ''
];

Mandrill configuration

$mandrillKey = 'mandrill API-key';

Send message with attach through the mail()

$mailer = new Mailer(new MailTransport());
try {
    $message = (new Message())
            ->to('emailto@example.com', 'Jon')
            ->from('emailfrom@example.com', 'Jon Mailer')
            ->subject('Test subject. Send mail php')
            ->body('

Test content. Send mail php
', 'text/html') ->attach('full_filename', ['name' => 'main-logo.png', 'mime_type' => 'image\png']); } catch (\InvalidArgumentException $e) { echo $e, PHP_EOL; } try { echo $mailer->send($message); } catch (\pyatakss\sendmail\PSMailException $e) { echo $e, PHP_EOL; }

Create different transports

$mailTransport = new MailTransport();
$smtpTransport = new SMTPTransport($smtpConfig);
$mandrillTransport = new MandrillTransport($mandrillKey);

Create transport for the mail()

$mailer = new Mailer($mailTransport);

Prepare messages

$messageCyrillicText = (new Message())
    ->to('emailto1@example.com', 'Π ΠΎΠΌΠ°')
    ->to('emailto2@example.com', 'Маша')
    ->to('emailto3@example.com', 'ΠšΠΈΡ€ΠΈΠ»Π»')
    ->from('emailfrom@example.com', 'Π”ΠΆΠΎΠ½ Π‘ΠΈΠ»ΡŒΠ²Π΅Ρ€')
    ->subject('Π’Π΅ΠΌΠ° Π½Π° ΠΊΠΈΡ€ΠΈΠ»ΠΈΡ†Π΅. Send mail php')
    ->body('<div style="color: red">ВСкст письма.<br> Писмо ΠΎΡ‚ΠΏΡ€Π°Π²Π΅Π»Π½ΠΎ Π±Π΅Π· attach. <br> Send mail php</div>', 'text/html');

$messageSwift = (new SwiftMessageAdapter(new \Swift_Message()))
    ->to('emailto1@example.com', 'Π ΠΎΠΌΠ°')
    ->to('emailto2@example.com', 'Маша')
    ->to('emailto3@example.com', 'ΠšΠΈΡ€ΠΈΠ»Π»')
    ->from('emailfrom@example.com', 'Π”ΠΆΠΎΠ½ Π‘ΠΈΠ»ΡŒΠ²Π΅Ρ€')
    ->subject('Subject English swift . Send mail php')
    ->body('<div style="color: green">Text of the letter.<br> Letter sent WITH attach. <br> Send mail php</div>', 'text/html')
    ->attach($listFiles[0])
    ->attach($listFiles[1]);

Sending through mail

echo $mailer->send($messageCyrillicText);

Change transport to SMTP, change subject of prepared mail, and, finally, send

$mailer->setTransport($smtpTransport);

$messageEnglish->subject('Subject English. Send smtp php');
echo $mailer->send($messageEnglish);

The Versions

03/11 2017

dev-bugfix/new_f

dev-bugfix/new_f https://github.com/pyataks/sendmail

Send messages for the different ways.

  Sources   Download

BSD

The Requires

 

by Sergiy Pyatak

03/11 2017

dev-develop

dev-develop https://github.com/pyataks/sendmail

Send messages for the different ways.

  Sources   Download

BSD

The Requires

 

by Sergiy Pyatak

30/08 2016

dev-master

9999999-dev https://github.com/pyataks/sendmail

Send messages for the different ways.

  Sources   Download

BSD

The Requires

 

by Sergiy Pyatak

30/08 2016

1.0.8

1.0.8.0 https://github.com/pyataks/sendmail

Send messages for the different ways.

  Sources   Download

BSD

The Requires

 

by Sergiy Pyatak

17/05 2016

1.0.7

1.0.7.0 https://github.com/pyataks/sendmail

Send messages for the different ways.

  Sources   Download

BSD

The Requires

 

by pyatak_ss

30/04 2016

1.0.6

1.0.6.0 https://github.com/pyataks/sendmail

Send messages for the different ways.

  Sources   Download

BSD

The Requires

 

by pyatak_ss

20/04 2016

1.0.5

1.0.5.0 https://github.com/pyataks/sendmail

Send messages for the different ways.

  Sources   Download

BSD

The Requires

 

by pyatak_ss

08/04 2016

1.0.4

1.0.4.0 https://github.com/pyataks/sendmail

Send messages for the different ways.

  Sources   Download

BSD

The Requires

 

by pyatak_ss

08/04 2016

1.0.3

1.0.3.0 https://github.com/pyataks/sendmail

Send messages for the different ways.

  Sources   Download

BSD

The Requires

 

by pyatak_ss

07/04 2016

1.0.2

1.0.2.0 https://github.com/pyataks/sendmail

Send messages for the different ways.

  Sources   Download

BSD

The Requires

 

by pyatak_ss

07/04 2016

1.0.1

1.0.1.0 https://github.com/pyataks/sendmail

Send messages for the different ways.

  Sources   Download

BSD

The Requires

 

by pyatak_ss

07/04 2016

1.0.0

1.0.0.0 https://github.com/pyataks/sendmail

Send messages for the different ways.

  Sources   Download

BSD

The Requires

 

by pyatak_ss