function sendMail($hostname, $hostport, $localhost, $smtp_user, $smtp_pass, $sender, $recipients, $subject, $body) { // ini_set('smtp',$hostname); $smtp = new smtp_class(); $smtp->host_name = $hostname; $smtp->host_port = $hostport; $smtp->localhost = $localhost; $smtp->user = $smtp_user; $smtp->password = $smtp_pass; //$smtp->debug=1; //DEBUG $date = strftime("%a, %d %b %Y %H:%M:%S %Z"); $recipients_in_string = implode(', ', $recipients); //Turn recipients array to string comma separated $headers = array("From: {$sender}", "To: {$recipients_in_string}", "Subject: {$subject}", "Date: {$date}"); if ($smtp->SendMessage($sender, $recipients, $headers, $body)) { return true; } else { echo $smtp->error; //DEBUG return false; } }
* Windows or any other platform that does not have enabled the MX * resolution function GetMXRR() , you need to include code that emulates * that function so the class knows which SMTP server it should connect * to deliver the message directly to the recipient SMTP server. */ if ($smtp->direct_delivery) { if (!function_exists("GetMXRR")) { /* * If possible specify in this array the address of at least on local * DNS that may be queried from your network. */ $_NAMESERVERS = array(); include "getmxrr.php"; } } if ($smtp->SendMessage($from, array($to), array("MIME-Version: 1.0", "Content-Type: multipart/mixed; boundary=\"PHP-mixed-" . $random_hash . "\"", "From: " . $from, "To: " . $to, "Subject: " . $_POST['subject'], "Date: " . strftime("%a, %d %b %Y %H:%M:%S %Z")), $message)) { $userArray = explode("\\", $authUser); if ($smtp->SendMessage($from, array($userArray[1] . "@usimagingnetwork.com"), array("MIME-Version: 1.0", "Content-Type: multipart/mixed; boundary=\"PHP-mixed-" . $random_hash . "\"", "From: " . $from, "To: " . $userArray[1] . "@usimagingnetwork.com", "Subject: [COPY OF CONFIRMATION EMAIL SENT]" . $_POST['subject'], "Date: " . strftime("%a, %d %b %Y %H:%M:%S %Z")), $message)) { echo " "; } unlink($target_path); unlink($target_path2); unlink($target_path3); echo "<p class=\"pAlignRight\"><a class=\"aSmall\" href=\"#\" id=\"aCancel\" name=\"aCancel\" onclick=\"javascript:window.opener='x';window.close();\">Close [x]</a></p>"; echo "<i>The following email has been sent to " . $to . ":</i><br><br>"; echo "<div class=\"divGrey\">"; echo $HTMLmsg; echo "</div>"; if (basename($_FILES['myfile']['name']) != "") { echo "<p>With attachment: " . $target_path . "</p>"; }
function cron_SendMail($to, $subject, $vBody, $from) { // check if smtp globals set if ($GLOBALS['smtp_host_name'] == '') { // larry :: debug //echo "\nDEBUG :: use mail method\n"; // larry :: add cc/bcc - bot used ? $cc = ""; $bcc = ""; $format = ""; // mdsupport - replaces 0 which causes gmail formatting / display problems. //echo "function called";exit; if (strlen($format) == 0) { $format = "text/html"; } $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: " . $format . "; charset=iso-8859-1\r\n"; // additional headers $headers .= "From: {$from}\r\n"; if (strlen($cc) > 5) { $headers .= "Cc: {$cc}\r\n"; } if (strlen($bcc) > 5) { $headers .= "Bcc: {$bcc}\r\n"; } $cnt = ""; $cnt .= "\nHeaders : " . $headers; $cnt .= "\nDate Time :" . date("d M, Y h:i:s"); $cnt .= "\nTo : " . $to; $cnt .= "\nSubject : " . $subject; $cnt .= "\nBody : \n" . $vBody . "\n"; if (1) { //WriteLog($cnt); } $mstatus = true; $mstatus = @mail($to, $subject, $vBody, $headers); // larry :: debug //echo "\nDEBUG :email: send email from=".$from." to=".$to." sbj=".$subject." body=".$vBody." head=".$headers."\n"; //echo "\nDEBUG :email: send status=".$mstatus."\n"; } else { // larry :: debug //echo "\nDEBUG :: use smtp method\n"; if (!class_exists("smtp_class")) { include "../../library/classes/smtp/smtp.php"; include "../../library/classes/smtp/sasl.php"; } $strFrom = $from; $sender_line = __LINE__; $strTo = $to; $recipient_line = __LINE__; if (strlen($strFrom) == 0) { return false; } if (strlen($strTo) == 0) { return false; } //if( !$smtp ) $smtp = new smtp_class(); $smtp->host_name = $GLOBALS['smtp_host_name']; $smtp->host_port = $GLOBALS['smtp_host_port']; $smtp->ssl = $GLOBALS['smtp_use_ssl']; $smtp->localhost = $GLOBALS['smtp_localhost']; $smtp->direct_delivery = 0; $smtp->timeout = 10; $smtp->data_timeout = 0; $smtp->debug = 1; $smtp->html_debug = 0; $smtp->pop3_auth_host = ""; $smtp->user = $GLOBALS['smtp_auth_user']; $smtp->password = $GLOBALS['smtp_auth_pass']; $smtp->realm = ""; // Workstation name for NTLM authentication $smtp->workstation = ""; // Specify a SASL authentication method like LOGIN, PLAIN, CRAM-MD5, NTLM, etc.. // Leave it empty to make the class negotiate if necessary $smtp->authentication_mechanism = ""; // If you need to use the direct delivery mode and this is running under // Windows or any other platform if ($smtp->direct_delivery) { if (!function_exists("GetMXRR")) { $_NAMESERVERS = array(); include "getmxrr.php"; } } if ($smtp->SendMessage($strFrom, array($strTo), array("From: {$strFrom}", "To: {$strTo}", "Subject: {$subject}", "Date Time :" . date("d M, Y h:i:s")), $vBody)) { echo "Message sent to {$to} OK.\n"; $mstatus = true; } else { echo "Cound not send the message to {$to}.\nError: " . $smtp->error . "\n"; $mstatus = false; } unset($smtp); } return $mstatus; }
/* else { $_NAMESERVERS=array(); if(count($_NAMESERVERS)==0) Unset($_NAMESERVERS); include("rrcompat.php"); $smtp->getmxrr="_getmxrr"; } */ $smtp->host_name = getenv("HOSTNAME"); /* relay SMTP server address */ $smtp->localhost = "localhost"; /* this computer address */ $from = getenv("USER") . "@" . $smtp->host_name; $to = "*****@*****.**"; $smtp->direct_delivery = 0; /* Set to 1 to deliver directly to the recepient SMTP server */ $smtp->debug = 0; /* Set to 1 to output the communication with the SMTP server */ $smtp->user = ""; /* Set to the user name if the server requires authetication */ $smtp->realm = ""; /* Set to the authetication realm, usually the authentication user e-mail domain */ $smtp->password = ""; /* Set to the authetication password */ if ($smtp->SendMessage($from, array($to), array("From: {$from}", "To: {$to}", "Subject: Testing Manuel Lemos' SMTP class", "Date: " . strftime("%a, %d %b %Y %H:%M:%S %Z")), "Hello {$to},\n\nIt is just to let you know that your SMTP class is working just fine.\n\nBye.\n")) { echo "Message sent to {$to} OK.\n"; } else { echo "Cound not send the message to {$to}.\nError: " . $smtp->error . "\n"; }
function hesk_mail($to, $subject, $message, $htmlMessage, $cc = array(), $bcc = array(), $hasMessageTag = false) { global $hesk_settings, $hesklang, $modsForHesk_settings, $ticket; // Demo mode if (defined('HESK_DEMO')) { return true; } // Encode subject to UTF-8 $subject = "=?UTF-8?B?" . base64_encode(hesk_html_entity_decode($subject)) . "?="; // Auto-generate URLs for HTML-formatted emails $htmlMessage = hesk_makeURL($htmlMessage, '', false); // Setup "name <email>" for headers if ($hesk_settings['noreply_name']) { $hesk_settings['from_header'] = "=?UTF-8?B?" . base64_encode(hesk_html_entity_decode($hesk_settings['noreply_name'])) . "?= <" . $hesk_settings['noreply_mail'] . ">"; } else { $hesk_settings['from_header'] = $hesk_settings['noreply_mail']; } // Uncomment for debugging # echo "<p>TO: $to<br >SUBJECT: $subject<br >MSG: $message</p>"; # return true; // Use mailgun if ($modsForHesk_settings['use_mailgun']) { ob_start(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://api.mailgun.net/v2/" . $modsForHesk_settings['mailgun_domain'] . "/messages"); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, 'api:' . $modsForHesk_settings['mailgun_api_key']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_POST, true); $postfields = array('from' => $hesk_settings['from_header'], 'to' => $to, 'h:Reply-To' => $hesk_settings['from_header'], 'subject' => $subject, 'text' => $message); if (count($cc) > 0) { $postfields['cc'] = implode(',', $cc); } if (count($bcc) > 0) { $postfields['bcc'] = implode(',', $bcc); } if ($modsForHesk_settings['html_emails']) { $postfields['html'] = $htmlMessage; } if ($hasMessageTag && $modsForHesk_settings['attachments'] && $hesk_settings['attachments']['use'] && isset($ticket['attachments']) && strlen($ticket['attachments'])) { $postfields = processDirectAttachments('mailgun', $postfields); } curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); $result = curl_exec($ch); curl_close($ch); $tmp = trim(ob_get_contents()); ob_end_clean(); return strlen($tmp) ? $tmp : true; } $outerboundary = sha1(uniqid()); $innerboundary = sha1(uniqid()); if ($outerboundary == $innerboundary) { $innerboundary .= '1'; } $plaintextMessage = $message; $message = "--" . $outerboundary . "\n"; $message .= "Content-Type: multipart/alternative; boundary=\"" . $innerboundary . "\"\n\n"; $message .= "--" . $innerboundary . "\n"; $message .= "Content-Type: text/plain; charset=" . $hesklang['ENCODING'] . "\n\n"; $message .= $plaintextMessage . "\n\n"; //Prepare the message for HTML or non-html if ($modsForHesk_settings['html_emails']) { $message .= "--" . $innerboundary . "\n"; $message .= "Content-Type: text/html; charset=" . $hesklang['ENCODING'] . "\n\n"; $message .= $htmlMessage . "\n\n"; } //-- Close the email $message .= "--" . $innerboundary . "--"; // Use PHP's mail function if (!$hesk_settings['smtp']) { // Set additional headers $headers = ''; $headers .= "MIME-Version: 1.0\n"; $headers .= "From: {$hesk_settings['from_header']}\n"; if (count($cc) > 0) { $headers .= "Cc: " . implode(',', $cc); } if (count($bcc) > 0) { $headers .= "Bcc: " . implode(',', $bcc); } $headers .= "Reply-To: {$hesk_settings['from_header']}\n"; $headers .= "Return-Path: {$hesk_settings['webmaster_mail']}\n"; $headers .= "Date: " . date(DATE_RFC2822) . "\n"; $headers .= "Content-Type: multipart/mixed;boundary=\"" . $outerboundary . "\""; // Add attachments if necessary if ($hasMessageTag && $modsForHesk_settings['attachments'] && $hesk_settings['attachments']['use'] && isset($ticket['attachments']) && strlen($ticket['attachments'])) { $message .= processDirectAttachments('phpmail', NULL, $outerboundary); } $message .= "\n\n" . '--' . $outerboundary . '--'; // Send using PHP mail() function ob_start(); mail($to, $subject, $message, $headers); $tmp = trim(ob_get_contents()); ob_end_clean(); return strlen($tmp) ? $tmp : true; } // Use a SMTP server directly instead $smtp = new smtp_class(); $smtp->host_name = $hesk_settings['smtp_host_name']; $smtp->host_port = $hesk_settings['smtp_host_port']; $smtp->timeout = $hesk_settings['smtp_timeout']; $smtp->ssl = $hesk_settings['smtp_ssl']; $smtp->start_tls = $hesk_settings['smtp_tls']; $smtp->user = $hesk_settings['smtp_user']; $smtp->password = hesk_htmlspecialchars_decode($hesk_settings['smtp_password']); $smtp->debug = 1; // Start output buffering so that any errors don't break headers ob_start(); // Send the e-mail using SMTP $to_arr = explode(',', $to); $headersArray = array("From: {$hesk_settings['from_header']}", "To: {$to}", "Reply-To: {$hesk_settings['from_header']}", "Return-Path: {$hesk_settings['webmaster_mail']}", "Subject: " . $subject, "Date: " . date(DATE_RFC2822)); array_push($headersArray, "MIME-Version: 1.0"); array_push($headersArray, "Content-Type: multipart/mixed;boundary=\"" . $outerboundary . "\""); if (count($cc) > 0) { array_push($headersArray, "Cc: " . implode(',', $cc)); } if (count($bcc) > 0) { array_push($headersArray, "Bcc: " . implode(',', $bcc)); } // Add attachments if necessary if ($hasMessageTag && $modsForHesk_settings['attachments'] && $hesk_settings['attachments']['use'] && isset($ticket['attachments']) && strlen($ticket['attachments'])) { $message .= processDirectAttachments('smtp', NULL, $outerboundary); } $message .= "\n\n" . '--' . $outerboundary . '--'; if (!$smtp->SendMessage($hesk_settings['noreply_mail'], $to_arr, $headersArray, $message)) { // Suppress errors unless we are in debug mode if ($hesk_settings['debug_mode']) { $error = $hesklang['cnsm'] . ' ' . $to . '<br /><br />' . $hesklang['error'] . ': ' . htmlspecialchars($smtp->error) . '<br /><br />' . '<textarea name="smtp_log" rows="10" cols="60">' . ob_get_contents() . '</textarea>'; ob_end_clean(); hesk_error($error); } else { $_SESSION['HESK_2ND_NOTICE'] = true; $_SESSION['HESK_2ND_MESSAGE'] = $hesklang['esf'] . ' ' . $hesklang['contact_webmsater'] . ' <a href="mailto:' . $hesk_settings['webmaster_mail'] . '">' . $hesk_settings['webmaster_mail'] . '</a>'; } } ob_end_clean(); return true; }
* Windows or any other platform that does not have enabled the MX * resolution function GetMXRR() , you need to include code that emulates * that function so the class knows which SMTP server it should connect * to deliver the message directly to the recipient SMTP server. */ if ($smtp->direct_delivery) { if (!function_exists("GetMXRR")) { /* * If possible specify in this array the address of at least on local * DNS that may be queried from your network. */ $_NAMESERVERS = array(); include "php/getmxrr.php"; } } if ($smtp->SendMessage($from, array($to), array("From: " . $from, "To: " . $to, "Subject: " . $subject, "Content-Type: text/html; charset=\"iso-8859-1\"", "MIME-Version: 1.0", "Date: " . strftime("%a, %d %b %Y %H:%M:%S %Z")), $msg1)) { echo "SUCCESS: Email Successfully Sent to Member"; /* $userArray=explode("\\",$_SERVER["AUTH_USER"]); if($_SERVER["AUTH_USER"]=="MARWOODGROUP\mhernandez") { $userArray[1]="mdurand"; } if($smtp->SendMessage ( $from, array($userArray[1]."@usimagingnetwork.com"), array( "From: ".$from, "To: ".$userArray[1]."@usimagingnetwork.com", "Subject: [COPY OF SURVEY EMAIL SENT]".$subject, //"Content-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"", "Content-Type: text/html; charset=\"iso-8859-1\"", "MIME-Version: 1.0",
function sendSMTPEmail($email_to, $email_from, $subject, $message, $host_name, $host_port, $ssl, $user, $password) { $smtp = new smtp_class(); $smtp->host_name = $host_name; // IP address Change this variable to the address of the SMTP server to relay, like "smtp.myisp.com" $smtp->host_port = $host_port; // Change this variable to the port of the SMTP server to use, like 465 $smtp->ssl = $ssl; // Change this variable if the SMTP server requires an secure connection using SSL $smtp->start_tls = 0; // Change this variable if the SMTP server requires security by starting TLS during the connection $smtp->localhost = "localhost"; // Your computer address $smtp->direct_delivery = 0; // Set to 1 to deliver directly to the recepient SMTP server $smtp->timeout = 10; // Set to the number of seconds wait for a successful connection to the SMTP server $smtp->data_timeout = 0; // Set to the number seconds wait for sending or retrieving data from the SMTP server. Set to 0 to use the same defined in the timeout variable $smtp->debug = 1; // Set to 1 to output the communication with the SMTP server $smtp->html_debug = 1; // Set to 1 to format the debug output as HTML $smtp->pop3_auth_host = ""; // Set to the POP3 authentication host if your SMTP server requires prior POP3 authentication $smtp->user = $user; // Set to the user name if the server requires authetication $smtp->realm = ""; // Set to the authetication realm, usually the authentication user e-mail domain $smtp->password = $password; // Set to the authetication password $smtp->workstation = ""; // Workstation name for NTLM authentication $smtp->authentication_mechanism = ""; // Specify a SASL authentication method like LOGIN, PLAIN, CRAM-MD5, NTLM, etc... Leave it empty to make the class negotiate if necessary if ($smtp->SendMessage($email_from, array($email_to), array("MIME-Version: 1.0", "Content-type: text/html; charset=iso-8859-1", "From: {$email_from}", "To: {$email_to}", "Subject: {$subject}", "Date: " . strftime("%a, %d %b %Y %H:%M:%S %Z")), "{$message}")) { //echo "Message sent to $email_to OK.\n"; } else { $this->sendEmail($email_to, $email_from, $subject, $message); //echo "Cound not send the message to $email_to.\nError: ".$smtp->error."\n"; } }
function SMTPMail($from, $to, $host, $port, $subject, $body) { // $from=$from; /* Change this to your address like "*****@*****.**"; */ $sender_line=__LINE__; // $to=""; /* Change this to your test recipient address */ $recipient_line=__LINE__; if (strlen($from) == 0) { die("Please set the messages sender address in line " . $sender_line . " of the script " . basename(__FILE__) . "\n"); } if (strlen($to) == 0) { die("Please set the messages recipient address in line " . $recipient_line . " of the script " . basename(__FILE__) . "\n"); } $smtp = new smtp_class(); $smtp->host_name = $host; /* Change this variable to the address of the SMTP server to relay, like "smtp.myisp.com" */ $smtp->host_port = $port; /* Change this variable to the port of the SMTP server to use, like 465 */ $smtp->ssl = 0; /* Change this variable if the SMTP server requires an secure connection using SSL */ $smtp->localhost = "localhost"; /* Your computer address */ $smtp->direct_delivery = 0; /* Set to 1 to deliver directly to the recepient SMTP server */ $smtp->timeout = 10; /* Set to the number of seconds wait for a successful connection to the SMTP server */ $smtp->data_timeout = 0; /* Set to the number seconds wait for sending or retrieving data from the SMTP server. Set to 0 to use the same defined in the timeout variable */ $smtp->debug = 1; /* Set to 1 to output the communication with the SMTP server */ $smtp->html_debug = 1; /* Set to 1 to format the debug output as HTML */ $smtp->pop3_auth_host = ""; /* Set to the POP3 authentication host if your SMTP server requires prior POP3 authentication */ $smtp->user = ""; /* Set to the user name if the server requires authetication */ $smtp->realm = ""; /* Set to the authetication realm, usually the authentication user e-mail domain */ $smtp->password = ""; /* Set to the authetication password */ $smtp->workstation = ""; /* Workstation name for NTLM authentication */ $smtp->authentication_mechanism = ""; /* Specify a SASL authentication method like LOGIN, PLAIN, CRAM-MD5, NTLM, etc.. Leave it empty to make the class negotiate if necessary */ /* * If you need to use the direct delivery mode and this is running under * Windows or any other platform that does not have enabled the MX * resolution function GetMXRR() , you need to include code that emulates * that function so the class knows which SMTP server it should connect * to deliver the message directly to the recipient SMTP server. */ if ($smtp->direct_delivery) { if (!function_exists("GetMXRR")) { /* * If possible specify in this array the address of at least on local * DNS that may be queried from your network. */ $_NAMESERVERS = array(); include "getmxrr.php"; } /* * If GetMXRR function is available but it is not functional, to use * the direct delivery mode, you may use a replacement function. */ /* else { $_NAMESERVERS=array(); if(count($_NAMESERVERS)==0) Unset($_NAMESERVERS); include("rrcompat.php"); $smtp->getmxrr="_getmxrr"; } */ } if ($smtp->SendMessage($from, array($to), array("From: {$from}", "To: {$to}", "Subject: {$subject}", "MIME-Version: 1.0\n", "Content-type: text/html; charset=iso-8859-1\r\n"), $body . "\n\nThank You.\n")) { } else { } // echo "Cound not send the message to $to.\nError: ".$smtp->error."\n"; }
function hesk_mail($to, $subject, $message) { global $hesk_settings, $hesklang; // Demo mode if (defined('HESK_DEMO')) { return true; } // Encode subject to UTF-8 $subject = "=?UTF-8?B?" . base64_encode(hesk_html_entity_decode($subject)) . "?="; // Setup "name <email>" for headers if ($hesk_settings['noreply_name']) { $hesk_settings['from_header'] = "=?UTF-8?B?" . base64_encode(hesk_html_entity_decode($hesk_settings['noreply_name'])) . "?= <" . $hesk_settings['noreply_mail'] . ">"; } else { $hesk_settings['from_header'] = $hesk_settings['noreply_mail']; } // Uncomment for debugging # echo "<p>TO: $to<br >SUBJECT: $subject<br >MSG: $message</p>"; # return true; // Use PHP's mail function if (!$hesk_settings['smtp']) { // Set additional headers $headers = "From: {$hesk_settings['from_header']}\n"; $headers .= "Reply-To: {$hesk_settings['from_header']}\n"; $headers .= "Return-Path: {$hesk_settings['webmaster_mail']}\n"; $headers .= "Date: " . date(DATE_RFC2822) . "\n"; $headers .= "Content-Type: text/plain; charset=" . $hesklang['ENCODING']; // Send using PHP mail() function ob_start(); mail($to, $subject, $message, $headers); $tmp = trim(ob_get_contents()); ob_end_clean(); return strlen($tmp) ? $tmp : true; } // Use a SMTP server directly instead $smtp = new smtp_class(); $smtp->host_name = $hesk_settings['smtp_host_name']; $smtp->host_port = $hesk_settings['smtp_host_port']; $smtp->timeout = $hesk_settings['smtp_timeout']; $smtp->ssl = $hesk_settings['smtp_ssl']; $smtp->start_tls = $hesk_settings['smtp_tls']; $smtp->user = $hesk_settings['smtp_user']; $smtp->password = hesk_htmlspecialchars_decode($hesk_settings['smtp_password']); $smtp->debug = 1; // Start output buffering so that any errors don't break headers ob_start(); // Send the e-mail using SMTP $to_arr = explode(',', $to); if (!$smtp->SendMessage($hesk_settings['noreply_mail'], $to_arr, array("From: {$hesk_settings['from_header']}", "To: {$to}", "Reply-To: {$hesk_settings['from_header']}", "Return-Path: {$hesk_settings['webmaster_mail']}", "Subject: " . $subject, "Date: " . date(DATE_RFC2822), "Content-Type: text/plain; charset=" . $hesklang['ENCODING']), $message)) { // Suppress errors unless we are in debug mode if ($hesk_settings['debug_mode']) { $error = $hesklang['cnsm'] . ' ' . $to . '<br /><br />' . $hesklang['error'] . ': ' . htmlspecialchars($smtp->error) . '<br /><br />' . '<textarea name="smtp_log" rows="10" cols="60">' . ob_get_contents() . '</textarea>'; ob_end_clean(); hesk_error($error); } else { $_SESSION['HESK_2ND_NOTICE'] = true; $_SESSION['HESK_2ND_MESSAGE'] = $hesklang['esf'] . ' ' . $hesklang['contact_webmsater'] . ' <a href="mailto:' . $hesk_settings['webmaster_mail'] . '">' . $hesk_settings['webmaster_mail'] . '</a>'; } } ob_end_clean(); return true; }
$smtp->localhost = "localhost"; /* Your computer address */ $smtp->direct_delivery = 0; /* Set to 1 to deliver directly to the recepient SMTP server */ $smtp->timeout = 10; /* Set to the number of seconds wait for a successful connection to the SMTP server */ $smtp->data_timeout = 0; /* Set to the number seconds wait for sending or retrieving data from the SMTP server. Set to 0 to use the same defined in the timeout variable */ $smtp->debug = 1; /* Set to 1 to output the communication with the SMTP server */ $smtp->html_debug = 1; /* Set to 1 to format the debug output as HTML */ $smtp->pop3_auth_host = ""; /* Set to the POP3 authentication host if your SMTP server requires prior POP3 authentication */ $smtp->user = "******"; /* Set to the user name if the server requires authetication */ $smtp->realm = ""; /* Set to the authetication realm, usually the authentication user e-mail domain */ $smtp->password = "******"; /* Set to the authetication password */ $smtp->workstation = ""; /* Workstation name for NTLM authentication */ $smtp->authentication_mechanism = ""; /* Specify a SASL authentication method like LOGIN, PLAIN, CRAM-MD5, NTLM, etc.. Leave it empty to make the class negotiate if necessary */ if ($smtp->SendMessage($from, array($to), array("From: {$from}", "To: {$to}", "Subject: {$subject}", "Date: " . strftime("%a, %d %b %Y %H:%M:%S %Z")), "{$message}")) { echo "Message sent to {$to} OK.\n"; } else { echo "Cound not send the message to {$to}.\nError: " . $smtp->error . "\n"; }
/* Set to 1 to deliver directly to the recepient SMTP server */ $smtp->timeout = 10; /* Set to the number of seconds wait for a successful connection to the SMTP server */ $smtp->data_timeout = 0; /* Set to the number seconds wait for sending or retrieving data from the SMTP server. Set to 0 to use the same defined in the timeout variable */ $smtp->debug = 1; /* Set to 1 to output the communication with the SMTP server */ $smtp->html_debug = 1; /* Set to 1 to format the debug output as HTML */ $smtp->pop3_auth_host = ""; /* Set to the POP3 authentication host if your SMTP server requires prior POP3 authentication */ $smtp->user = ""; /* Set to the user name if the server requires authetication */ $smtp->realm = ""; /* Set to the authetication realm, usually the authentication user e-mail domain */ $smtp->password = ""; /* Set to the authetication password */ $smtp->workstation = "www"; /* Workstation name for NTLM authentication */ $smtp->authentication_mechanism = ""; /* Specify a SASL authentication method like LOGIN, PLAIN, CRAM-MD5, NTLM, etc.. Leave it empty to make the class negotiate if necessary */ $recipients = explode(',', $to); foreach ($recipients as $recipient) { if ($smtp->SendMessage($sender, array($recipient), array("From: {$sender}", "To: {$to}", "Subject: {$subject}", "Date: " . strftime("%a, %d %b %Y %H:%M:%S %Z")), "{$message}")) { echo "Message sent. \n"; } else { echo "Cound not send message.\nError: " . $smtp->error . "\n"; } }
$smtp->password = ""; /* Set to the authetication password */ $smtp->workstation = ""; /* Workstation name for NTLM authentication */ $smtp->authentication_mechanism = "NTLM"; /* Specify a SASL authentication method like LOGIN, PLAIN, CRAM-MD5, NTLM, etc.. Leave it empty to make the class negotiate if necessary */ /* * If you need to use the direct delivery mode and this is running under * Windows or any other platform that does not have enabled the MX * resolution function GetMXRR() , you need to include code that emulates * that function so the class knows which SMTP server it should connect * to deliver the message directly to the recipient SMTP server. */ if ($smtp->direct_delivery) { if (!function_exists("GetMXRR")) { /* * If possible specify in this array the address of at least on local * DNS that may be queried from your network. */ $_NAMESERVERS = array(); include "php/getmxrr.php"; } } if ($smtp->SendMessage($from, array($to), array("MIME-Version: 1.0", "Content-Type: multipart/mixed; boundary=\"PHP-mixed-" . $random_hash . "\"", "From: " . $from, "To: " . $to, "Subject: " . 'BiWeekly Customer Service Survey Results', "Date: " . strftime("%a, %d %b %Y %H:%M:%S %Z")), $message)) { // If email is successful, delete survey results file unlink($target_path); echo "\nFile successfully sent"; } else { echo "\nError with report"; }
* Windows or any other platform that does not have enabled the MX * resolution function GetMXRR() , you need to include code that emulates * that function so the class knows which SMTP server it should connect * to deliver the message directly to the recipient SMTP server. */ if ($smtp->direct_delivery) { if (!function_exists("GetMXRR")) { /* * If possible specify in this array the address of at least on local * DNS that may be queried from your network. */ $_NAMESERVERS = array(); include "getmxrr.php"; } } if ($smtp->SendMessage($from, array($to), array("MIME-Version: 1.0", "Content-Type: multipart/mixed; boundary=\"PHP-mixed-" . $random_hash . "\"", "From: " . $from, "To: " . $to, "Subject: " . $_GET['subject'], "Date: " . strftime("%a, %d %b %Y %H:%M:%S %Z")), $message)) { echo "<p class=\"pAlignRight\"><a class=\"aSmall\" href=\"#\" id=\"aCancel\" name=\"aCancel\" onclick=\"javascript:window.opener='x';window.close();\">Close [x]</a></p>"; echo "<i>The following email has been sent to " . $to . ":</i><br><br>"; echo "<div class=\"divGrey\">"; echo $HTMLmsg; echo "</div>"; echo "<p class=\"pAlignRight\"><a class=\"aSmall\" href=\"#\" id=\"aCancel\" name=\"aCancel\" onclick=\"javascript:window.opener='x';window.close();\">Close [x]</a></p><br><br>"; $q = "Update tbl_referral Set user9 = 1 where referral_id = " . $_GET['referral_id']; $result = mysql_query($q, $conn); } else { echo "<p class=\"pAlignRight\"><a class=\"aSmall\" href=\"#\" id=\"aCancel\" name=\"aCancel\" onclick=\"javascript:window.opener='x';window.close();\">Close [x]</a></p><br><br>"; echo "Email send failed - Contact IS.<br /><br/><br/><br/>"; echo $smtp->error . "<br/>"; //print_r($smtp); echo "<small>From:" . $from . "<br/>"; echo "To:" . $to . "<br/>";
function mail_smtp($from, $to, $subject, $body, $html = 0) { require_once "smtp.php"; $smtp = new smtp_class(); $smtp->host_name = "localhost"; /* Change this variable to the address of the SMTP server to relay, like "smtp.myisp.com" */ $smtp->localhost = "localhost"; /* Your computer address */ $smtp->direct_delivery = 0; /* Set to 1 to deliver directly to the recepient SMTP server */ $smtp->timeout = 10; /* Set to the number of seconds wait for a successful connection to the SMTP server */ $smtp->data_timeout = 0; /* Set to the number seconds wait for sending or retrieving data from the SMTP server. Set to 0 to use the same defined in the timeout variable */ $smtp->debug = 0; /* Set to 1 to output the communication with the SMTP server */ $smtp->html_debug = 1; /* Set to 1 to format the debug output as HTML */ $smtp->pop3_auth_host = "vietnextco.com.vn"; /* Set to the POP3 authentication host if your SMTP server requires prior POP3 authentication */ $smtp->user = "******"; /* Set to the user name if the server requires authetication */ $smtp->realm = ""; /* Set to the authetication realm, usually the authentication user e-mail domain */ $smtp->password = "******"; /* Set to the authetication password */ $smtp->workstation = ""; /* Workstation name for NTLM authentication */ $smtp->authentication_mechanism = ""; /* Specify a SASL authentication method like LOGIN, PLAIN, CRAM-MD5, NTLM, etc.. Leave it empty to make the class negotiate if necessary */ if ($smtp->direct_delivery) { if (!function_exists("GetMXRR")) { $_NAMESERVERS = array(); include "getmxrr.php"; } } $header = ""; if ($html == 0) { $header = array("From: {$from}", "To: {$to}", "Subject: {$subject}", "Date: " . strftime("%a, %d %b %Y %H:%M:%S %Z")); } else { $header = array("MIME-Version: 1.0", "Content-type: text/html; charset=iso-8859-1", "From: {$from}", "To: {$to}", "Subject: {$subject}", "Date: " . strftime("%a, %d %b %Y %H:%M:%S %Z")); } $ret = $smtp->SendMessage($from, array($to), $header, $body); return $ret; }
function mailSend($to, $subject, $body) { //Get the mail specific configuration variables already existing globally global $_mail_from, $_mail_protocol, $_mail_protocol, $_mail_from, $_smtp_username, $_smtp_pass, $_smtp_host, $_smtp_port; $body = wordwrap($body, 70); if ($_mail_protocol == 'smtp') { require_once "smtp.php"; $smtp = new smtp_class(); $smtp->host_name = $_smtp_host; $smtp->host_port = $_smtp_port; $smtp->user = $_smtp_username; $smtp->password = $_smtp_pass; $smtp->timeout = 10; //$smtp->debug=1; Debug: Uncomment this. Note that it will cause errors in cases where this file is contacted by ajax and the requested data format is json e.g in the registration form $headers = "MIME-Version: 1.0\r\n\n\t\t\tFrom: CodeZone <{$_mail_from}>\r\n\n\t\t\tReply-To: {$_mail_from}\r\n"; foreach ($to as $val) { $smtp->SendMessage($_mail_from, array($val), array("MIME-Version: 1.0", "From: CodeZone <{$_mail_from}>", "Reply-To: {$_mail_from}", "To: {$val}", "Subject: {$subject}", "Date: " . strftime("%a, %d %b %Y %H:%M:%S %Z")), "{$body}"); } } else { foreach ($to as $val) { @mail($val, $subject, $body, "MIME-Version: 1.0\r\nFrom: CodeZone <{$_mail_from}>\r\nReply-To: {$_mail_from}\r\nDate: " . strftime("%a, %d %b %Y %H:%M:%S %Z")); } } }