Example #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>";
     }
 }
 function sendEmail()
 {
     foreach ($this->to as $to) {
         $headers = array('From' => SMTP_FROM_NAME . "<" . SMTP_FROM . ">", 'To' => $to, 'Subject' => $this->subject);
         $mime = new Mail_mime($this->NEW_LINE);
         if ($this->body == null) {
             if ($this->compiledTXT != null && strlen($this->compiledTXT) > 0) {
                 $mime->setTXTBody($this->compiledTXT);
             }
             if ($this->compiledHTML != null && strlen($this->compiledHTML) > 0) {
                 $mime->setHTMLBody($this->compiledHTML);
             }
         } else {
             $mime->setTXTBody($this->body);
         }
         foreach ($this->cc as $email) {
             $mime->addCc($email);
         }
         foreach ($this->bcc as $email) {
             $mime->addBcc($email);
         }
         if (is_array($this->files) && count($this->files) > 0) {
             foreach ($this->files as $file) {
                 $mime->addAttachment($file["path"], $file["content-type"]);
             }
         }
         $body = $mime->get();
         $headers = $mime->headers($headers);
         $string = "";
         foreach ($headers as $key => $value) {
             $string .= "{$key}: {$value}\r\n";
         }
         $smtpOptions = array('host' => SMTP_HOST, 'port' => SMTP_PORT);
         if (defined("SMTP_USER_NAME") && defined("SMTP_PASSWORD")) {
             $smtpOptions['auth'] = true;
             $smtpOptions['username'] = SMTP_USER_NAME;
             $smtpOptions['password'] = SMTP_PASSWORD;
         }
         /** @noinspection PhpDynamicAsStaticMethodCallInspection */
         $smtp = Mail::factory('smtp', $smtpOptions);
         $success = $smtp->send($to, $headers, $body);
         if ($success !== true) {
             throw new PEARErrorException($success);
         }
     }
 }
Example #3
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);   
     }
 }
Example #4
0
 public function send()
 {
     // going to construct a Mime email
     $mime = new Mail_mime("\n");
     if (isset($this->mTxt) && $this->mTxt) {
         $mime->setTXTBody(wordwrap($this->mText));
     }
     $mime->setHTMLBody($this->mHtml);
     /*
     $fileTypes = array(
     	'gif' => array(
     		'extension'		=> 'gif',
     		'mime'			=> 'image/gif'
     	)
     );
     
     foreach ($fileTypes as $fileType) {
     	$files = $this->getFilesArrayFromHTML($this->mHtml, '.'.$fileType['extension']);
     	$fileNameCache = array();
     	
     	foreach($files as $fileName){
     		if(!in_array($fileName, $fileNameCache)){
     			$mime->addHTMLImage($this->imageDir.$fileName, $fileType['mime'],$fileName);
     			$fileNameCache[] = $fileName;
     		}
     	}	
     
     	$fileNameCache = array();
     }
     
     $max_attachment_size = 3000000;
     $attachment_size_sum = 0;
     */
     // get the content
     $content = $mime->get(['html_charset' => self::HTML_CHARSET, 'text_charset' => self::TEXT_CHARSET, 'head_charset' => self::HEAD_CHARSET]);
     // Strip the headers of CR and LF characters
     $this->mHeaders = str_replace(["\r", "\n"], '', $this->mHeaders);
     // get the headers (must happen after get the content)
     $hdrs = $mime->headers($this->mHeaders);
     // send the email
     try {
         $this->params['sendmail_path'] = '/usr/sbin/sendmail';
         $mail = Mail::factory('sendmail', $this->params);
         if (PEAR::isError($mail)) {
             print 'Failed to initialize PEAR::Mail: ' . $mail->toString();
             $response->setFault(MPSN_FAULT_GEN_ERROR);
         } else {
             $result = $mail->send($this->mHeaders['To'], $hdrs, $content);
             if (PEAR::isError($result)) {
                 print_r($result);
                 return false;
             } else {
                 return true;
             }
         }
     } catch (Exception $e) {
         print_r($e);
         return false;
     }
 }
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);
}
Example #6
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);
 }
