/** *发送邮件 * *@param string 发送邮箱地址 *@param array 接收邮箱地址 *@param array 抄送人 *@param string 邮件标题 *@param string 邮件内容 *@param array 文件附件,地址格式 *@param string 编码格式 */ public function send($from, $to, $cc = '', $subject, $content = '', $files = '', $char = 'utf-8') { $site_email = new htmlMimeMail5(); $site_email->setHeadCharset($char); $site_email->setTextCharset($char); $site_email->setHtmlCharset($char); $site_email->setFrom($from); $site_email->setSubject($subject); $site_email->setHTML($content); $site_email->setCc($cc); $address = explode(",", $to); if ($files != '') { foreach ($files as $file) { if (file_exists($file)) { $attachment = new fileAttachment($file); $site_email->addAttachment($attachment); } else { $this->logger->write_log('ERROR', 'MAIL: attachment ' . $file . ' not exists'); } } } foreach ($address as $k) { $mail[$k] = 1; } foreach ($mail as $k => $v) { $address_new[] = $k; } if ($site_email->send($address_new)) { return true; } else { return false; } }
function send_mail_client($email) { $text = '<p>Спасибо за регистрацию!</p>'; $text .= '<p>Ждем Вас 24 и 25 марта 2015 года в НСК «Олимпийский»,"Зал Чемпионов".</p>'; $mailSend = new htmlMimeMail5(); $helo = "Aviaforum Kiev"; $mailSend->setFrom('Aviaforum Kiev <' . MAILUSER . '>'); $mailSend->setTextCharset('utf-8'); $mailSend->setHtmlCharset('utf-8'); $mailSend->setHeadCharset('utf-8'); $mailSend->setSubject('Авиафорум'); $mailSend->setHTML($text); $mailSend->send(array($email), mail); }
/** * Envoie de mail sur l'evolution des données de la transactions depuis Arcadia * @param string $paramSujet * @param string $paramCorpMail * @param string $paramArdTto * @param string $paramArdFrom * @param string $paramUrlSmtp * @return string */ function sendMail($paramSujet, $paramCorpMail, $paramArdTto, $paramArdFrom, $paramUrlSmtp) { //Création du mail $mail = new htmlMimeMail5(); // $mail->setSMTPParams($paramUrlSmtp); // Set the From and Reply-To headers $mail->setFrom($paramArdFrom); $mail->setReturnPath($paramArdFrom); // Set the Subject $mail->setSubject($paramSujet); /** * Encodement en utf-8 */ $mail->setTextCharset("UTF-8"); $mail->setHTMLCharset("UTF-8"); $mail->setHeadCharset("UTF-8"); // Set the body $mail->setHTML(nl2br($paramCorpMail)); /** * L'envoi réel du mail n'est pas réalisé en environnement Codeur */ $result = $mail->send(array($paramArdTto), 'smtp'); return $result; }
public function sendMail($strSubject, $strHtmlBody, $strSender, $arrRecipients) { $strReturn = ""; //*** Build the e-mail. $strTextBody = str_replace("<br /> ", "<br />", $strHtmlBody); $strTextBody = str_replace("<br />", "\n", $strTextBody); $strTextBody = str_replace(" ", "", $strTextBody); $strTextBody = strip_tags($strTextBody); $strTextBody = html_entity_decode($strTextBody, ENT_COMPAT, "UTF-8"); //*** Send the email. $objMail = new htmlMimeMail5(); $objMail->setHTMLEncoding(new Base64Encoding()); $objMail->setTextCharset("utf-8"); $objMail->setHTMLCharset("utf-8"); $objMail->setHeadCharset("utf-8"); $objMail->setFrom($strSender); $objMail->setSubject($strSubject); $objMail->setText($strTextBody); $objMail->setHTML($strHtmlBody); if (!$objMail->send($arrRecipients)) { $strReturn = $objMail->errors; } return $strReturn; }
function envoismail($sujetmail, $text, $destinataire, $expediteur, $paramTypeMail = null, $conf = null) { if ($conf == null) { $globalConfig = new GlobalConfig(); } if ($globalConfig->getConf()->getSmtpServiceEnable() == TRUE) { /* * Toutes les adresses emails sont redirigées vers utilisateurs.fta@ldc.fr * Si la redirection est mis en place */ if ($globalConfig->getConf()->getSmtpEmailRedirectionUser()) { $destinataire_orig = $destinataire; $destinataire = $globalConfig->getConf()->getSmtpEmailRedirectionUser(); $sujetmail_orig = $sujetmail; $sujetmail = "[Environnement " . $globalConfig->getConf()->getExecEnvironment() . "] " . $sujetmail_orig; $text_orig = $text; if (is_array($destinataire_orig)) { $listeDesDestinataire = explode(",", $destinataire_orig); } else { $listeDesDestinataire = $destinataire_orig; } $text = $listeDesDestinataire . "\n" . $text_orig; } //Création du mail $mail = new htmlMimeMail5(); $mail->setSMTPParams($globalConfig->getConf()->getSmtpServerName()); // Set the From and Reply-To headers $mail->setFrom($expediteur); $mail->setReturnPath($expediteur); // Set the Subject $mail->setSubject($sujetmail); /** * Encodement en utf-8 */ $mail->setTextCharset("UTF-8"); $mail->setHTMLCharset("UTF-8"); $mail->setHeadCharset("UTF-8"); // Set the body $mail->setHTML(nl2br($text)); //$result = $mail->send(array($adresse_to), 'smtp'); //$result = $mail->send(array($destinataire), 'smtp'); /** * L'envoi réel du mail n'est pas réalisé en environnement Codeur */ if ($paramTypeMail != "mail-transactions") { $result = $mail->send(array($destinataire), 'smtp'); } if (!$result and $globalConfig->getConf()->getExecEnvironment() == EnvironmentConf::ENV_PRD) { $paramTypeMail = "Erreur"; } } /** * Génération de log */ $paramLog = $paramTypeMail . " " . $expediteur . " " . $destinataire . "\n" . $sujetmail . "\n" . $text; // Logger::AddMail($paramLog, $paramTypeMail); }
public function sendMsgNow($message) { $mType = $message->mType; $recp = westorElggMan_get_entity($message->toId); $sender = westorElggMan_get_entity($message->fromId); $senderEmail = $this->getEntityProperty($sender, elgg_echo('ElggMan_:cEmail')); $subject = $message->title; $body = $message->description; if ($message->mType == "EMAIL" || $message->mType == "EMAILTXT") { $mail = new htmlMimeMail5(); } switch ($message->mType) { case "EMAIL": $mail->setHTMLCharset("UTF-8"); $mail->setHTML($body); case "EMAILTXT": $mail->setTextCharset("UTF-8"); $mail->setHeadCharset("UTF-8"); $mail->setFrom($senderEmail); $mail->setSubject($subject); $search = array("|<br[[:space:]]*/?[[:space:]]*>|i", "|</p>|i"); $replace = array("\r\n", "\r\n"); $mail->setText(strip_tags(html_entity_decode(preg_replace($search, $replace, $body)))); if ($recp->getSubtype() == "PrivateContact") { $mail->send(array($recp->user_email)); } else { $mail->send(array($recp->email)); } $message->waitForSend = 0; // mark as done $message->state = 'OK'; break; case "HQ-SMS": $senderNumber = $sender->westorElggManSMSSender; $recipientNumber = $this->getEntityProperty($recp, elgg_echo('ElggMan_:cMobile')); $result = $this->sendSMSToGateway($senderNumber, $recipientNumber, $body, $message->mType); if ($result["success"]) { $message->waitForSend = 0; // mark as done $message->state = 'OK'; } else { if ($message->retryed >= 3) { $message->waitForSend = 0; // mark as done $message->state = 'FAILED'; } $message->retryed++; } break; default: } // switch $message->save(); return $result; }