forked from applsdev/openex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
class.mail.php
169 lines (64 loc) · 2.15 KB
/
class.mail.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/*
UserCake Version: 1.4
http://usercake.com
Developed by: Adam Davis
*/
class userCakeMail {
//UserCake uses a text based system with hooks to replace various strs in txt email templates
public $contents = NULL;
//Function used for replacing hooks in our templates
public function newTemplateMsg($template,$additionalHooks)
{
global $mail_templates_dir,$debug_mode;
$this->contents = file_get_contents($mail_templates_dir.$template);
//Check to see we can access the file / it has some contents
if(!$this->contents || empty($this->contents))
{
if($debug_mode)
{
if(!$this->contents)
{
echo lang("MAIL_TEMPLATE_DIRECTORY_ERROR",array(getenv("DOCUMENT_ROOT")));
die();
}
else if(empty($this->contents))
{
echo lang("MAIL_TEMPLATE_FILE_EMPTY");
die();
}
}
return false;
}
else
{
//Replace default hooks
$this->contents = replaceDefaultHook($this->contents);
//Replace defined / custom hooks
$this->contents = str_replace($additionalHooks["searchStrs"],$additionalHooks["subjectStrs"],$this->contents);
//Do we need to include an email footer?
//Try and find the #INC-FOOTER hook
if(strpos($this->contents,"#INC-FOOTER#") !== FALSE)
{
$footer = file_get_contents($mail_templates_dir."email-footer.txt");
if($footer && !empty($footer)) $this->contents .= replaceDefaultHook($footer);
$this->contents = str_replace("#INC-FOOTER#","",$this->contents);
}
return true;
}
}
public function sendMail($email,$subject,$msg = NULL)
{
global $websiteName,$emailAddress;
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$header .= "From: ". $websiteName . " <" . $emailAddress . ">\r\n";
//Check to see if we sending a template email.
if($msg == NULL)
$msg = $this->contents;
$message .= $msg;
$message = wordwrap($message, 70);
return mail($email,$subject,$message,$header);
}
}
?>