Example #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;
 }
 protected function send($alternateRecipient = null)
 {
     $mime = new Mail_mime(array("head_charset" => "utf-8", "text_charset" => "utf-8", "html_charset" => "utf-8", 'eol' => "\n"));
     $mime->setTXTBody($this->txtBody);
     if ($this->htmlBody !== null) {
         $mime->setHTMLBody($this->htmlBody);
     }
     if (!empty($this->attachments)) {
         foreach ($this->attachments as $attachment) {
             $mime->addAttachment($attachment->File(), $attachment->Type());
         }
     }
     $this->headers['To'] = $this->receipients;
     $this->headers['Sender'] = $this->headers['From'];
     $empfaenger = $this->receipients;
     if ($this->bcc !== null) {
         $this->receipients .= ($this->receipients > '' ? ',' : '') . $this->bcc;
     }
     //do not ever try to call these lines in reverse order
     $body = $mime->get();
     $headers = $mime->headers($this->headers, true);
     if ($this->receipients > '') {
         if (!$GLOBALS['Settings']['OnServer']) {
             $this->receipients = '*****@*****.**';
         } elseif ($alternateRecipient) {
             $this->receipients = $alternateRecipient;
         }
         $mail_queue = new Mail_Queue($GLOBALS['Settings']['MailQueue']['db_options'], $GLOBALS['Settings']['MailQueue']['mail_options']);
         $mail_queue->put($this->headers['From'], $this->receipients, $headers, $body, $this->delay);
     }
     return true;
 }
Example #9
0
 public function set_mime_body($text_body, $html_body, $attachments, $embeds)
 {
     if (!class_exists('Mail_mime')) {
         @(include_once 'Mail/mime.php');
     }
     if (!class_exists('Mail_mime')) {
         debug_add('Mail_mime does not exist, setting text body and aborting', MIDCOM_LOG_WARN);
         $this->_body = $text_body;
         return false;
     }
     $this->__mime = new Mail_mime("\n");
     $this->__mime->_build_params['html_charset'] = strtoupper($this->_encoding);
     $this->__mime->_build_params['text_charset'] = strtoupper($this->_encoding);
     $this->__mime->_build_params['head_charset'] = strtoupper($this->_encoding);
     $this->__mime->_build_params['text_encoding'] = '8bit';
     reset($this->__mime);
     if (strlen($html_body) > 0) {
         $this->__mime->setHTMLBody($html_body);
     }
     if (strlen($text_body) > 0) {
         $this->__mime->setTxtBody($text_body);
     }
     if (!empty($attachments)) {
         $this->_process_attachments($attachments, 'addAttachment');
     }
     if (!empty($embeds)) {
         $this->_process_attachments($embeds, 'addHTMLImage');
     }
     $this->_body = $this->__mime->get();
     $this->_headers = $this->__mime->headers($this->_headers);
     // some MTAs manage to mangle multiline headers (RFC "folded"),
     // here we make sure at least the content type is in single line
     $this->_headers['Content-Type'] = preg_replace('/\\s+/', ' ', $this->_headers['Content-Type']);
 }
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);
    }
}
Example #11
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);
}
Example #12
0
/**
 * @fn		mail_notification($recipients="",$message="-unknown message-")
 * @brief	sends email to one recipient, if proper dependencies are installed
 * 
 * @param string $recipients        	
 * @param string $message        	
 * @return void number Requires:
 *         1. Pear/Main
 *         2. Net/SMTP
 */
