-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemail.php
43 lines (35 loc) · 924 Bytes
/
email.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
*
* Description: Email sender class
* Author: Denis Vororpaev
* Author Email: d.n.voropaev@gmail.com
* Version: 0.1.0
* Copyright: Denis Voropaev © 2016
*
**/
class Email {
private static function headers ($type, $from, $to, $charset='utf-8') {
return "Content-type: {$type}; charset={$charset}\r\n" .
"From: {$from}\r\n" .
"Reply-To: {$from}\r\n";
// "To: {$to}";
}
public static function sendText ($from, $to, $subject, $content) {
return Email::send (
Email::headers (
'text/plain', $from, $to), $to, $subject, $content);
}
public static function sendHTML ($from, $to, $subject, $content) {
return Email::send (
Email::headers (
'text/html', $from, $to), $to, $subject, $content);
}
private static function send ($headers, $to, $subject, $content) {
if (!$to) {
return false;
}
return mail ($to, $subject, $content, $headers);
}
}
?>