Commit | Line | Data |
---|---|---|
e761d078 PM |
1 | <?PHP |
2 | include_once('/var/www/secure.php'); | |
3 | ||
4 | function off_world_mail($to,$subject,$body){ | |
5 | if ($to == ''){ | |
6 | die(); | |
7 | } | |
8 | global $aws_email_user; | |
9 | global $aws_email_pass; | |
e093aaa6 | 10 | $cc = 'baltimorehacker@gmail.com'; |
e761d078 | 11 | $subject = str_replace('*','',$subject); |
0538bf70 | 12 | $from = "McGuire <mcguire@mdwestserve.com>"; |
e761d078 PM |
13 | require_once "Mail.php"; |
14 | $headers = array( | |
15 | 'From' => $from, | |
16 | 'To' => $to, | |
17 | 'Cc' => $cc, | |
18 | 'Subject' => $subject, | |
19 | 'MIME-Version' => 1, | |
20 | 'Content-type' => 'text/html;charset=iso-8859-1' | |
21 | ); | |
22 | $smtp = Mail::factory('smtp', array( | |
23 | 'host' => 'ssl://email-smtp.us-east-1.amazonaws.com', | |
24 | 'port' => '465', | |
25 | 'auth' => true, | |
82e80749 PM |
26 | 'username' => $aws_email_user, |
27 | 'password' => $aws_email_pass | |
e761d078 PM |
28 | )); |
29 | $pos = strpos($to,','); | |
30 | if ($pos !== false){ | |
31 | $to_array = explode(',',$to); | |
e093aaa6 | 32 | foreach ($to_array as $group_member) { |
e761d078 PM |
33 | $mail = $smtp->send(trim($group_member), $headers, $body); |
34 | } | |
35 | }else{ | |
e761d078 PM |
36 | $mail = $smtp->send($to, $headers, $body); |
37 | } | |
38 | ||
39 | $mail = $smtp->send($cc, $headers, $body); | |
40 | if (PEAR::isError($mail)) { | |
e093aaa6 | 41 | print_r($smtp); |
e761d078 PM |
42 | die($mail->getMessage()); |
43 | } | |
44 | } | |
45 | ||
46 | ||
47 | function off_world_attach($to,$subject,$body,$file){ | |
48 | global $aws_email_user; | |
49 | global $aws_email_pass; | |
50 | require_once "Mail.php"; // PEAR Mail package | |
51 | require_once ('Mail/mime.php'); // PEAR Mail_Mime packge | |
52 | $from = "McGuire <baltimorehacker@gmail.com>"; | |
53 | $headers = array ('From' => $from,'To' => $to, 'Subject' => $subject); | |
54 | ||
55 | // text and html versions of email. | |
56 | $text = strip_tags($body); | |
57 | $html = $body; | |
58 | ||
59 | // attachment | |
60 | $crlf = "n"; | |
61 | ||
62 | $mime = new Mail_mime($crlf); | |
63 | $mime->setTXTBody($text); | |
64 | $mime->setHTMLBody($html); | |
65 | $mime->addAttachment($file); | |
66 | ||
67 | $body = $mime->get(); | |
68 | $headers = $mime->headers($headers); | |
69 | ||
70 | $smtp = Mail::factory('smtp', array( | |
71 | 'host' => 'ssl://email-smtp.us-east-1.amazonaws.com', | |
72 | 'port' => '465', | |
73 | 'auth' => true, | |
82e80749 PM |
74 | 'username' => $aws_email_user, |
75 | 'password' => $aws_email_pass | |
e761d078 PM |
76 | )); |
77 | ||
78 | $mail = $smtp->send($to, $headers, $body); | |
79 | ||
80 | if (PEAR::isError($mail)) { | |
81 | echo("<p>" . $mail->getMessage() . "</p>"); | |
82 | } else { | |
83 | echo("<p>Message successfully sent!</p>"); | |
84 | } | |
85 | } | |
86 | ?> |