Commit | Line | Data |
---|---|---|
5c66ac11 | 1 | <?PHP |
aa865293 PM |
2 | require_once "Mail.php"; // Pear Mail Library |
3 | include_once('/var/www/secure.php'); // provides $gmail_email_user & $gmail_email_pass | |
5c66ac11 | 4 | |
aa865293 PM |
5 | // USAGE meps_mail('Patrick <baltimorehacker@gmail.com>','I just wanted to take a second and follow up with your visit to md-petition.com and see if you needed anything, or had any questions.','Petition Follow-Up','1'); |
6 | function meps_mail($to,$msg,$sub,$custom_mail_server=''){ | |
a52532ef PM |
7 | global $gmail_email_user; |
8 | global $gmail_email_pass; | |
aa865293 PM |
9 | $custom_mail_server = intval($custom_mail_server); |
10 | if ($custom_mail_server != 0){ | |
11 | /* | |
12 | email_smtp_server varchar(300) | |
13 | email_smtp_port varchar(300) | |
14 | email_smtp_user varchar(300) | |
15 | email_smtp_pass varchar(300) | |
16 | */ | |
17 | $r = $petition->query("select * from petition where petition_id = '$custom_mail_server' "); | |
18 | $d = mysqli_fetch_array($r,MYSQLI_ASSOC); | |
19 | $custom_email_user = $d['email_smtp_user']; | |
20 | $custom_email_pass = $d['email_smtp_pass']; | |
21 | $custom_email_server = $d['email_smtp_server']; | |
22 | $custom_email_port = $d['email_smtp_port']; | |
23 | }else{ | |
24 | // Use Our G-Mail Server | |
25 | $custom_email_server = 'ssl://smtp.gmail.com'; | |
26 | $custom_email_port = '465'; | |
27 | $custom_email_user = $gmail_email_user; | |
28 | $custom_email_pass = $gmail_email_pass; | |
29 | } | |
30 | $from = 'Petition Support <'.$custom_email_user.'>'; | |
5d9a356a | 31 | $subject = $sub.' [MD-Petition.com]'; |
aa865293 | 32 | $body = "$msg <br><br><br><br> MD Petition Support $custom_email_user <br> https://www.md-petition.com "; |
a52532ef PM |
33 | $headers = array( |
34 | 'From' => $from, | |
35 | 'To' => $to, | |
36 | 'Subject' => $subject, | |
37 | 'MIME-Version' => 1, | |
38 | 'Content-type' => 'text/html;charset=iso-8859-1' | |
39 | ); | |
a52532ef | 40 | $smtp = Mail::factory('smtp', array( |
aa865293 PM |
41 | 'host' => $custom_email_server, |
42 | 'port' => $custom_email_port, | |
a52532ef | 43 | 'auth' => true, |
aa865293 PM |
44 | 'username' => $custom_email_user, |
45 | 'password' => $custom_email_pass | |
a52532ef | 46 | )); |
a52532ef | 47 | $mail = $smtp->send($to, $headers, $body); |
a52532ef | 48 | if (PEAR::isError($mail)) { |
13d3ff0f | 49 | return $mail->getMessage(); |
a52532ef | 50 | } else { |
13d3ff0f | 51 | return 'NO ERROR'; |
a52532ef | 52 | } |
aa865293 | 53 | |
46790afe | 54 | } |