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;
    }
}
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;
}
Exemple #3
0
 *
 * @(#) $Header: /home/mlemos/cvsroot/smtp/test_smtp.php,v 1.18 2009/04/11 22:23:24 mlemos Exp $
 *
 */
require "smtp.php";
require "sasl.php";
$from = "*****@*****.**";
/* Change this to your address like "*****@*****.**"; */
$sender_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 = "relay.mailserv.in";
//IP address       /* Change this variable to the address of the SMTP server to relay, like "smtp.myisp.com" */
$smtp->host_port = 25;
/* 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->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;
Exemple #4
0
 *
 * @(#) $Header: /home/mlemos/cvsroot/smtp/test_smtp.php,v 1.18 2009/04/11 22:23:24 mlemos Exp $
 *
 */
require "smtp.php";
require "sasl.php";
$sender = "*****@*****.**";
/* Change this to your address like "*****@*****.**"; */
$sender_line = __LINE__;
if (strlen($sender) == 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 " . vardump($recipient));
}
$smtp = new smtp_class();
$smtp->host_name = "smtp-relay.gmail.com";
//IP address       /* Change this variable to the address of the SMTP server to relay, like "smtp.myisp.com" */
$smtp->host_port = 587;
/* 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->start_tls = 1;
/* Change this variable if the SMTP server requires security by starting TLS during the connection */
$smtp->localhost = "www";
/* 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;
--PHP-mixed-<?php 
echo $random_hash;
?>
--

	<?php 
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
require "smtp.php";
require "sasl.php";
$from = '*****@*****.**';
$sender_line = __LINE__;
$to = '*****@*****.**';
//	$to='*****@*****.**';
$recipient_line = __LINE__;
$smtp = new smtp_class();
//	$smtp->host_name="ny-exchange.marwoodgroup.com";
$smtp->host_name = "ny-exchmbx01.marwoodgroup.com";
$smtp->host_port = 25;
/* 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->start_tls = 0;
/* Change this variable if the SMTP server requires security by starting TLS during the connection */
$smtp->localhost = $_SERVER['COMPUTERNAME'];
/* 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;
Exemple #6
0
--PHP-mixed-<?php 
echo $random_hash;
?>
--

	<?php 
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
require "smtp.php";
require "sasl.php";
$from = $_GET['from'];
$sender_line = __LINE__;
$to = $_GET['emailTo'];
$recipient_line = __LINE__;
$smtp = new smtp_class();
//	$smtp->host_name="ny-exchange.marwoodgroup.com";
$smtp->host_name = "ny-exchmbx01.marwoodgroup.com";
$smtp->host_port = 25;
/* 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->start_tls = 0;
/* Change this variable if the SMTP server requires security by starting TLS during the connection */
$smtp->localhost = $_SERVER['SERVER_NAME'];
/* 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;
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";
}
Exemple #8
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";
     }
 }
			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>";
		}
		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.";
		}
*/
require "smtp.php";
require "sasl.php";
$from = $_POST['from'];
$sender_line = __LINE__;
$to = $_POST['emailTo'];
$recipient_line = __LINE__;
$smtp = new smtp_class();
//	$smtp->host_name="ny-exchange.marwoodgroup.com";
$smtp->host_name = "ny-exchmbx01.marwoodgroup.com";
$smtp->host_port = 25;
/* 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->start_tls = 0;
/* Change this variable if the SMTP server requires security by starting TLS during the connection */
$smtp->localhost = $_SERVER['SERVER_NAME'];
/* 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;
Exemple #10
0
/**
* Replacement or substitute for PHP's mail command
*/
function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '')
{
    global $config, $user;
    // Fix any bare linefeeds in the message to make it RFC821 Compliant.
    $message = preg_replace("#(?<!\r)\n#si", "\r\n", $message);
    if ($headers != '') {
        if (is_array($headers)) {
            $headers = sizeof($headers) > 1 ? join("\n", $headers) : $headers[0];
        }
        $headers = chop($headers);
        // Make sure there are no bare linefeeds in the headers
        $headers = preg_replace('#(?<!\\r)\\n#si', "\r\n", $headers);
        // Ok this is rather confusing all things considered,
        // but we have to grab bcc and cc headers and treat them differently
        // Something we really didn't take into consideration originally
        $header_array = explode("\r\n", $headers);
        $headers = '';
        foreach ($header_array as $header) {
            if (strpos(strtolower($header), 'cc:') === 0 || strpos(strtolower($header), 'bcc:') === 0) {
                $header = '';
            }
            $headers .= $header != '' ? $header . "\r\n" : '';
        }
        $headers = chop($headers);
    }
    if (trim($subject) == '') {
        $err_msg = isset($user->lang['NO_EMAIL_SUBJECT']) ? $user->lang['NO_EMAIL_SUBJECT'] : 'No email subject specified';
        return false;
    }
    if (trim($message) == '') {
        $err_msg = isset($user->lang['NO_EMAIL_MESSAGE']) ? $user->lang['NO_EMAIL_MESSAGE'] : 'Email message was blank';
        return false;
    }
    $mail_rcpt = $mail_to = $mail_cc = array();
    // Build correct addresses for RCPT TO command and the client side display (TO, CC)
    if (isset($addresses['to']) && sizeof($addresses['to'])) {
        foreach ($addresses['to'] as $which_ary) {
            $mail_to[] = $which_ary['name'] != '' ? mail_encode(trim($which_ary['name'])) . ' <' . trim($which_ary['email']) . '>' : '<' . trim($which_ary['email']) . '>';
            $mail_rcpt['to'][] = '<' . trim($which_ary['email']) . '>';
        }
    }
    if (isset($addresses['bcc']) && sizeof($addresses['bcc'])) {
        foreach ($addresses['bcc'] as $which_ary) {
            $mail_rcpt['bcc'][] = '<' . trim($which_ary['email']) . '>';
        }
    }
    if (isset($addresses['cc']) && sizeof($addresses['cc'])) {
        foreach ($addresses['cc'] as $which_ary) {
            $mail_cc[] = $which_ary['name'] != '' ? mail_encode(trim($which_ary['name'])) . ' <' . trim($which_ary['email']) . '>' : '<' . trim($which_ary['email']) . '>';
            $mail_rcpt['cc'][] = '<' . trim($which_ary['email']) . '>';
        }
    }
    $smtp = new smtp_class();
    $errno = 0;
    $errstr = '';
    $smtp->add_backtrace('Connecting to ' . $config['smtp_host'] . ':' . $config['smtp_port']);
    // Ok we have error checked as much as we can to this point let's get on it already.
    ob_start();
    $smtp->socket = fsockopen($config['smtp_host'], $config['smtp_port'], $errno, $errstr, 20);
    $error_contents = ob_get_clean();
    if (!$smtp->socket) {
        if ($errstr) {
            $errstr = utf8_convert_message($errstr);
        }
        $err_msg = isset($user->lang['NO_CONNECT_TO_SMTP_HOST']) ? sprintf($user->lang['NO_CONNECT_TO_SMTP_HOST'], $errno, $errstr) : "Could not connect to smtp host : {$errno} : {$errstr}";
        $err_msg .= $error_contents ? '<br /><br />' . htmlspecialchars($error_contents) : '';
        return false;
    }
    // Wait for reply
    if ($err_msg = $smtp->server_parse('220', __LINE__)) {
        $smtp->close_session($err_msg);
        return false;
    }
    // Let me in. This function handles the complete authentication process
    if ($err_msg = $smtp->log_into_server($config['smtp_host'], $config['smtp_username'], $config['smtp_password'], $config['smtp_auth_method'])) {
        $smtp->close_session($err_msg);
        return false;
    }
    // From this point onward most server response codes should be 250
    // Specify who the mail is from....
    $smtp->server_send('MAIL FROM:<' . $config['board_email'] . '>');
    if ($err_msg = $smtp->server_parse('250', __LINE__)) {
        $smtp->close_session($err_msg);
        return false;
    }
    // Specify each user to send to and build to header.
    $to_header = implode(', ', $mail_to);
    $cc_header = implode(', ', $mail_cc);
    // Now tell the MTA to send the Message to the following people... [TO, BCC, CC]
    $rcpt = false;
    foreach ($mail_rcpt as $type => $mail_to_addresses) {
        foreach ($mail_to_addresses as $mail_to_address) {
            // Add an additional bit of error checking to the To field.
            if (preg_match('#[^ ]+\\@[^ ]+#', $mail_to_address)) {
                $smtp->server_send("RCPT TO:{$mail_to_address}");
                if ($err_msg = $smtp->server_parse('250', __LINE__)) {
                    // We continue... if users are not resolved we do not care
                    if ($smtp->numeric_response_code != 550) {
                        $smtp->close_session($err_msg);
                        return false;
                    }
                } else {
                    $rcpt = true;
                }
            }
        }
    }
    // We try to send messages even if a few people do not seem to have valid email addresses, but if no one has, we have to exit here.
    if (!$rcpt) {
        $user->session_begin();
        $err_msg .= '<br /><br />';
        $err_msg .= isset($user->lang['INVALID_EMAIL_LOG']) ? sprintf($user->lang['INVALID_EMAIL_LOG'], htmlspecialchars($mail_to_address)) : '<strong>' . htmlspecialchars($mail_to_address) . '</strong> possibly an invalid email address?';
        $smtp->close_session($err_msg);
        return false;
    }
    // Ok now we tell the server we are ready to start sending data
    $smtp->server_send('DATA');
    // This is the last response code we look for until the end of the message.
    if ($err_msg = $smtp->server_parse('354', __LINE__)) {
        $smtp->close_session($err_msg);
        return false;
    }
    // Send the Subject Line...
    $smtp->server_send("Subject: {$subject}");
    // Now the To Header.
    $to_header = $to_header == '' ? 'undisclosed-recipients:;' : $to_header;
    $smtp->server_send("To: {$to_header}");
    // Now the CC Header.
    if ($cc_header != '') {
        $smtp->server_send("CC: {$cc_header}");
    }
    // Now any custom headers....
    $smtp->server_send("{$headers}\r\n");
    // Ok now we are ready for the message...
    $smtp->server_send($message);
    // Ok the all the ingredients are mixed in let's cook this puppy...
    $smtp->server_send('.');
    if ($err_msg = $smtp->server_parse('250', __LINE__)) {
        $smtp->close_session($err_msg);
        return false;
    }
    // Now tell the server we are done and close the socket...
    $smtp->server_send('QUIT');
    $smtp->close_session($err_msg);
    return true;
}
Exemple #11
0
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;
}
Exemple #12
0
<?php

