示例#1
1
 private function send_email($to, $subject, $body, $attachments)
 {
     require_once 'Mail.php';
     require_once 'Mail/mime.php';
     require_once 'Mail/mail.php';
     $headers = array('From' => _EMAIL_ADDRESS, 'To' => $to, 'Subject' => $subject);
     // attachment
     $crlf = "\n";
     $mime = new Mail_mime($crlf);
     $mime->setHTMLBody($body);
     //$mime->addAttachment($attachment, 'text/plain');
     if (is_array($attachments)) {
         foreach ($attachments as $attachment) {
             $mime->addAttachment($attachment, 'text/plain');
         }
     }
     $body = $mime->get();
     $headers = $mime->headers($headers);
     $smtp = Mail::factory('smtp', array('host' => _EMAIL_SERVER, 'auth' => true, 'username' => _EMAIL_USER, 'password' => _EMAIL_PASSWORD));
     $mail = $smtp->send($to, $headers, $body);
     if (PEAR::isError($mail)) {
         echo "<p>" . $mail->getMessage() . "</p>";
     } else {
         echo "<p>Message successfully sent!</p>";
     }
 }
示例#2
0
 /**
  * 
  * @param array $data
  * 				$data['from']
  * 				$data['to']
  * 				$data['subject']
  * 				$data['body']
  * 
  */
 public function sendMail($data)
 {
     $from = $data['from'];
     //"<from.gmail.com>";
     $to = $data['to'];
     //"<to.yahoo.com>";
     $subject = $data['subject'];
     //"Hi!";
     $body = $data['body'];
     //"Hi,\n\nHow are you?";
     $headers = array('From' => $from, 'To' => $to, 'Subject' => $subject);
     $message = new Mail_mime();
     $message->setTXTBody($body);
     // 		$message->setHTMLBody($messageHTML);
     $mimeparams = array();
     $mimeparams['text_encoding'] = "7bit";
     $mimeparams['text_charset'] = "UTF-8";
     $mimeparams['html_charset'] = "UTF-8";
     $mimeparams['head_charset'] = "UTF-8";
     $body = $message->get($mimeparams);
     $headers = $message->headers($headers);
     $smtp = Mail::factory('smtp', array('host' => $this->host, 'port' => $this->port, 'auth' => true, 'username' => $this->username, 'password' => $this->password));
     $mail = $smtp->send($to, $headers, $body);
     if (PEAR::isError($mail)) {
         error_log($mail->getMessage());
     }
 }
示例#3
0
文件: func.php 项目: kzotoff/JuliaCMS
 /**
  * Send email using configuration supplied
  *
  * @param array $data array with message details. array must contain at least "to", "subject" and "text" items
  * @param array $config array with mail transport configuration. Array must contain 'type' element, which will
  *                      define transport system: 'sendmail' or 'smtp' (case-insensitive). If transport is "smtp",
  *                      array must also have "server", "host", "auth", "username", "password", and "localhost"
  *                      items. Refer to PEAR::Mail documentation for items meaning for detailed items description.
  */
 private function mail_send($data, $config, &$send_log)
 {
     switch (strtoupper($config['type'])) {
         case 'SENDMAIL':
             $headers = 'From: ' . $config['from'] . PHP_EOL . 'To: ' . $data['to'] . PHP_EOL . 'Content-Type: text/html; charset=utf-8';
             return mail($data['to'], get_array_value($data, 'subject', '* no subject*'), get_array_value($data, 'text', ''), $headers);
             break;
         case 'SMTP':
             // suppress massive strict notices as PEAR's mailer
             $current_error_reporting = error_reporting();
             // catch errors, get log
             error_reporting(E_ALL ^ E_NOTICE);
             ob_start();
             // init mailer, yeah
             $params = array('host' => $config['server'], 'port' => $config['port'], 'auth' => $config['auth'], 'username' => $config['username'], 'password' => $config['password'], 'localhost' => $config['localhost'], 'debug' => true);
             $mailer =& Mail::factory('smtp', $params);
             $headers = array('From' => $config['from'], 'Subject' => get_array_value($data, 'subject', '* no subject*'), 'Content-Type' => 'text/html; charset=utf-8', 'To' => $data['to']);
             $result = $mailer->send($data['to'], $headers, $data['text']);
             error_reporting($current_error_reporting);
             $send_log = ob_get_clean();
             if ($result === true) {
                 return true;
             } else {
                 popup_message_add('Mail failed: ' . $result->message);
                 return false;
             }
             break;
     }
     trigger_error('mail_send: no transport defined, message not sent', E_USER_WARNING);
     return false;
 }