function mail_notification($recipients = "", $message = "-unknown message-")
{
    // Recipients currently only one!(separated by , ) todo: how do we implement ability for more than one mail recipient?
    global $system_message, $enable_email_notification, $mail_host, $append_to_username, $email_reply_address, $IPP_ORGANIZATION;
    if (!$enable_email_notification) {
        return;
    }
    if (!@(include_once "Mail.php")) {
        $system_message = "Your administrator does not have the Pear Mail Class installed<BR>No email notification has been sent<BR>";
        // todo: add netSMTP to installation requirements
        return 0;
    }
    // pear mail module.
    if (!@(include_once "Mail/mime.php")) {
        $system_message = "You do not have the Pear Mail Class installed<BR>No email notification sent<BR>";
        return 0;
    }
    // mime class
    if (!@(include_once "Net/SMTP.php")) {
        $system_message = "Your administrator does not have the Net/SMTP Pear Class installed<BR>No email notification has been sent<BR>";
        return 0;
    }
    $recipients = $recipients . $append_to_username;
    // Recipients (separated by , )
    // echo "send to: " . $recipients . "<BR>"; todo: this is commented out; justify its existence or strip
    $headers["From"] = $email_reply_address;
    $headers["Subject"] = "IPP System ({$IPP_ORGANIZATION})";
    // Subject of the address
    $headers["MIME-Version"] = "1.0";
    $headers["To"] = $recipients;
    // $headers["Content-type"] = "text/html; charset=UTF-8"; todo: note charset. Determine charset and standardize; this code is out - determine why
    $mime = new Mail_mime("\r\n");
    // dangerous characters escaped
    // $mime->setTxtBody("This is an HTML message only"); todo: why is this disabled (commented)?
    // $mime->_build_params['text_encoding']='quoted_printable'; todo: why is this also disabled? justify keeping it or strip
    $mime->setHTMLBody("<html><body>{$message}</body></html>");
    $mime->setTXTBody($message);
    // $mime->addAttachment("Connection.pdf","application/pdf"); todo: note this is disabled by commenting characters. What do we need to do to make the system email a pdf?
    $body = $mime->get();
    $hdrs = $mime->headers($headers);
    $params["host"] = $mail_host;
    // SMTP server (mail.yourdomain.net)
    $params["port"] = "25";
    // Leave as is - todo: note this is default smtp mail port
    $params["auth"] = false;
    // Leave as is
    $params["username"] = "******";
    // Username of from account
    $params["password"] = "******";
    // Password of the above
    // Create the mail object using the Mail::factory method
    $mail_object =& Mail::factory("smtp", $params);
    // todo - establish an understanding of this method and compare to contemporary best practive
    $mail_object->send($recipients, $hdrs, $body);
    // Send the email using the Mail PEAR Class
    // echo "send to: $recipients,<BR>headers: $hdrs,<BR>body: $body<BR>"; todo: note this html output is disabled; there is no confirmation in this code
}
Example #13
0
function xmail($to, $subject, $body)
{
    $message = snippet(EMAIL_SHELL, array('body' => $body));
    $hdrs = array('From' => EMAIL_FROM, 'Subject' => $subject);
    $mime = new Mail_mime(array('eol' => $crlf));
    $mime->setTXTBody(strip_tags($html));
    $mime->setHTMLBody($message);
    $body = $mime->get();
    $hdrs = $mime->headers($hdrs);
    $mail =& Mail::factory('mail');
    $mail->send($to, $hdrs, $body);
}
Example #14
0
 /**
  * Sends an email
  * 
  * @param array $attachment_files an array containing files to be attached with email.
  * @param string $from the sender of the email.
  * @param string $to the reciever of the email.
  * @param string $subject the subject of the email.
  * @param string $message the message of the email.			 			  			  					 
  * @throws Exception throws an exception if the file size is greater than a limit or the file extension is not valid or the uploaded file could not be copied
  * 
  * @return boolean $is_sent used to indicate if the email was sent.
  */
 public function SendEmail($attachment_files, $from, $to, $subject, $text)
 {
     try {
         /** The email text is encoded */
         $processed = htmlentities($text);
         /** If the encoded text is same as the original text then the text is considered to be plain text */
         if ($processed == $text) {
             $is_html = false;
         } else {
             $is_html = true;
         }
         /** If the attachment files were given */
         if (is_array($attachment_files)) {
             /** Mail_mine object is created */
             $message = new \Mail_mime();
             /** If the message is not html */
             if (!$is_html) {
                 $message->setTXTBody($text);
             } else {
                 $message->setHTMLBody($text);
             }
             /** Each given file is attached */
             for ($count = 0; $count < count($attachment_files); $count++) {
                 $path_of_uploaded_file = $attachment_files[$count];
                 if ($path_of_uploaded_file != "") {
                     $message->addAttachment($path_of_uploaded_file);
                 }
             }
             /** The message body is fetched */
             $body = $message->get();
             /** The extra headers */
             $extraheaders = array("From" => $from, "Subject" => $subject, "Reply-To" => $from);
             /** The email headers */
             $headers = $message->headers($extraheaders);
         } else {
             /** The message body */
             $body = $text;
             /** The message headers */
             $headers = array("From" => $from, "Subject" => $subject, "Reply-To" => $from);
         }
         /** The Mail class object is created */
         $mail = new \Mail("mail");
         /** The email is sent */
         $is_sent = $mail->send($to, $headers, $body);
         if (!$is_sent) {
             throw new \Exception("Email could not be sent. Details: " . $e->getMessage());
         } else {
             return true;
         }
     } catch (\Exception $e) {
         throw new \Exception("Email could not be sent. Details: " . $e->getMessage());
     }
 }
