예제 #1
0
 /**
  *
  * @param 	array $o
  * @throws InvalidArgumentException
  * @return multitype:NULL string |multitype:NULL |number
  *
  */
 public function sendBasic(smMailMessage $smMailMessage, array $options)
 {
     $this->smMailMessage = $smMailMessage;
     $message = Swift_Message::newInstance();
     $this->setSMTPData($message, $options['account']);
     $this->feedAddress($message, 'to', $this->smMailMessage->to);
     $this->feedAddress($message, 'cc', $this->smMailMessage->cc);
     $this->feedAddress($message, 'bcc', $this->smMailMessage->bcc);
     $message->setFrom(array($smMailMessage->from => $smMailMessage->fromName ? $smMailMessage->fromName : $this->from));
     $message->setSender($smMailMessage->sender);
     $message->addReplyTo($this->smMailMessage->replyTo);
     $message->setSubject($smMailMessage->subject);
     $headers = $message->getHeaders();
     if (count($this->customheaders) > 0) {
         foreach ($this->customheaders as $kc => $vc) {
             $headers->addTextHeader(array($kc, $vc));
         }
     }
     foreach ($smMailMessage->attachments as $k => $v) {
         $message->attach(Swift_Attachment::fromPath($v));
     }
     $type = $message->getHeaders()->get('Content-Type');
     $type->setValue('text/html');
     $type->setParameter('charset', $this->charset);
     $message->setBody($smMailMessage->HTMLBody)->addPart($smMailMessage->HtmlToTextBody());
     $success = $this->mailer->send($message, $error) > 0;
     return array('success' => $success, 'mailStream' => $success ? $message->toString() : null, 'error' => $error);
 }
예제 #2
0
 /**
  *
  * @param unknown $o
  * @return multitype:Ambigous <multitype:NULL, number>
  * http://127.0.0.1/extmailbox_local/proxy.php?attachments=[]&bcc=[]&body=%26nbsp%3Btest1&cc=[]&exw_action=local.MailboxSmtpExt.sendMail&from=micoli%40mail.local&message_id=40ac2d70-e52c-4e5f-96e0-584478c5dcaf&priority=medium&ref=&subject=test1&to=[{%22email%22%3A%22micoli%40mail.local%22%2C%22name%22%3A%22%22}]&account=micoli@ms
  * http://localhost/extmailbox_local/proxy.php?exw_action=local.MailboxSmtpExt.sendMail&account=micoli%40ms&attachments=[%220cfd65d5-1f80-4b0c-8e29-28e7877ab41b-9-Des%20portails%20ferms%20%20l%27uniformit%22%2C%220cfd65d5-1f80-4b0c-8e29-28e7877ab41b-4-La%20cuisine%20contemporaine%20privilgie%20la%20transparence%22]&bcc=[]&body=%26nbsp%3B%20test%20de%20text%20ht%3Cspan%20style%3D%22background-color%3A%20rgb%28255%2C%20255%2C%20153%29%3B%22%3Eml%3Cb%3Edsdsd%3C%2Fb%3Edsds%3C%2Fspan%3Eds%20%3Ci%3Edsdsds%20%3C%2Fi%3E%3Cbr%3E%26nbsp%3Btest%20de%20text%20ht%3Cspan%20style%3D%22background-color%3A%20rgb%28255%2C%20255%2C%20153%29%3B%22%3Eml%3Cb%3Edsdsd%3C%2Fb%3Edsds%3C%2Fspan%3Eds%20%3Ci%3Edsdsds%26nbsp%3B%20%3C%2Fi%3Etest%20de%20text%20ht%3Cspan%20style%3D%22background-color%3A%20rgb%28255%2C%20255%2C%20153%29%3B%22%3Eml%3Cb%3Edsdsd%3C%2Fb%3Edsds%3C%2Fspan%3Eds%20%3Ci%3Edsdsds%3C%2Fi%3E&cc=[]&from=micoli%40mail.local&message_id=0cfd65d5-1f80-4b0c-8e29-28e7877ab41b&priority=medium&ref=&subject=test%20123&to=[{%22email%22%3A%22micoli%40mail.local%22%2C%22name%22%3A%22%22}]
  */
 public function pub_sendMail($o)
 {
     /*
     *'from','fromName'
     *'to','cc','bcc'
     *'sender','replyTo'
     'subject'
     'lng'
     'charset'
     'plaintext
     'HTMLBody'
     'newTextBody'
     'attachment'
     */
     header('content-type:text/html');
     error_reporting(E_ALL ^ E_NOTICE);
     ini_set('display_errors', 1);
     ini_set('html_errors', 1);
     $p = QDImap::makeMailEditorStruct($o);
     $sender = new mailSenderSwiftMailer();
     $res = $sender->sendBasic(smMailMessage::create()->set($p), array('account' => $GLOBALS['conf']['imapMailBox']['accounts'][$o['account']]['smtp']));
     if ($res['success']) {
         $sentFolder = $GLOBALS['conf']['imapMailBox']['accounts'][$o['account']]['sendFolder'];
         $this->setAccount($o['account']);
         $this->imapProxy->open($sentFolder);
         $r = $this->imapProxy->append($sentFolder, $res['mailStream'], "\\Seen");
     }
     return array('success' => $res['success']);
 }
예제 #3
0
        } else {
            $attachments[] = (isnull($base) ? $base . '/' : '') . $filename;
        }
        return $this;
    }
    public function HtmlToTextBody($body = null)
    {
        if (is_null($body)) {
            $body = $this->_HTMLBody;
        }
        $lastligne = '';
        $tmpBody = utf8_decode($body);
        // on decode les caracteres encodés en utf-8 vers ISO-8859-1
        $tmpBody = preg_replace('!<title>(.*?)</title>!', '', $tmpBody);
        $tmpBody = preg_replace('!<a href(.*?)alt="(.*?)"(.*?)>(.*?)</a>!', "\\2", $tmpBody);
        $tmpBody = strip_tags($tmpBody);
        $tmpBody = str_replace("\r", "", $tmpBody);
        $tmpBodyArr = array();
        foreach (explode("\n", $tmpBody) as $ligne) {
            $ligne = trim($ligne);
            if (!($ligne == '' && $lastligne == '')) {
                $ligne = str_replace('&#149;', '-', $ligne);
                $tmpBodyArr[] = html_entity_decode($ligne);
            }
            $lastligne = $ligne;
        }
        return join("\n", $tmpBodyArr);
    }
}
smMailMessage::init();