示例#4
0
	/**
	 * Sends an email using the specified details.
	 * 
	 * @param string $from the "from" address
	 * @param string $to the recipient
	 * @param string $subject the subject of the email
	 * @param string $body the body of the email
	 * @return integer the result of the process
	 */
	public static function send($from, $to, $subject, $body) {
		try {
			// Setup
			$config = \Bedrock\Common\Registry::get('config');
			
			$headers = array('From' => $from,
							'To' => $to,
							'Subject' => $subject,
							'Date' => date("r", time()));
			
			$smtpConfig = array('host' => $config->email->smtp,
								'port' => $config->email->port,
								'auth' => true,
								'username' => $config->email->username,
								'password' => $config->email->password);
		
			$smtp = \Mail::factory('smtp', $smtpConfig);
			
			\Bedrock\Common\Logger::info('Attempting to send an email to "' . $to . '" ...');
			$mail = $smtp->send($to, $headers, $body);
			
			if(\PEAR::isError($mail)) {
				throw new \Bedrock\Common\Email\Exception($mail->getMessage());
			}
		}
		catch(\Bedrock\Common\Email\Exception $ex) {
			\Bedrock\Common\Logger::exception($ex);
			throw $ex;
		}
		catch(\Exception $ex) {
			\Bedrock\Common\Logger::exception($ex);
			throw new \Bedrock\Common\Email\Exception('The email could not be sent.');
		}
	}
示例#5
0
 public function send()
 {
     extract($_POST);
     $crlf = "\n";
     $mime = new Mail_mime($crlf);
     $mime->setTXTBody(strip_tags($body));
     //    $mime->setHTMLBody($body);
     $mimebody = $mime->get();
     $useremail = $this->server->user['email'];
     if ($useremail == null) {
         $useremail = "*****@*****.**";
     }
     $to = $email_addresses;
     $headers = array('From' => $useremail, 'Subject' => $subject);
     if ($email_addresses != '') {
         $headers['To'] = $email_addresses;
     }
     if ($toself == 1) {
         $headers['Cc'] = $useremail;
         if ($to != '') {
             $to .= ', ';
         }
         $to .= $useremail;
     }
     $headers = $mime->headers($headers);
     $smtp = Mail::factory('smtp', array('host' => 'owa.moma.org'));
     $mail = $smtp->send($to, $headers, $mimebody);
     if (PEAR::isError($mail)) {
         throw new Error('Error sending e-mail: ' . $mail->getMessage());
     } else {
         return new Response('ok');
     }
 }
示例#6
0
/**
 * 发送邮件 
 * 
 * @param string $from 发件人
 * @param string $to 收件人
 * @param string $subject 主题
 * @param string $body 邮件体
 * @return void
 */