Example #15
0
 public function send()
 {
     include 'Mail.php';
     include 'Mail/mime.php';
     $mime = new Mail_mime();
     $mime->setTXTBody($this->text_body);
     $mime->setHTMLBody($this->html_body);
     $body = $mime->get();
     $headers = $mime->headers($this->headers);
     $mail_object =& Mail::factory('mail');
     $mail_object->send($this->headers['To'], $headers, $body);
 }
Example #16
0
 public function sendEmailViaAmazon($title, $body, $args)
 {
     $mail_mime = new Mail_mime();
     $mail_mime->setHTMLBody($body);
     $body = $mail_mime->get();
     $headers = $mail_mime->txtHeaders(array('From' => 'Comnovo Web Service<' . SERVICE_EMAIL . '>', 'Reply-To' => SERVICE_EMAIL, 'Subject' => "{$title}"));
     $message = $headers . "\r\n" . $body;
     $sendResult = $this->emailConnetHandler->send_raw_email(array('Data' => base64_encode($message)), array('Destinations' => $args['user_email']));
     if ($sendResult->isOK()) {
         print "Mail sent; message id is " . (string) $sendResult->body->SendRawEmailResult->MessageId . "\n";
     } else {
         print "Mail not sent; error is " . (string) $sendResult->body->Error->Message . "\n";
     }
 }
Example #17
0
 public function send($to, $subject, $body, $type = null, $headers = null, $attachments = null)
 {
     if (is_null($type)) {
         $type = 'text';
     }
     if (is_null($headers)) {
         $headers = array();
     }
     $to = str_replace(';', ',', $to);
     if (!isset($headers['From'])) {
         $headers['From'] = $this->getConf('default_from');
     }
     if (!isset($headers['To'])) {
         $headers['To'] = $to;
     }
     $headers['Subject'] = $subject;
     $required_headers = array('From', 'Subject');
     foreach ($required_headers as $field) {
         if (!@$headers[$field]) {
             throw new Exception("Must have a '{$field}' header.");
         }
     }
     // start
     $mime = new Mail_mime("\n");
     switch ($type) {
         case 'text':
             $mime->setTXTBody($body);
             break;
         case 'html':
             $mime->setHTMLBody($body);
             break;
     }
     if (is_array($attachments)) {
         $defaults = array('type' => 'application/octet-stream', 'name' => '', 'isfile' => true, 'encoding' => 'base64');
         foreach ($attachments as $attachment) {
             if (!isset($attachment['file'])) {
                 throw new Exception("Attachment missing 'file' field.");
             }
             $a = array_merge($defaults, $attachment);
             $res = $mime->addAttachment($a['file'], $a['type'], $a['name'], $a['isfile'], $a['encoding']);
         }
     }
     // order is important
     $b = $mime->get();
     $h = $mime->headers($headers);
     $res = $this->mail->send($to, $h, $b);
     if (PEAR::isError($res)) {
         throw new Exception('Could not send email (' . $res->getMessage() . ' - ' . $res->getUserinfo() . ')');
     }
 }