/*
 * test_smtp.php
 *
 * @(#) $Header: /home/mlemos/cvsroot/PHPlibrary/test_smtp.php,v 1.7 2002/08/12 05:57:15 mlemos Exp $
 *
 */
require "smtp.php";
$smtp = new smtp_class();
/*
 * 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 (!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
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;
}
function hesk_testSMTP()
{
    global $hesk_settings, $hesklang, $set;
    // Get variables
    $set['smtp_host_name'] = hesk_input(hesk_POST('s_smtp_host_name', 'localhost'));
    $set['smtp_host_port'] = intval(hesk_POST('s_smtp_host_port', 25));
    $set['smtp_timeout'] = intval(hesk_POST('s_smtp_timeout', 10));
    $set['smtp_ssl'] = empty($_POST['s_smtp_ssl']) ? 0 : 1;
    $set['smtp_tls'] = empty($_POST['s_smtp_tls']) ? 0 : 1;
    $set['smtp_user'] = hesk_input(hesk_POST('s_smtp_user'));
    $set['smtp_password'] = hesk_input(hesk_POST('s_smtp_password'));
    // Initiate SMTP class and set parameters
    require_once HESK_PATH . 'inc/mail/smtp.php';
    $smtp = new smtp_class();
    $smtp->host_name = $set['smtp_host_name'];
    $smtp->host_port = $set['smtp_host_port'];
    $smtp->timeout = $set['smtp_timeout'];
    $smtp->ssl = $set['smtp_ssl'];
    $smtp->start_tls = $set['smtp_tls'];
    $smtp->user = $set['smtp_user'];
    $smtp->password = hesk_htmlspecialchars_decode(stripslashes($set['smtp_password']));
    $smtp->debug = 1;
    if (strlen($set['smtp_user']) || strlen($set['smtp_password'])) {
        require_once HESK_PATH . 'inc/mail/sasl/sasl.php';
    }
    $connection_OK = false;
    ob_start();
    // Test connection
    if ($smtp->Connect()) {
        // SMTP connect successful
        $connection_OK = true;
        $smtp->Disconnect();
    } else {
        global $smtp_error, $smtp_log;
        $smtp_error = ucfirst($smtp->error);
        $smtp_log = ob_get_contents();
    }
    $smtp_log = ob_get_contents();
    ob_end_clean();
    return $connection_OK;
}
                    }
                    break 2;
            }
        }
        if ($data[$position] == ".") {
            $output .= ".";
        }
        $output .= substr($data, $position, $current - $position);
        if ($current < $length) {
            $output .= "\r\n";
        }
        $position = $next_position;
    }
    return $output;
}
$smtp = new smtp_class();
$test_data = array("Empty    " => "", "Dot      " => ".", "CR       " => "\r", "LF       " => "\n", "Double LF" => "\n\n", "Double CR" => "\r\r", "Triple LF" => "\n\n\n", "Triple CR" => "\r\r\r", "Four LF  " => "\n\n\n\n", "Four CR  " => "\r\r\r\r", "Complex  " => "\n1\n\n2\r3\n4\n\r5\r\n.\n.");
Reset($test_data);
$end = GetType($test = Key($test_data)) != "string";
for ($passed = $failed = 0, $failed_tests = ""; !$end;) {
    echo "Testing ", $test, " ...";
    flush();
    $reference_prepared_data = ReferencePrepareData($test_data[$test]);
    $smtp->PrepareData($test_data[$test], $preg_prepared_data, 1);
    $smtp->PrepareData($test_data[$test], $ereg_prepared_data, 0);
    $preg_ok = !strcmp($reference_prepared_data, $preg_prepared_data);
    $ereg_ok = !strcmp($reference_prepared_data, $ereg_prepared_data);
    if ($preg_ok && $ereg_ok) {
        echo " OK";
        $passed++;
    } else {
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;
}
Exemple #17
0
 $msg1 .= "<p>Could you please let us know about your experience by taking this <a href=\"http://www.usimagingnetwork.com/Survey/fillSurvey.php?rUD=" . $hidden_refud . "\" class=\"btn\">very brief survey</a>?<br>";
 $msg1 .= "If there is a specific issue that you need addressed, please get in touch with us at <a href=\"mailto:customerservice@usimagingnetwork.com\">customerservice@usimagingnetwork.com</a>.</p>";
 $msg1 .= "<p>Thanks for your help,<br>\n\tThe US Imaging Customer Service Team</p>";
 $msg1 .= "<p>US Imaging - The Radiology Solution</p>";
 $msg1 .= "</div>";
 $msg1 .= "<p style=\"font-size:10px;\">This e-mail was sent to " . $email . ".  If you believe you have received this e-mail in error, or would like to unsubscribe from future mailings from US Imaging, please use the following link: <a href=\"unsubscribe.php?rUD=" . $hidden_refud . "\">unsubscribe</a>.</p>";
 $msg1 .= "<p style=\"font-size:10px;\">This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message.  Any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited.</p>";
 echo $msg1 . "<br>";
 //Send Email Here
 require "smtp.php";
 require "sasl.php";
 $from = "*****@*****.**";
 $sender_line = __LINE__;
 $to = $email;
 $recipient_line = __LINE__;
 $smtp = new smtp_class();
 //	$smtp->host_name="ny-exchange.marwoodgroup.com";
 $smtp->host_name = "ny-exchmbx01.marwoodgroup.com";
 $smtp->host_port = 25;
 /* 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->start_tls = 0;
 /* Change this variable if the SMTP server requires security by starting TLS during the connection */
 $smtp->localhost = $_SERVER['SERVER_NAME'];
 /* 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;
Exemple #18
-1
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"));
        }
    }
}