Skip to content

Commit 7bd60a4

Browse files
committed
version 3.0.0-beta
1 parent 038eba5 commit 7bd60a4

File tree

8 files changed

+413
-580
lines changed

8 files changed

+413
-580
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.idea/*

README.md

+38-78
Original file line numberDiff line numberDiff line change
@@ -11,108 +11,68 @@ PHP Class for sending email.
1111
## With [Composer](https://getcomposer.org/)
1212
1. Run in console:
1313
```text
14-
php composer.phar require ddrv/mailer
15-
php composer.phar install
14+
php composer.phar require ddrv/mailer:~3
1615
```
1716
1. Include autoload file
1817
```php
1918
require_once('vendor/autoload.php');
2019
```
21-
## Manually install
22-
1. Download [Archive](https://github.com/ddrv/mailer/archive/master.zip)
23-
1. Unzip archive to /path/to/libraries/
24-
1. Include files
25-
```php
26-
require_once('/path/to/libraries/mailer/src/Mailer.php');
27-
```
2820
2921
# Usage
3022
3123
```php
32-
/**
33-
* Inititalization Mailer class.
24+
<?php
25+
26+
/*
27+
* Initialization Mailer class.
3428
*/
3529
$mailer = new \Ddrv\Mailer\Mailer();
3630
37-
/**
31+
/*
3832
* If need use SMTP server, setting it
3933
*/
40-
$mailer->smtp('smtp.host.name',25,'[email protected]','password for from', 'http://host.name');
41-
42-
/**
43-
* Set sender [email protected] as Site Administrator
44-
*/
45-
$mailer->sender('[email protected]','Site Administrator');
46-
47-
/**
48-
* Set subject of mail
49-
*/
50-
$mailer->subject('Subject of mail');
51-
52-
/**
53-
* Add text of mail in HTML format
54-
*/
55-
$mailer->body('<p>Simple text</p>');
56-
57-
/**
58-
* In need adding attachment from string, run
59-
*/
60-
$mailer->attachFromString('content','attach1.txt');
61-
62-
/**
63-
* In need adding attachment from file, run
34+
$mailer->smtp(
35+
'smtp.host.name', // host
36+
25, // port
37+
'[email protected]', // login
38+
'password for from', // password
39+
'[email protected]', // sender
40+
null, // encryption: 'tls', 'ssl' or null
41+
'http://host.name' // domain
42+
);
43+
44+
/*
45+
* If need switch provider back to mail() function, use
6446
*/
65-
$mailer->attachFromFile('/path/to/file','attach2.txt');
47+
$mailer->legacy('-f');
6648
67-
/**
68-
* Add addresses
49+
/*
50+
* Create message
6951
*/
70-
$mailer->addAddress('[email protected]', 'My best Friend');
71-
$mailer->addAddress('[email protected]', 'My second Friend');
52+
$message = new \Ddrv\Mailer\Message('[email protected]', 'subject', '<p>Simple text</p>', true);
7253
73-
/**
74-
* If error, remove address
54+
/*
55+
* You can set named sender [email protected] as Site Administrator
7556
*/
76-
$mailer->removeAddress('address2@host.name');
57+
$message->setSender('from@host.name', 'Site Administrator');
7758
78-
/**
79-
* Send email to addresses
59+
/*
60+
* If need adding attachment from string, run
8061
*/
81-
$mailer->send();
82-
```
62+
$message->attachFromString('attach1.txt', 'content', 'text/plain');
8363
84-
## Templates
85-
86-
Content of file /path/to/template.tmpl:
87-
```text
88-
<h1>This template</h1>
89-
<p>Hello, {username}!</p>
90-
<p>This message generated automatically.</p>
91-
<p>{date}</p>
92-
```
93-
94-
PHP code:
95-
```php
96-
/**
97-
* You can using templates for your mails
98-
*/
99-
100-
/**
101-
* Add template from string
64+
/*
65+
* If need adding attachment from file, run
10266
*/
103-
$mailer->addTemplateFromString('tmpl1', '<p>Hello, {username}</p>');
67+
$message->attachFromFile('attach2.txt', '/path/to/file');
10468
105-
/**
106-
* Add template from file
69+
/*
70+
* Send email to addresses (one mail for all addresses)
10771
*/
108-
$mailer->addTemplateFromFile('tmpl2', '/path/to/template.tmpl');
72+
$mailer->send($message, array('[email protected]', '[email protected]'));
10973
110-
/**
111-
* Set body from template
74+
/*
75+
* or send personal mailing one mail per addresses
11276
*/
113-
$context = [
114-
'username' => 'Anonymous',
115-
'date' => date('Y-m-d'),
116-
];
117-
$mailer->template('tmpl2',$context);
118-
```
77+
$mailer->send($message, array('[email protected]', '[email protected]', true));
78+
```

composer.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
{
22
"name": "ddrv/mailer",
3-
"version":"2.2.0",
3+
"version":"3.0.0-beta",
44
"require":{
5-
"php":">=5.4.0"
5+
"php":">=5.3.0",
6+
"ext-mbstring": "*"
7+
},
8+
"suggest": {
9+
"ext-fileinfo": "Mime-Type detecting"
610
},
711
"type": "library",
812
"description": "PHP Class for sending email",
9-
"keywords": ["email", "mail", "send", "attachments"],
13+
"keywords": ["email", "mail", "send", "attachments", "smtp"],
1014
"license": "MIT",
1115
"authors": [
1216
{

0 commit comments

Comments
 (0)