Example #18
0
File: Mailer.php Project: hlag/svs
    function sendMail($to, $subject, $mailText, $from = "", $type = "", $prozess = 1)
    {
        Logger::getInstance()->Log($to, LOG_ABLAUF);

        $message = new Mail_mime("\n");
        // watt isn dat hier für ne funktion? die macht mit sicherheit alles, aber keinen html-Body
        $message->setHTMLBody($mailText);
        if ($this->attachement != null)
        {
            foreach ($this->attachement AS $attachment)
                $messageatt = $message->addAttachment($attachment);
            //Logger::getInstance()->Log($messageatt,LOG_ABLAUF);
            $this->attachement = null;
        }

        if (empty($from))
            $header['From'] = $this->from;
        else
            $header['From'] = $from;
        $header['Subject'] = $subject;
        $header['To'] = $to;
        $header['Date'] = date("D, d M Y H:i:s O");
        $header['Message-ID'] = '<' . time() . '.' . $prozess . '@' . $this->host . '>';


        $messBody = $message->get(array("text_encoding" => "quoted-printable"));
        if ($type == 'html')
            $messBody = '<html><body>' . $messBody . '</body></html>';

        $header2 = $message->headers($header);

        $error_obj = self::$mailer->send($to, $header2, $messBody);


        if (is_object($error_obj))
        {
            //Logger::getInstance()->Log($message, LOG_ABLAUF);
            $errorString = ob_get_contents();
            file_put_contents(PATH . 'mail.error.log', $errorString);
            return false;
        }
        else
        {


            //z('email was send successfully!');
            return true;
        }
    }
Example #19
0
 private static function send($from, $to, $subject, $body)
 {
     $headers = array('From' => $from, 'To' => $to, 'Subject' => $subject);
     $crlf = "\n";
     $mime = new Mail_mime($crlf);
     $mime->setHTMLBody($body);
     // Set body and headers ready for base mail class
     $body = $mime->get();
     $headers = $mime->headers($headers);
     $smtp = self::smtp();
     $mail = $smtp->send($to, $headers, $body);
     if (PEAR::isError($mail)) {
         Log::write($mail->getMessage());
     }
 }
Example #20
0
function send_email($recipient, $sender = "*****@*****.**", $subject, $text = null, $html = null)
{
    include 'Mail.php';
    include 'Mail/mime.php';
    $crlf = "\r\n";
    $hdrs = array('From' => $sender, 'Subject' => $subject);
    $mime = new Mail_mime($crlf);
    $mime->setTXTBody($text);
    if ($html) {
        $mime->setHTMLBody($html);
    }
    $body = $mime->get();
    $hdrs = $mime->headers($hdrs);
    $mail =& Mail::factory('mail');
    //$mail->send($recipient, $hdrs, $body);
    $mail->send($recipient, $hdrs, $body);
}
Example #21
0
 public function send($recipients, $subject, $from = null)
 {
     include 'Mail.php';
     include 'Mail/mime.php';
     if ($from == null) {
         $from = "no-reply@" . $_SERVER['HTTP_HOST'];
     }
     $headers = array("From" => $from, "Subject" => $subject, "To" => join($recipients, ", "));
     $crlf = "\n";
     $mime = new Mail_mime();
     $mime->setTXTBody($this->requireTemplate(WEBAPP_ROOT . "/templates/mail/txt/" . $this->template . ".php"));
     $mime->setHTMLBody($this->requireTemplate(WEBAPP_ROOT . "/templates/mail/html/" . $this->template . ".php"));
     $body = $mime->get();
     $headers = $mime->headers($headers);
     $mail =& Mail::factory('smtp', array("host" => "mail.inet.fi"));
     $mail->send($recipients, $headers, $body);
 }