function send_mail($from = null, $to = null, $subject = null, $body = null)
{
    //smtp设置
    $host = 'mail.eyou.net';
    $username = '******';
    $password = '******';
    //发件人
    if (empty($from)) {
        $from = 'mailer';
    }
    //收件人
    if (empty($to)) {
        $to = '*****@*****.**';
    }
    //主题
    if (empty($subject)) {
        $subject = 'test';
    } else {
        $subject = encode_msg($subject);
    }
    //邮件体
    if (empty($body)) {
        $body = 'hello world';
    } else {
        //$body = file_get_contents($body);
        $body = $body;
    }
    $headers = array('From' => $from, 'To' => $to, 'Subject' => $subject, 'Date' => date('r'), 'Content-Type' => 'text/plain; charset="GB2312"');
    $smtp = Mail::factory('smtp', array('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password));
    $smtp->send($to, $headers, $body);
}
示例#7
0
 function eMail($row, $user = '')
 {
     $lastRun = $this->getLastReportRun($row['subscription_name']);
     $html = $lastRun['report_html'];
     if ($html == '' || $html == 'NULL') {
         return FALSE;
     }
     // Remove google chart data
     $css = file_get_contents('/var/www/html/css/mail.css');
     $message = "<html>\n<head>\n<style>\n{$css}\n</style>\n</head>\n";
     $html = str_replace("<td class='chart'>", "<td>", $html);
     $sp1 = strpos($html, "<body>");
     $sp2 = strpos($html, "<form");
     $sp3 = strpos($html, "</form>");
     $message .= substr($html, $sp1, $sp2 - $sp1);
     $message .= "<p><a href='https://analytics.atari.com/report_log.php?_report=" . $row['subscription_name'] . "&_cache=" . $lastRun['report_startts'] . "'>View This In A Browser</a></p>";
     $message .= substr($html, $sp3 + strlen('</form>'));
     // Now Email the results
     $crlf = "\n";
     $hdrs = array('Subject' => "Atari Analytics: Report: " . $row['subscription_title'] . ". Run completed successfully at " . $lastRun['report_endts'] . ".");
     $mime = new Mail_mime(array('eol' => $crlf));
     $mime->setHTMLBody($message);
     $mime->addAttachment("/tmp/" . $lastRun['report_csv'], 'text/plain');
     $body = $mime->get();
     $hdrs = $mime->headers($hdrs);
     $mail =& Mail::factory('mail');
     if ($user == '') {
         $mail->send($row['subscription_list'], $hdrs, $body);
     } else {
         $mail->send($user, $hdrs, $body);
     }
     return TRUE;
 }
function sendValidationCode($email, $validationCode, $msg)
{
    //    $headers['From'] = '*****@*****.**';
    //    $headers['To'] = $email;
    //    $headers['Subject'] = 'Colfusion Invitation';
    //    $body = $msg;
    // $smtpinfo["host"] = "ssl://smtp.gmail.com";
    // $smtpinfo["port"] = "465";
    // $smtpinfo["auth"] = true;
    // $smtpinfo["username"] = "******";
    // $smtpinfo["password"] = "******";
    // $mail_object = & Mail::factory("smtp", $smtpinfo);
    // $mail_object->send($email, $headers, $body);
    $headers['From'] = '*****@*****.**';
    $headers['To'] = $email;
    $headers['Subject'] = 'Colfusion Invitation';
    $params['sendmail_path'] = '/usr/sbin/sendmail';
    // Create the mail object using the Mail::factory method
    $mail_object =& Mail::factory('sendmail', $params);
    $recipients = $email . ", Karataev.Evgeny@gmail.com";
    $mail_object->send($recipients, $headers, $msg);
    if (PEAR::isError($mail_object)) {
        print $mail_object->getMessage();
    }
}
/**
* Send a CAPTCHA verification email to the supplied address
*
* @param string	$to_email_address	The destination email address
* @param string	$key				The shared CAPTCHA verification key (in the email and the user's session)
*
* @access public
* @return void
*/
function sendAccessibleCaptchaEmail($to_email_address, $key)
{
    require_once 'Mail.php';
    require_once 'Mail/mime.php';
    // Strip spaces from around the "To" address in case these are present
    $to_email_address = trim($to_email_address);
    // Provide the name of the system as supplied in the main.inc configuration for use in the email (if it is set)
    $from_address = '"Accessible CAPTCHA Form"';
    if (SQ_CONF_SYSTEM_NAME != '') {
        $from_system_name = 'from the ' . SQ_CONF_SYSTEM_NAME . ' website ';
        $from_address = SQ_CONF_SYSTEM_NAME;
    }
    // Quote the System Name as it could contain apos'rophes
    $from_address = '"' . $from_address . '"';
    $current_url = current_url();
    $body = 'This email has been generated ' . $from_system_name . "as part of a form submission which includes an Accessible CAPTCHA field.\n\n" . "Please visit the following page to validate your submission before submitting the form\n\n" . $current_url . '?key=' . $key;
    $mime = new Mail_mime("\n");
    $mime->setTXTBody($body);
    $from_address .= ' <' . SQ_CONF_DEFAULT_EMAIL . '>';
    $headers = array('From' => $from_address, 'Subject' => 'Accessible CAPTCHA Form Verification');
    $param = array('head_charset' => SQ_CONF_DEFAULT_CHARACTER_SET, 'text_charset' => SQ_CONF_DEFAULT_CHARACTER_SET, 'html_charset' => SQ_CONF_DEFAULT_CHARACTER_SET);
    $body = @$mime->get($param);
    $headers = @$mime->headers($headers);
    $mail =& Mail::factory('mail');
    $status = @$mail->send($to_email_address, $headers, $body);
}
示例#10
0
文件: mail.php 项目: nkaligin/oobd
function sendMail($absender_email, $absender_name, $Empfaenger, $Betreff, $content, $attachments)
{
    global $config;
    $crlf = "\n";
    $from = "{$absender_name} <{$absender_email}>";
    $headers = array('From' => $from, 'To' => $Empfaenger, 'Subject' => $Betreff);
    $mime = new Mail_mime(array('eol' => $crlf));
    $mime->setTXTBody($content);
    if (isset($attachments)) {
        foreach ($attachments as $attachment) {
            if (isset($attachment["filename"]) && $attachment["filename"] != "" && isset($attachment["mailname"]) && $attachment["mailname"] != "") {
                $mime->addAttachment($attachment["filename"], 'application/octet-stream', $attachment["mailname"], true, 'base64');
            }
        }
    }
    $body = $mime->get(array('html_charset' => 'utf-8', 'text_charset' => 'utf-8', 'eol' => $crlf));
    $hdrs = $mime->headers($headers);
    $smtp = Mail::factory('smtp', array('host' => $config['smtphost'], 'auth' => true, 'username' => $config['smtpusername'], 'password' => $config['smtppassword']));
    $mail = $smtp->send($Empfaenger, $hdrs, $body);
    /*
    if (PEAR::isError($mail)) {
    echo("<p>" . $mail->getMessage() . "</p>");
    } else {
    echo("<p>Message successfully sent!</p>");
    }
    */
    //	mail($Empfaenger, $Betreff, $text, $Header) or die('Die Email
    //	konnte nicht versendet werden');
}
示例#11
0
function configure()
{
    # A. Limonade default options
    $localhost = preg_match('/^localhost(\\:\\d+)?/', $_SERVER['HTTP_HOST']);
    $env = $localhost ? ENV_DEVELOPMENT : ENV_PRODUCTION;
    option('env', $env);
    //option('base_path', $env == ENV_DEVELOPMENT ? '/vincent-helye.com/www-2' : '/www-2');
    if ($env == ENV_PRODUCTION) {
        option('base_uri', '/');
    }
    option('http_cache', $env == ENV_PRODUCTION);
    # B. Helye options
    option('app_dir', file_path(dirname(option('root_dir')), 'app'));
    option('lib_dir', file_path(option('app_dir'), 'lib'));
    option('views_dir', file_path(option('app_dir'), 'views'));
    option('controllers_dir', file_path(option('app_dir'), 'controllers'));
    $datas_dir = file_path(option('app_dir'), 'datas');
    option('lemon_tree_root', file_path($datas_dir, 'public'));
    option('private_lemon_tree_root', file_path($datas_dir, 'private'));
    option('lemon_tree_root_name', 'home');
    option('auth_config', file_path(option('app_dir'), 'config', 'users.php'));
    option('title_separator', ' // ');
    $email_options = array();
    $email_options['to'] = $env == ENV_PRODUCTION ? '*****@*****.**' : '*****@*****.**';
    $email_options['subject'] = "[vincent-helye.com]: %s (message envoyé par %s)";
    if ($env == ENV_DEVELOPMENT) {
        require_once "Mail.php";
        $email_options['smtp'] = Mail::factory('smtp', array('host' => 'smtp.sfr.fr', 'port' => 587));
    }
    option('email_options', $email_options);
    # C. Other settings
    setlocale(LC_TIME, "fr_FR");
    define('MARKDOWN_EMPTY_ELEMENT_SUFFIX', ">");
}
示例#12
0
function send_confirmation($user_name, $email)
{
    // Create a new template, and specify that the template files are
    // in the same directory as the as the php files.
    $template = new HTML_Template_IT("./templates");
    // Load the email template file
    $template->loadTemplatefile("confirmemail.tpl", true, true);
    $template->setVariable("USERNAME", $user_name);
    $template->setVariable("EMAIL", $email);
    $to = $email;
    // Setup the headers.
    $headers["From"] = "*****@*****.**";
    $headers["Subject"] = "Fitness Log Confirmation Email";
    $headers["X-Sender"] = "*****@*****.**";
    $headers["X-Mailer"] = "PHP";
    $headers["Return-Path"] = "*****@*****.**";
    $headers["To"] = $email;
    $body = $template->get();
    $host = "mail.vanhlebarsoftware.com";
    $mail_user = "******";
    $password = "******";
    $smtp = Mail::factory('smtp', array('host' => $host, 'auth' => true, 'username' => $mail_user, 'password' => $password));
    $mail = $smtp->send($to, $headers, $body);
    if (PEAR::isError($mail)) {
        echo "<p>" . $mail->getMessage() . "</p>";
    }
}
示例#13
0
文件: Payment.php 项目: demental/m
 function logError()
 {
     $mail = Mail::factory('vide');
     $mail->setVars(array('body' => print_r($this, true), 'subject' => 'debug CB'));
     $mail->sendTo('demental at github');
     return;
 }
function pearMail($to, $subject, $html, $text, $headers = false)
{
    $headers = $headers ? $headers : array('From' => EMAIL, 'Subject' => $subject);
    $html = '<html>
    <head>
    <style type="text/css">
      body{font-family: Arial, sans-serif;}
      a{color: #0088cc}
      a:hover {color: #005580;text-decoration: none;}
    </style>
    </head>
      <body>' . $html . '</body>
    </html>';
    $html = $html;
    $text = utf8_decode($text);
    // We never want mails to send out from local machines. It's all too easy
    // to accidentally send out a test mail to a client or their clients.
    if (LOCAL) {
        die($html);
    } else {
        $mime = new Mail_mime();
        $mime->setTXTBody($text);
        // Add standard CSS or other mail headers to this string, and all mails will
        // be styled uniformly.
        $mime->setHTMLBody($html);
        $body = $mime->get();
        $hdrs = $mime->headers($headers);
        $mail =& Mail::factory('mail');
        $mail->send($to, $hdrs, $body);
    }
}
示例#15
0
 public function __construct()
 {
     $this->backend = "smtp";
     $this->params = array("host" => "localhost", "port" => "25");
     $this->mailobject = Mail::factory($this->backend, $this->params);
     $this->headers = array("From" => "BlooDy <*****@*****.**>", "Sender" => "BlooDy <*****@*****.**>", "Reply-To" => "BlooDy <*****@*****.**>", "Content-Type" => "text/plain; charset=UTF-8", "X-Mailer" => "BlooDy", "X-Origin" => "http://bloodybd.fr");
 }
示例#16
0
 function start($args)
 {
     print_r($args);
     list($cmd, $this->repos, $this->rev, $this->email) = $args;
     if ($this->repos[0] == '/') {
         $this->repos = $this->repos = 'file://' . $this->repos;
     }
     $this->rev = (int) $this->rev;
     $last = $this->rev - 1;
     // techncially where the diff is!?
     require_once 'System.php';
     $svn = System::which('svn', '/usr/bin/svn');
     $cmd = "{$svn} diff -r{$last}:{$this->rev} {$this->repos}";
     $this->log = svn_log($this->repos, $this->rev, $this->rev - 1, 0, SVN_DISCOVER_CHANGED_PATHS);
     $syntax = $this->checkSyntax();
     //echo $cmd;
     $diff = `{$cmd}`;
     $diff = $this->log[0]['msg'] . "\n\n" . $diff;
     if ($syntax) {
         $diff = $syntax . "\n\n" . $diff;
     }
     $bits = explode('@', $this->email);
     $headers['From'] = "{$this->log[0]['author']} <{$this->log[0]['author']}@{$bits[1]}>";
     $headers['To'] = $this->email;
     $headers['Subject'] = "[SVN {$bits[1]}] " . ($syntax ? "ERROR!" : "") . $this->getFilenames() . " ({$this->rev})";
     $headers['Date'] = date('r');
     $headers['X-Mailer'] = 'svn hook';
     // Create the mail object using the Mail::factory method
     require_once 'Mail.php';
     $mail_object =& Mail::factory('smtp', $params);
     $mail_object->send($this->email, $headers, $diff);
     $this->sendPopup($syntax);
 }
示例#17
0
 public function send($to, $subject, $message, $html = 0, $from = '')
 {
     $headers["From"] = $from == '' ? $this->from : $from;
     $headers["To"] = $to;
     $headers["Subject"] = $subject;
     $headers["Content-Type"] = 'text/html; charset=UTF-8';
     $headers["Content-Transfer-Encoding"] = "8bit";
     $mime = new Mail_mime();
     if ($html == 0) {
         $mime->setTXTBody($message);
     } else {
         $mime->setHTMLBody($message);
     }
     $mimeparams['text_encoding'] = "8bit";
     $mimeparams['text_charset'] = "UTF-8";
     $mimeparams['html_charset'] = "UTF-8";
     $mimeparams['head_charset'] = "UTF-8";
     $body = $mime->get($mimeparams);
     $headers = $mime->headers($headers);
     // SMTP server name, port, user/passwd
     $smtpinfo["host"] = $this->host;
     $smtpinfo["port"] = $this->port;
     $smtpinfo["auth"] = $this->auth;
     $smtpinfo["username"] = $this->username;
     $smtpinfo["password"] = $this->password;
     $smtpinfo["debug"] = false;
     $to = array($to);
     // Create the mail object using the Mail::factory method
     $mail =& Mail::factory("smtp", $smtpinfo);
     @$mail->send($to, $headers, $body);
 }
示例#18
0
 /**
  * Send an mime mail
  * possibly only text or text + html.
  *
  * @param string or array  $recipients
  * @param string $text
  * @param string $html
  * @param array $hdrs
  */
 static public function MailMime($recipients, $text=false, $html=false, $hdrs)
 {
     include_once 'Mail.php';
     include_once 'Mail/mime.php';
 
     $crlf = "\n";
 
     $mime = new Mail_mime($crlf);
     
     if (strlen($text)) {
         $mime->setTXTBody($text);
     }
     
     if (strlen($html)) {
         $mime->setHTMLBody($html);
     }
     
     $body = $mime->get(array('head_charset' => 'UTF-8', 'text_charset' => 'UTF-8', 'html_charset' => 'UTF-8'));
     $hdrs = $mime->headers($hdrs);
     
     $mail = Mail::factory('mail');
     
     if (is_array($recipients)) {
         foreach ($recipients as $recipient) {
             $mail->send($recipient, $hdrs, $body);
         }
     } else {
         $mail->send($recipients, $hdrs, $body);   
     }
 }
示例#19
0
function sendVerificationEmail($user, $email)
{
    $query = "SELECT confirm_code FROM UnverifiedUser " . "WHERE name='{$user}' AND email='{$email}'";
    $result = mysql_query($query);
    if (mysql_num_rows($result) == 0) {
        // error
        return "<returncode>0</returncode>\n" . "<errormessage>No such unverified user!</errormessage>";
    }
    $result_row = mysql_fetch_assoc($result);
    $confirm_code = $result_row['confirm_code'];
    $from = "COBL <*****@*****.**>";
    $to = $email;
    $subject = "COBL User Confirmation";
    $body = "Hi {$user},\n" . "To confirm your user registration please click on the link below:\n" . "http://sands.sce.ntu.edu.sg:5500/do_command.php?command=verify_user&" . "confirm_code={$confirm_code} \n" . "COBL Team";
    $port = 587;
    $host = "smtp.gmail.com";
    $username = "******";
    $password = "******";
    $headers = array('From' => $from, 'To' => $to, 'Subject' => $subject);
    $smtp = Mail::factory('smtp', array('host' => $host, 'auth' => true, 'port' => $port, 'username' => $username, 'password' => $password));
    $mail = $smtp->send($to, $headers, $body);
    if (PEAR::isError($mail)) {
        return "<p>" . $mail->getMessage() . "</p>";
    } else {
        return "<p>Message successfully sent!</p>";
    }
}
示例#20
0
 public function main()
 {
     if (empty($this->from)) {
         throw new BuildException('Missing "from" attribute');
     }
     $this->log('Sending mail to ' . $this->tolist);
     if (!empty($this->filesets)) {
         @(require_once 'Mail.php');
         @(require_once 'Mail/mime.php');
         if (!class_exists('Mail_mime')) {
             throw new BuildException('Need the PEAR Mail_mime package to send attachments');
         }
         $mime = new Mail_mime(array('text_charset' => 'UTF-8'));
         $hdrs = array('From' => $this->from, 'Subject' => $this->subject);
         $mime->setTXTBody($this->msg);
         foreach ($this->filesets as $fs) {
             $ds = $fs->getDirectoryScanner($this->project);
             $fromDir = $fs->getDir($this->project);
             $srcFiles = $ds->getIncludedFiles();
             foreach ($srcFiles as $file) {
                 $mime->addAttachment($fromDir . DIRECTORY_SEPARATOR . $file, 'application/octet-stream');
             }
         }
         $body = $mime->get();
         $hdrs = $mime->headers($hdrs);
         $mail = Mail::factory('mail');
         $mail->send($this->tolist, $hdrs, $body);
     } else {
         mail($this->tolist, $this->subject, $this->msg, "From: {$this->from}\n");
     }
 }
 public function send()
 {
     $to = $this->getSetting('to', '');
     $from = $this->getSetting('from', '');
     $subject = $this->getSetting('subject', '');
     $encoding = $this->getSetting('encoding', '');
     $body = $this->getSetting('content', '');
     $error = '';
     $crlf = '';
     $params = array();
     $params['host'] = $this->getSetting('server', '');
     $params['auth'] = $this->getSetting('auth', true);
     $params['username'] = $this->getSetting('user', '');
     $params['password'] = $this->getSetting('password', '');
     $params['port'] = $this->getSetting('port', '587');
     $headers = array();
     $headers['To'] = 'To: ' . $to;
     $headers['From'] = 'From: ' . $from;
     $headers['Subject'] = $subject;
     $htmlparams = array('charset' => 'utf-8', 'content_type' => 'text/html', 'encoding' => 'quoted/printable');
     $email = new Mail_mimePart('', array('content_type' => 'multipart/alternative'));
     $htmlmime = $email->addSubPart($this->getTemplate(), $htmlparams);
     $final = $email->encode();
     $final['headers'] = array_merge($final['headers'], $headers);
     $smtp = Mail::factory('smtp', $params);
     $mail = $smtp->send($to, $final['headers'], $final['body']);
     if (PEAR::isError($mail)) {
         $error = $mail->getMessage();
     }
     return $error;
 }
function send_mail($mail_sender, $name_sender, $mail_receiver, $subject, $message_txt, $message_html = '')
{
    require_once 'tools/contact/libs/Mail.php';
    require_once 'tools/contact/libs/Mail/mime.php';
    $headers['From'] = $mail_sender;
    $headers['To'] = $mail_sender;
    $headers['Subject'] = $subject;
    $headers["Return-path"] = $mail_sender;
    if ($message_html == '') {
        $message_html == $message_txt;
    }
    $mime = new Mail_mime("\n");
    $mimeparams = array();
    $mimeparams['text_encoding'] = "7bit";
    $mimeparams['text_charset'] = "UTF-8";
    $mimeparams['html_charset'] = "UTF-8";
    $mimeparams['head_charset'] = "UTF-8";
    $mime->setTXTBody($message_txt);
    $mime->setHTMLBody($message_html);
    $message = $mime->get($mimeparams);
    $headers = $mime->headers($headers);
    // Creer un objet mail en utilisant la methode Mail::factory.
    $object_mail =& Mail::factory(CONTACT_MAIL_FACTORY);
    return $object_mail->send($mail_receiver, $headers, $message);
}
示例#23
0
 public function sendAction()
 {
     include 'Mail.php';
     $data = $_POST;
     $headers['From'] = $data['username'];
     $headers['Subject'] = $data['subject'];
     $headers['Date'] = date("r");
     $recipients = array();
     if (is_array($data['to'])) {
         foreach ($data['to'] as $to) {
             $recipients[] = $to;
         }
     } else {
         $recipients[] = $data['to'];
     }
     if (array_key_exists('body', $data)) {
         $body = $data['body'];
     } else {
         $body = "";
     }
     $params['host'] = EmailConfiguration::getSmtpHost();
     $params['port'] = EmailConfiguration::getSmtpPort();
     $params['auth'] = EmailConfiguration::getSmtpAuth();
     $params['username'] = $data['username'];
     $params['password'] = $data['password'];
     // Create the mail object using the Mail::factory method
     $mail_object =& Mail::factory('smtp', $params);
     $mail_object->send($recipients, $headers, $body);
 }
示例#24
0
 private function getInstanciaSmtp()
 {
     if (empty($this->instanciaSmtp)) {
         $this->instanciaSmtp = Mail::factory('smtp', array('host' => 'mail.host.com.br', 'port' => 587, 'auth' => true, 'username' => '*****@*****.**', 'password' => 'senha'));
     }
     return $this->instanciaSmtp;
 }
示例#25
0
/**
 * Copyright (C) 2008,2009 Ulteo SAS
 * http://www.ulteo.com
 * Author Julien LANGLOIS <*****@*****.**>
 * Author Laurent CLOUET <*****@*****.**>
 * Author Jeremy DESVAGES <*****@*****.**>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; version 2
 * of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 **/
function sendamail($to_, $subject_, $message_)
{
    require_once 'Mail.php';
    $prefs = Preferences::getInstance();
    if (!$prefs) {
        die_error('get Preferences failed', __FILE__, __LINE__);
    }
    $buf = $prefs->get('general', 'mails_settings');
    $method = $buf['send_type'];
    $from = $buf['send_from'];
    $host = $buf['send_host'];
    $port = $buf['send_port'];
    $ssl = false;
    if ($buf['send_ssl'] == '1') {
        $ssl = true;
    }
    if ($ssl === true) {
        $host = 'ssl://' . $host;
    }
    $localhost = '[' . $_SERVER['SERVER_ADDR'] . ']';
    $auth = false;
    if ($buf['send_auth'] == '1') {
        $auth = true;
    }
    $username = $buf['send_username'];
    $password = $buf['send_password'];
    $to = $to_;
    $subject = $subject_;
    $message = wordwrap($message_, 72);
    $headers = array('From' => $from . ' <' . $from . '>', 'To' => $to, 'Subject' => $subject, 'Content-Type' => 'text/plain; charset=UTF-8', 'X-Mailer' => 'PHP/' . phpversion());
    $api_mail = Mail::factory($method, array('host' => $host, 'port' => $port, 'localhost' => $localhost, 'auth' => $auth, 'username' => $username, 'password' => $password));
    return $api_mail->send($to, $headers, $message);
}
示例#26
0
 private function _sendPearMail($from, $to, $subject, $message)
 {
     require_once 'Xinc/Ini.php';
     try {
         $smtpSettings = Xinc_Ini::getInstance()->get('email_smtp');
     } catch (Exception $e) {
         $smtpSettings = null;
     }
     if ($smtpSettings != null) {
         $mailer = Mail::factory('smtp', $smtpSettings);
     } else {
         $mailer = Mail::factory('mail');
     }
     $recipients = split(',', $to);
     $headers = array();
     if (isset($smtpSettings['localhost'])) {
         $from = str_replace('@localhost', '@' . $smtpSettings['localhost'], $from);
     }
     $headers['From'] = $from;
     $headers['Subject'] = $subject;
     $res = $mailer->send($recipients, $headers, $message);
     if ($res === true) {
         return $res;
     } else {
         return false;
     }
 }
示例#27
0
function rsvp_notifications($rsvp, $rsvp_to, $subject, $message)
{
    include 'Mail.php';
    include 'Mail/mime.php';
    $mail =& Mail::factory('mail');
    $text = $message;
    $html = "<html><body>\n" . wpautop($message) . '</body></html>';
    $crlf = "\n";
    $hdrs = array('From' => '"' . $rsvp["first"] . " " . $rsvp["last"] . '" <' . $rsvp["email"] . '>', 'Subject' => $subject);
    $mime = new Mail_mime($crlf);
    $mime->setTXTBody($text);
    $mime->setHTMLBody($html);
    //do not ever try to call these lines in reverse order
    $body = $mime->get();
    $hdrs = $mime->headers($hdrs);
    $mail->send($rsvp_to, $hdrs, $body);
    // now send confirmation
    $hdrs = array('From' => $rsvp_options["rsvp_to"], 'Subject' => "Confirming RSVP {$answer} for " . $post->post_title . " {$date}");
    $mime = new Mail_mime($crlf);
    $mime->setTXTBody($text);
    $mime->setHTMLBody($html);
    //do not ever try to call these lines in reverse order
    $body = $mime->get();
    $hdrs = $mime->headers($hdrs);
    $mail->send($rsvp["email"], $hdrs, $body);
}
示例#28
0
 public function sendEmail($to, $from, $subject, $body, $username, $password, $is_body_html = true)
 {
     $smtp = array();
     $smtp['host'] = "ssl://smtp.gmail.com";
     $smtp['port'] = 465;
     $smtp['auth'] = true;
     $smtp['username'] = $username;
     $smtp['password'] = $password;
     $mailer = Mail::factory('smtp', $smtp);
     if (PEAR::isError($mailer)) {
         throw new Exception('Khong the tao mot mail moi!');
     }
     $recipients = array();
     $recipients[] = $to;
     $header = array();
     $header['From'] = $from;
     $header['To'] = $to;
     $header['Subject'] = $subject;
     if ($is_body_html) {
         $header['Content-Type'] = 'text/html';
     }
     $result = $mailer->send($recipients, $header, $body);
     if (PEAR::isError($result)) {
         throw new Exception('Loi khong the gui mail: ' . htmlspecialchars($result->getMessage()));
     }
 }
示例#29
0
 public function __construct($From, $To, $Subject, $Body, $User, $Pwd, $Host, $Port = 465)
 {
     $this->headers = array('From' => $From, 'To' => $To, 'Subject' => $Subject, 'Content-Type' => 'text/html');
     $this->smtp = Mail::factory('smtp', array('host' => $Host, 'port' => $Port, 'auth' => true, 'username' => $User, 'password' => $Pwd));
     $this->body = $Body;
     $this->to = $To;
 }
function sendEmail($settings, $subject, $body)
{
    $mailSettings = array('host' => $settings['alertSmtp']);
    //$settings['alertDevice']
    $mail = Mail::factory('smtp', $mailSettings);
    $headers = array('From' => $settings['alertEmail'], 'Subject' => $subject);
    $mail->send($settings['alertEmail'], $headers, $body);
}