-
Notifications
You must be signed in to change notification settings - Fork 8
/
Mail.php
55 lines (45 loc) · 1.75 KB
/
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
<?php
/**
* @version 1.0
* @author Paul Dragoonis <dragoonis@php.net>
* @license http://opensource.org/licenses/mit-license.php MIT
* @copyright Digiflex Development
* @package Core
* @link www.ppiframework.com
*/
class PPI_Mail {
/**
* PPI Mail Sending Functioin
* @param array $p_aOptions The options for sending to the mail library
* @uses $p_aOptions[subject, body, toaddr] are all mandatory.
* @uses Options available are toname
* @return boolean The result of the mail sending process
*/
static function sendMail(array $p_aOptions) {
$oConfig = PPI_Helper::getConfig();
$oEmail = new PPI_Model_Email_Advanced();
if(!isset($p_aOptions['subject'], $p_aOptions['body'], $p_aOptions['toaddr'])) {
throw new PPI_Exception('Invalid parameters to sendMail');
}
$oEmail->Subject = $p_sSubject;
if(isset($p_aOptions['fromaddr'], $p_aOptions['fromname'])) {
$oEmail->SetFrom($p_aOptions['fromaddr'], $p_aOptions['fromname']);
} elseif(isset($p_aOptions['fromaddr'])) {
$oEmail->SetFrom($p_aOptions['fromaddr']);
} else {
$oEmail->SetFrom($oConfig->system->adminEmail, $oConfig->system->adminName);
}
if(isset($p_aOptions['toaddr'], $p_aOptions['toname'])) {
$oEmail->AddAddress($p_aOptions['toaddr'], $p_aOptions['toname']);
} elseif(isset($p_aOptions['toaddr'])) {
$oEmail->AddAddress($p_aOptions['toaddr']);
}
if(isset($p_aOptions['altbody'])) {
$oEmail->AltBody = $p_sMessage;
}
$oEmail->MsgHTML($p_aOptions['body']);
// If the email sent successfully,
return $oEmail->Send();
// @todo - Log the email sending process.
}
}