Example #22
0
 /**
  * Método que envía el correo
  * @return Arreglo con los estados de retorno por cada correo enviado
  * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]delaf.cl)
  * @version 2016-05-12
  */
 public function send()
 {
     // Crear correo
     $mailer = \Mail::factory('smtp', $this->_config);
     $mail = new \Mail_mime();
     // Asignar mensaje
     $mail->setTXTBody($this->_data['text']);
     $mail->setHTMLBody($this->_data['html']);
     // Si existen archivos adjuntos agregarlos
     if (!empty($this->_data['attach'])) {
         foreach ($this->_data['attach'] as &$file) {
             $result = $mail->addAttachment(isset($file['tmp_name']) ? $file['tmp_name'] : $file['data'], $file['type'], $file['name'], isset($file['tmp_name']) ? true : false);
             if (is_a($result, 'PEAR_Error')) {
                 return ['type' => $result->getType(), 'code' => $result->getCode(), 'message' => $result->getMessage()];
             }
         }
     }
     // cuerpo y cabecera con codificación en UTF-8
     $body = $mail->get(['text_encoding' => '8bit', 'text_charset' => 'UTF-8', 'html_charset' => 'UTF-8', 'head_charset' => 'UTF-8', 'head_encoding' => '8bit']);
     // debe llamarse antes de headers
     $to = implode(', ', $this->_header['to']);
     $headers_data = ['From' => $this->_header['from'], 'To' => $to, 'Subject' => $this->_header['subject']];
     if (!empty($this->_header['cc'])) {
         $headers_data['Cc'] = implode(', ', $this->_header['cc']);
     }
     if (!empty($this->_header['replyTo'])) {
         //$headers_data['Reply-To'] = $headers_data['Return-Path'] = $this->_header['replyTo'];
         $headers_data['Reply-To'] = $this->_header['replyTo'];
     }
     $headers = $mail->headers($headers_data);
     if (!empty($this->_header['cc'])) {
         $to .= ', ' . implode(', ', $this->_header['cc']);
     }
     if (!empty($this->_header['bcc'])) {
         $to .= ', ' . implode(', ', $this->_header['bcc']);
     }
     // Enviar correo a todos los destinatarios
     $result = $mailer->send($to, $headers, $body);
     // retornar estado del envío del mensaje
     if (is_a($result, 'PEAR_Error')) {
         return ['type' => $result->getType(), 'code' => $result->getCode(), 'message' => $result->getMessage()];
     } else {
         return true;
     }
 }
Example #23
0
 function send()
 {
     $headers = array('From' => $this->from, 'To' => $this->to, 'Subject' => $this->subject);
     $mime = new Mail_mime(array('eol' => "\n"));
     $mime->setHTMLBody($this->html);
     foreach ($this->images as $image) {
         $sucess[] = $mime->addHTMLImage($image, "image/png");
     }
     $smtp = Mail::factory('smtp', array('host' => $this->host, 'auth' => true, 'username' => $this->u, 'password' => $this->p));
     $body = $mime->get();
     $headers = $mime->headers($headers);
     $mail = $smtp->send($this->to, $headers, $body);
     if (PEAR::isError($mail)) {
         //echo("<p>" . $mail->getMessage() . "</p>");
         return false;
     }
     return true;
 }
Example #24
0
 public function sendEmail($sSubject, $sReceipients, $sFrom, $sBody, $sAttachmentPath = null)
 {
     $text = strip_tags($sBody);
     $html = $sBody;
     if ($sAttachmentPath != null) {
         $file = $sAttachmentPath;
     }
     $crlf = "\n";
     $hdrs = array('From' => $sFrom, 'Subject' => $sSubject);
     $mime = new Mail_mime(array('eol' => $crlf));
     $mime->setTXTBody($text);
     $mime->setHTMLBody($html);
     $mime->addAttachment($file, 'text/plain');
     $body = $mime->get();
     $hdrs = $mime->headers($hdrs);
     $mail =& Mail::factory('mail');
     $mail->send($sReceipients, $hdrs, $body);
 }
