• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..23-Nov-2020-

src/H23-Nov-2020-1,031446

tests/H23-Nov-2020-14994

LICENSEH A D22-Nov-20201 KiB2116

README.mdH A D22-Nov-20201.2 KiB5242

composer.jsonH A D22-Nov-2020893 4039

composer.lockH A D22-Nov-202038.7 KiB1,1281,127

phpunit.xmlH A D22-Nov-2020941 3433

README.md

1Mailer
2=======
3
4A lightweight SMTP mail sender
5
6### Install
7
8```
9$ composer require txthinking/mailer
10```
11
12### Usage
13
14```
15<?php
16use Tx\Mailer;
17
18$ok = (new Mailer())
19    ->setServer('smtp.ym.163.com', 25)
20    ->setAuth('', '') // email, password
21    ->setFrom('You', '') //your name, your email
22    ->setFakeFrom('heelo', 'bot@fake.com') // if u want, a fake name, a fake email
23    ->addTo('Cloud', 'cloud@txthinking.com')
24    ->setSubject('Test Mailer')
25    ->setBody('Hi, I <strong>love</strong> you.')
26    ->addAttachment('host', '/etc/hosts')
27    ->send();
28var_dump($ok);
29```
30OR
31```
32<?php
33use \Tx\Mailer\SMTP;
34use \Tx\Mailer\Message;
35use \Monolog\Logger;
36
37$smtp = new SMTP(); // new SMTP(new Logger('Mailer')); # set logger to receive debug log
38$smtp->setServer('smtp.ym.163.com', 25)
39    ->setAuth('bot@ym.txthinking.com', ''); // email, password
40
41$message = new Message();
42$message->setFrom('Tom', 'your@mail.com') // your name, your email
43    ->setFakeFrom('heelo', 'bot@fake.com') // if u want, a fake name, a fake email
44    ->addTo('Cloud', 'cloud@txthinking.com')
45    ->setSubject('Test Mailer')
46    ->setBody('<h1>For test</h1>')
47    ->addAttachment('host', '/etc/hosts');
48
49$ok = $smtp->send($message);
50var_dump($ok);
51```
52