| 1 | <?PHP |
| 2 | require_once "Mail.php"; // Pear Mail Library |
| 3 | include_once('/var/www/secure.php'); // provides $gmail_email_user & $gmail_email_pass |
| 4 | |
| 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=''){ |
| 7 | global $gmail_email_user; |
| 8 | global $gmail_email_pass; |
| 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.'>'; |
| 31 | $subject = $sub.' [MD-Petition.com]'; |
| 32 | $body = "$msg <br><br><br><br> MD Petition Support $custom_email_user <br> https://www.md-petition.com "; |
| 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 | ); |
| 40 | $smtp = Mail::factory('smtp', array( |
| 41 | 'host' => $custom_email_server, |
| 42 | 'port' => $custom_email_port, |
| 43 | 'auth' => true, |
| 44 | 'username' => $custom_email_user, |
| 45 | 'password' => $custom_email_pass |
| 46 | )); |
| 47 | $mail = $smtp->send($to, $headers, $body); |
| 48 | if (PEAR::isError($mail)) { |
| 49 | return $mail->getMessage(); |
| 50 | } else { |
| 51 | return 'NO ERROR'; |
| 52 | } |
| 53 | |
| 54 | } |