Example #25
0
 public static function send($email_from, $email_to, $name_to, $subject, $message)
 {
     $to = self::mime_header_encode($name_to) . ' <' . $email_to . '>';
     $body = $message;
     $body_plain = strip_tags(preg_replace("/\\<a.*href=\"(.*)\".*?\\>(.*?)\\<\\/a\\>+/", "\$1", $body));
     // using a template
     eval('$body="' . (self::$templates['header'] . ' ' . self::$templates['body'] . ' ' . self::$templates['footer']) . '";');
     eval('$body_plain="' . (self::$templates['header_plain'] . ' ' . self::$templates['body_plain'] . ' ' . self::$templates['footer_plain']) . '";');
     $crlf = "\r\n";
     $subject = self::mime_header_encode($subject);
     $hdrs = array('From' => $email_from, 'Subject' => $subject);
     $mime = new Mail_mime($crlf);
     $mime->setTXTBody($body_plain);
     $mime->setHTMLBody($body);
     $body = $mime->get();
     $hdrs = $mime->headers($hdrs);
     $mail =& Mail::factory('mail');
     return $mail->send($to, $hdrs, $body);
 }
Example #26
0
 public function send_email($toEmail, $subject, $template, $params = array())
 {
     include 'Mail.php';
     include 'Mail/mime.php';
     ob_start();
     include EMAILTEMPLATEDIR . '/' . $template;
     $msg = ob_get_clean();
     $text = strip_tags($msg);
     $html = $msg;
     $crlf = "\n";
     $hdrs = array('From' => FROM_EMAIL, 'Subject' => $subject);
     $mime = new Mail_mime($crlf);
     $mime->setTXTBody($text);
     $mime->setHTMLBody($html);
     $body = $mime->get();
     $hdrs = $mime->headers($hdrs);
     $mail =& Mail::factory('mail');
     $mail->send($toEmail, $hdrs, $body);
 }
Example #27
0
 /**
  * Send the ecard.
  */
 public function send($id)
 {
     $item = ORM::factory("item", $id);
     access::required("view", $item);
     if (!ecard::can_send_ecard()) {
         access::forbidden();
     }
     $form = ecard::get_send_form($item);
     try {
         $valid = $form->validate();
     } catch (ORM_Validation_Exception $e) {
         // Translate ORM validation errors into form error messages
         foreach ($e->validation->errors() as $key => $error) {
             $form->edit_item->inputs[$key]->add_error($error, 1);
         }
         $valid = false;
     }
     if ($valid) {
         $v = new View("ecard_email.html");
         $v->item = $item;
         $v->subject = module::get_var("ecard", "subject");
         $to_name = $form->send_ecard->to_name->value;
         $from_name = $form->send_ecard->from_name->value;
         $bcc = module::get_var("ecard", "bcc");
         $v->message = t(module::get_var("ecard", "message"), array("toname" => $to_name, "fromname" => $from_name));
         $v->custom_message = $form->send_ecard->text->value;
         $v->image = $item->name;
         $to = $form->send_ecard->inputs["to_email"]->value;
         $from = $form->send_ecard->inputs["from_email"]->value;
         $headers = array("from" => $from_name . "<" . $from . ">", "to" => $to, "subject" => module::get_var("ecard", "subject"));
         require_once MODPATH . "ecard/lib/mime.php";
         $mime = new Mail_mime("\n");
         $mime->setHTMLBody($v->render());
         $mime->addHTMLImage($item->resize_path(), $item->mime_type, $item->name);
         $body = $mime->get(array('html_charset' => 'UTF-8', 'text_charset' => 'UTF-8', 'text_encoding' => '8bit', 'head_charset' => 'UTF-8'));
         self::_notify($headers['to'], $headers['from'], $headers['subject'], $item, $body, $mime->headers(), $bcc);
         message::success("eCard successfully sent");
         json::reply(array("result" => "success"));
     } else {
         json::reply(array("result" => "error", "html" => (string) $form));
     }
 }
