function send_email($to, $from, $cc = '', $bcc = '', $subject, $message) { LOG_MSG('INFO', "send_email(): START EMAILER_HOST=[" . EMAILER_HOST . "] to=[{$to}] from=[{$from}] cc=[{$cc}] bcc=[{$bcc}] subject=[{$subject}]"); // Defaults if (!$bcc) { $bcc = EMAIL_BCC; } // Add footer to the message ob_start(); include HTML_DIR . '/emails/email_footer.html'; $message .= ob_get_contents(); ob_get_clean(); $headers = "Content-Type: text/html\r\n"; //."MIME-Version: 1.0\r\n" //."charset=utf-8\r\n" //."Content-Transfer-Encoding: 8bit\r\n" //."X-Mailer: Shopnix - eCommerce Solution\r\n"; // To store subject whithout appending with SHOP_NAME $plain_subject = $subject; $subject = "[" . SHOP_NAME . "] {$subject}"; // Setup parameters $status = 'SUCCESS'; if (EMAILER_HOST == 'LOCAL') { $emailer_host = $_SERVER['SERVER_NAME']; $headers .= "From: {$from}\r\n"; $headers .= "CC: {$cc}\r\n"; $headers .= "Bcc: {$bcc}\r\n"; $resp = mail($to, $subject, $message, $headers); // SEND EMAIL if ($resp) { $status = 'SUCCESS'; } else { $status = 'FAILED'; } } elseif (EMAILER_HOST == 'REMOTE') { $headers .= "From:{$from} \nCC: {$cc} \nBcc: {$bcc}"; $from = urlencode($from); $to = urlencode($to); $cc = urlencode($cc); $bcc = urlencode($bcc); $subject = urlencode($subject); $url = ""; $resp = curl_post($url, $message); // SEND EMAIL $emailer_host = 'cloudnix.com'; } elseif (EMAILER_HOST == 'MANDRILL') { // Setup data $sw_from = convert_email($from); $sw_to = convert_email($to); $text = strip_tags($message); $html = $message; $emailer_host = 'Mandrill'; // Setup connection info $transport = Swift_SmtpTransport::newInstance('smtp.mandrillapp.com1', 587); $transport->setUsername(SMTP_USERNAME); $transport->setPassword(SMTP_PASSWORD); $swift = Swift_Mailer::newInstance($transport); // Setup Data object $sw_message = new Swift_Message($subject); $sw_message->setFrom($sw_from); $sw_message->setBody($html, 'text/html'); $sw_message->setTo($sw_to); $sw_message->addPart($text, 'text/plain'); if ($bcc) { $sw_bcc = convert_email($bcc); //echo "<pre>Setting BCC[$bcc] to [".print_r($sw_bcc,true)."]</pre>"; $sw_message->setBcc($sw_bcc); } if ($cc) { $sw_cc = convert_email($cc); //echo "<pre>Setting CC[$cc] to [".print_r($sw_cc,true)."]</pre>"; $sw_message->setCc($sw_cc); } // Send mail if ($recipients = $swift->send($sw_message, $failures)) { $resp = true; $status = 'SUCCESS'; } else { LOG_MSG('ERROR', "send_email(MANDRILL): Error sending email=[" . print_r($failures, true) . "]"); $resp = false; $status = 'FAILED'; } } else { LOG_MSG("INFO", "EMAILER_HOST is OFF. Not sending email"); $status = 'NOT SENT'; $resp = true; } $email_resp = db_emails_insert($from, $to, $cc, $bcc, $plain_subject, $message, $status, $headers, EMAILER_HOST); if ($email_resp['STATUS'] != 'OK') { LOG_MSG('ERROR', "send_email(): Error while inserting in EMails talble from=[{$from}] to=[{$to}]"); } LOG_MSG("INFO", "\n\t******************************EMAIL START[{$status}]******************************\n\tTO: [{$to}]\n\t{$headers}\n\tSUBJECT:[{$subject}]\n\t{$message}\n\t******************************EMAIL END******************************"); return $resp; }
function send_email($to, $from, $cc = '', $bcc = '', $subject, $message, $attachments_arr = '', $plain_message = '', $field_type = "pdf") { LOG_MSG('INFO', "send_email(): START EMAILER_HOST=[" . EMAILER_HOST . "] to=[{$to}] from=[{$from}] cc=[{$cc}] bcc=[{$bcc}] subject=[{$subject}]"); // Defaults $EOL = PHP_EOL; $separator = md5(time()); if (!$bcc) { $bcc = EMAIL_BCC; } // Copy of the message without the attachment details // required to insert into the db if ($plain_message == '') { $plain_message = $message; } $plain_subject = $subject; // The subject should have the shop domain if (defined('SHOP_NAME')) { $subject = "[" . SHOP_NAME . "] {$subject}"; } else { $subject = "[" . SITE_NAME . "] {$subject}"; } // common headers $headers = "From: {$from} {$EOL}"; $headers .= "CC: {$cc} {$EOL}"; $headers .= "Bcc: {$bcc} {$EOL}"; if ($attachments_arr) { // main header $headers .= "MIME-Version: 1.0" . $EOL; $headers .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\""; // body //$body = "--".$separator.$EOL; $body = "Content-Transfer-Encoding: 7bit" . $EOL . $EOL; $body .= "--" . $separator . $EOL; $body .= "Content-Type: text/html; charset=\"iso-8859-1\"" . $EOL; $body .= "Content-Transfer-Encoding: 8bit" . $EOL . $EOL; $body .= $message . $EOL; // attachment $attachment = chunk_split(base64_encode($attachments_arr[0]['data'])); $body .= "--" . $separator . $EOL; $body .= "Content-Type: application/octet-stream; name=\"" . $attachments_arr[0]['filename'] . "\"" . $EOL; $body .= "Content-Transfer-Encoding: base64" . $EOL; $body .= "Content-Disposition: attachment" . $EOL . $EOL; $body .= $attachment . $EOL; $body .= "--" . $separator . "--"; $message = $body; } else { $headers .= "Content-Type: text/html {$EOL}"; $headers .= "MIME-Version: 1.0 {$EOL}"; //$headers.="charset=utf-8 $EOL"; $headers .= "Content-Transfer-Encoding: 8bit {$EOL}"; $headers .= "X-Mailer: Shopnix - eCommerce Solution {$EOL}"; } // Setup parameters $status = 'SUCCESS'; if (EMAILER_HOST == 'LOCAL') { $emailer_host = $_SERVER['SERVER_NAME']; $resp = mail($to, $subject, $message, $headers); // SEND EMAIL if ($resp) { $status = 'SUCCESS'; } else { $status = 'FAILED'; } } elseif (EMAILER_HOST == 'REMOTE') { $headers .= "From:{$from} \nCC: {$cc} \nBcc: {$bcc}"; $from = urlencode($from); $to = urlencode($to); $cc = urlencode($cc); $bcc = urlencode($bcc); $subject = urlencode($subject); $url = "http://mitnix.in/snix/modules/utils/emailer.php?to={$to}&from={$from}&cc={$cc}&bcc={$bcc}&sub={$subject}"; $resp = curl_post($url, $message); // SEND EMAIL $emailer_host = 'cloudnix.com'; } elseif (EMAILER_HOST == 'MANDRILL') { // Setup data $sw_from = convert_email($from); $sw_to = convert_email($to); $text = strip_tags($plain_message); $html = $plain_message; $emailer_host = 'Mandrill'; // Setup connection info $transport = Swift_SmtpTransport::newInstance('smtp.mandrillapp.com', 587); $transport->setUsername(SMTP_USERNAME); $transport->setPassword(SMTP_PASSWORD); $swift = Swift_Mailer::newInstance($transport); // Setup Data object $message = new Swift_Message($subject); $message->setFrom($sw_from); $message->setBody($html, 'text/html'); $message->setTo($sw_to); $message->addPart($text, 'text/plain'); if ($bcc) { $sw_bcc = convert_email($bcc); //echo "<pre>Setting BCC[$bcc] to [".print_r($sw_bcc,true)."]</pre>"; $message->setBcc($sw_bcc); } if ($cc) { $sw_cc = convert_email($cc); //echo "<pre>Setting CC[$cc] to [".print_r($sw_cc,true)."]</pre>"; $message->setCc($sw_cc); } if ($attachments_arr) { // Create the attachment with your data $attachment = Swift_Attachment::newInstance($attachments_arr[0]['data'], $attachments_arr[0]['filename'], "application/{$field_type}"); // Attach it to the message $message->attach($attachment); } // Send mail if ($recipients = $swift->send($message, $failures)) { $resp = true; $status = 'SUCCESS'; } else { LOG_MSG('ERROR', "send_email(MANDRILL): Error sending email=[" . print_r($failures, true) . "]"); $resp = false; $status = 'FAILED'; } } else { LOG_MSG("INFO", "EMAILER_HOST is OFF. Not sending email"); $status = 'NOT SENT'; $resp = true; } if (defined('SHOP_ID') && $from != '*****@*****.**') { // Don't store security emails $email_resp = db_emails_insert($from, $to, $cc, $bcc, $plain_subject, $plain_message, $status, $headers, $emailer_host); if ($email_resp['STATUS'] != 'OK') { LOG_MSG('ERROR', "send_email(): Error while inserting in EMails talble from=[{$from}] to=[{$to}]"); } } LOG_MSG("INFO", "\n\t******************************EMAIL START [{$status}]******************************\n\tTO: [{$to}]\n\t{$headers}\n\tSUBJECT:[{$subject}]\n\t{$plain_message}\n\t******************************EMAIL END******************************"); return $resp; }
echo '</li>' . "\n" . ' <li><strong>-f Parameter Assignment</strong> — '; echo $neg_f_param; echo '</li>' . "\n" . ' <li><strong>SMTP Sneak Pseudo Bypass Method</strong> — '; echo $smtp_sneak; echo '</li>' . "\n" . ' <li><strong>INI Set Switch Variable</strong> — '; echo $ini_set; echo '</li>' . "\n" . ' <li><strong>SMTP Mail Server</strong> — '; echo $smtp; echo '</li>' . "\n" . ' <li><strong>SMTP Mail Port Variable</strong> — '; echo $smtp_port; echo '</li>' . "\n" . ' <li><strong>SMTP Mail Password Variable</strong> — '; echo md5($smtp_password); echo ' (shown hashed for security)</li>' . "\n" . ' <li><strong>SMTP Mail Username Variable</strong> — '; echo md5($smtp_username); echo ' (shown hashed for security)</li>' . "\n" . ' <li><strong>Send Email Variable (modified)</strong> — <span>'; echo convert_email($sendmail_from); echo '</span></li>' . "\n" . ' <li><strong>Send Email Variable Path</strong> — '; echo $sendmail_path; echo '</li>' . "\n" . ' <li><strong>Alternate Form Action</strong> — '; if ($form_action == "") { echo 'An alternate form action is not specified.'; } else { echo $form_action; } echo '</li>' . "\n" . ' <li><strong>Form Lockdown Mode</strong> — '; echo $form_lockdown; echo '</li>' . "\n" . ' <li><strong>Allowed User by IP</strong> — '; if ($form_lockdown == "yes" && $allow_ip != "") { echo 'User allowed: <span>'; echo $allow_ip; echo '</span>';