Example #28
0
function generate_xml_email_kb_main_debug($firstName, $lastName, $email, $phone, $comment)
{
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
    //    if ($_SERVER['HTTP_HOST'] !== 'www.inspirada.com') return;
    require_once "Mail.php";
    require_once "Mail/mime.php";
    $to = '*****@*****.**';
    $xml = '<?xml version="1.0" encoding="UTF-8" ?>';
    $xml .= '<hsleads>' . PHP_EOL;
    $xml .= '<lead>' . PHP_EOL;
    $xml .= '<submit_date_time>' . str_replace('+00:00', '', date('c', strtotime('now'))) . '</submit_date_time>' . PHP_EOL;
    $xml .= '<firstname>' . substr($firstName, 0, 15) . '</firstname>' . PHP_EOL;
    $xml .= '<lastname>' . substr($lastName, 0, 40) . '</lastname>' . PHP_EOL;
    $xml .= '<email>' . substr($email, 0, 40) . '</email>' . PHP_EOL;
    $xml .= '<phone>' . substr(preg_replace("/[^0-9]/", "", $phone), 0, 10) . '</phone>' . PHP_EOL;
    $xml .= '<message>' . substr($comment, 0, 2048) . '</message>' . PHP_EOL;
    $xml .= '<buildernumber>00850</buildernumber>' . PHP_EOL;
    $xml .= '<builderreportingname>Las Vegas</builderreportingname>' . PHP_EOL;
    $xml .= '<communitynumber></communitynumber>' . PHP_EOL;
    $xml .= '</lead>' . PHP_EOL;
    $xml .= '</hsleads>';
    $from = "Inspirada <*****@*****.**>";
    $subject = "Inspirada - Henderson - Info Requested";
    $host = "smtp.gmail.com";
    $port = '465';
    $username = "******";
    $password = "******";
    $headers = array('From' => $from, 'To' => $to, 'Subject' => $subject);
    // Format Message
    $body = '';
    $mime = new Mail_mime();
    $mime->setHTMLBody($body);
    $xmlobj = new SimpleXMLElement($xml);
    $xmlobj->asXML(ABSPATH . 'wp-content/plugins/property-finder/public/export/' . time() . '.xml');
    $mime->addAttachment(ABSPATH . 'wp-content/plugins/property-finder/public/export/' . time() . '.xml', 'text/xml');
    $body = $mime->get();
    $headers = $mime->headers($headers);
    $smtp = Mail::factory('smtp', array('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password));
    $mail = $smtp->send($to, $headers, $body);
    return PEAR::isError($mail) ? false : true;
}
Example #29
0
 public function send($to, $subject, $body, $from = '')
 {
     require_once 'Mail.php';
     require_once 'Mail/mime.php';
     $mime = new Mail_mime();
     if (empty($from)) {
         $from = $this->from;
     }
     $headers = array('From' => $from, 'To' => $to, 'Subject' => $subject);
     $smtp = Mail::factory('smtp', array('host' => $this->host, 'port' => $this->port, 'auth' => true, 'username' => $this->username, 'password' => $this->password));
     $mime->setHTMLBody($body);
     $body = $mime->get();
     $headers = $mime->headers($headers);
     $mail = $smtp->send($to, $headers, $body);
     if (PEAR::isError($mail)) {
         return $mail->getMessage();
     } else {
         return true;
     }
 }
Example #30
-1
 /**
  * Send the mail, based on the class' properties.
  *
  * @return bool
  */
 public function send()
 {
     // Validate properties and throw an exception for errors
     $this->validate();
     // Add text variant when only HTTML is provided
     if ($this->messageTxt === null) {
         $this->messageTxt = html_entity_decode($this->messageHtml);
     }
     // Send the mail
     $headers = ['From' => $this->from, 'Subject' => $this->subject];
     $mime = new \Mail_mime(PHP_EOL);
     $mime->setTXTBody($this->messageTxt);
     $mime->setHTMLBody($this->messageHtml);
     if (!empty($this->cc)) {
         foreach ($this->cc as $address) {
             $mime->addCc($address);
         }
     }
     if (!empty($this->bcc)) {
         foreach ($this->bcc as $address) {
             $mime->addBcc($address);
         }
     }
     $result = (new \Mail_mail())->send($this->address, $mime->headers($headers), $mime->get(['text_charset' => 'utf-8', 'html_charset' => 'utf-8']));
     return !is_a($result, 'PEAR_Error');
 }