/** *发送邮件 * *@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_report_mail($recipient) { global $PATH, $MAIL_CFG, $LNK; $fullfilename = $this->fname; $msg = "Ein Backup vom Server zum Backup-Server wurde erstellt. Dabei wurde folgendes Protokoll erstellt:\n\n"; $msg .= $fullfilename . "\n\n"; $msg .= "Es gab folgende FEHLER (nur solche, die automatisch erfasst werden konnten):\n\n"; $sql = "select * from reports where klasse like 'ERROR' order by uid asc;"; $result = mysqli_query($LNK, $sql); $txt = ""; while ($row = mysqli_fetch_assoc($result)) { $txt .= $row["datum"] . "\t"; $txt .= $row["meldung"] . "\n"; } $msg .= $txt; if ($txt == "") { $msg .= "< KEINE. >"; } $msg .= "\n\n\nEs gab folgende WARNUNGEN:\n\n"; $sql = "select * from reports where klasse like 'WARNING' order by uid asc;"; $result = mysqli_query($LNK, $sql); $txt = ""; while ($row = mysqli_fetch_assoc($result)) { $txt .= $row["datum"] . "\t"; $txt .= $row["meldung"] . "\n"; } $msg .= $txt; if ($txt == "") { $msg .= "< KEINE. >"; } $mail = new htmlMimeMail5(); $mail->setFrom($MAIL_CFG["from"]); $mail->setSubject('Backup-Durchlauf ' . strftime('%d.%m.%y %H:%M:%S', time())); $mail->setHeader('Date', date('D, d M y H:i:s O')); $mail->setTextCharset('UTF-8'); $mail->setText($msg); $mail->setHtmlCharset('UTF-8'); $mail->setHTML(file_get_contents($this->fname)); // $mail->addEmbeddedImage(new fileEmbeddedImage($PATH."img/APPrototype.gif")); // $mail->addAttachment(new fileAttachment('example.zip')); $mail->setSMTPParams($MAIL_CFG["host"], $MAIL_CFG["port"], $MAIL_CFG["helo"], $MAIL_CFG["auth"], $MAIL_CFG["user"], $MAIL_CFG["pass"]); $mail->send(array($recipient), 'smtp'); // first param is an array! if (isset($mail->errors)) { echo "\n\n\nFehler beim Versand der Report-Mail an {$recipient} !\n\n\n"; if (is_array($mail->errors)) { echo implode("; ", $mail->errors) . "\n"; // non-fatal; } else { errlog($mail->errors) . "\n"; // non-fatal; } } }
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); }
public function sendEmail($subject, $body, $recipientID, $parameters) { $emailData = $this->getEMailData($parameters); $parameters = explode("::", $parameters); $action = $parameters[0]; $className = $parameters[1]; $classID = $parameters[2]; $time = $parameters[3]; $C = new $className($classID); $data = $C->getCalendarDetails($className, $classID); $adresse = $data->getAdresse(); $fromName = Session::currentUser()->A("name"); $from = Session::currentUser()->A("UserEmail"); $mail = new htmlMimeMail5(); $mail->setFrom(utf8_decode($fromName . " <" . $from . ">")); if (!ini_get('safe_mode')) { $mail->setReturnPath($from); } $mail->setSubject(utf8_decode($subject)); /*if($action == "reply"){ $ics = "BEGIN:VCALENDAR PRODID:-//lightCRM Kalender VERSION:2.0 METHOD:REPLY BEGIN:VEVENT CREATED:20121130T004454Z LAST-MODIFIED:20121201T143509Z DTSTAMP:20121201T143509Z UID:7715ie5i20hvm0b71p18vhgj70@google.com SUMMARY:Test STATUS:CONFIRMED ORGANIZER;CN=rainer.furtmeier@googlemail.com:mailto:rainer.furtmeier@googl email.com ATTENDEE;CN=nemi@2sins.de;PARTSTAT=ACCEPTED;CUTYPE=INDIVIDUAL;ROLE=REQ-PAR TICIPANT;X-NUM-GUESTS=0:mailto:nemi@2sins.de DTSTART:20121206T123000Z DTEND:20121206T133000Z DESCRIPTION: SEQUENCE:5 TRANSP:OPAQUE END:VEVENT END:VCALENDAR"; }*/ if ($action == "notification") { $ics = "BEGIN:VCALENDAR\nPRODID:-//lightCRM Kalender\nVERSION:2.0\nMETHOD:REQUEST\nBEGIN:VTIMEZONE\nTZID:Europe/Berlin\nX-LIC-LOCATION:Europe/Berlin\nBEGIN:DAYLIGHT\nTZOFFSETFROM:+0100\nTZOFFSETTO:+0200\nTZNAME:CEST\nDTSTART:19700329T020000\nRRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3\nEND:DAYLIGHT\nBEGIN:STANDARD\nTZOFFSETFROM:+0200\nTZOFFSETTO:+0100\nTZNAME:CET\nDTSTART:19701025T030000\nRRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10\nEND:STANDARD\nEND:VTIMEZONE\nBEGIN:VEVENT\nLAST-MODIFIED:20120629T094018Z\nDTSTAMP:" . date("Ymd") . "T" . date("His") . "\nUID:" . $data->UID() . "\nSUMMARY:" . $data->summary() . "\nORGANIZER;CN=\"{$fromName}\":MAILTO:{$from}\nDTSTART;TZID=Europe/Berlin:" . date("Ymd", Kalender::parseDay($data->getDay())) . "T" . $data->getTime() . "00\nDTEND;TZID=Europe/Berlin:" . date("Ymd", Kalender::parseDay($data->getEndDay())) . "T" . $data->getEndTime() . "00\nEND:VEVENT\nEND:VCALENDAR"; } $mail->addAttachment(new stringAttachment($ics, "event.ics", 'application/ics')); $adresse->replaceByAnsprechpartner($recipientID); $body = str_replace("{Anrede}", Util::formatAnrede($_SESSION["S"]->getUserLanguage(), $adresse), $body); if ($action == "notification") { $mail->setCalendar($ics, "REQUEST"); } #if($action == "reply") # $mail->setCalendar($ics, "REPLY"); $mail->setTextCharset("UTF-8"); $mail->setCalendarCharset("UTF-8"); $mail->setText($body); #print_r($mail->getRFC822(array("*****@*****.**"))); #die(); $mail->send(array($emailData["recipients"][$recipientID][1])); $C->setNotified($className, $classID); }
/** * @param string $iCal * @param string $myEmail * @param int $answer possible values: accept: 1, maybe: 2, decline: 3 */ public static function answerInvitation(string $iCal, string $myEmail, int $answer) { if ($answer == "1") { $text = "akzeptiert"; } if ($answer == "2") { $text = "vorläufig akzeptiert"; } if ($answer == "3") { $text = "abgelehnt"; } $VC = new vcalendar(); $VC->parse($iCal); $event = $VC->getComponent("vevent"); $targetAttendee = "MAILTO:" . $myEmail; $i = 1; while ($valueOccur = $event->getProperty("ATTENDEE", $i, true)) { if (stripos($valueOccur["value"], $targetAttendee) === false) { $i++; continue; } $params = $valueOccur["params"]; if ($answer == "1") { $params["PARTSTAT"] = "ACCEPTED"; } if ($answer == "2") { $params["PARTSTAT"] = "TENTATIVE"; } if ($answer == "3") { $params["PARTSTAT"] = "DECLINED"; } if (isset($params["RSVP"])) { unset($params["RSVP"]); } $event->setAttendee($targetAttendee, $params, $i); $i++; } $i = 1; while ($valueOccur = $event->getProperty("ATTENDEE", $i, true)) { if (stripos($valueOccur["value"], $targetAttendee) === false) { $i++; $event->deleteProperty("ATTENDEE"); continue; } $i++; } $event->setProperty("DTSTAMP", gmdate("Ymd") . "T" . gmdate("His") . "Z"); $event->setProperty("LAST-MODIFIED", gmdate("Ymd") . "T" . gmdate("His") . "Z"); $VC->deleteComponent("vevent"); $VC->setComponent($event); $VC->setMethod("REPLY"); $ics = $VC->createCalendar(); $fromName = Session::currentUser()->A("name"); $from = Session::currentUser()->A("UserEmail"); $mail = new htmlMimeMail5(); $mail->setFrom(utf8_decode($fromName . " <" . $from . ">")); if (!ini_get('safe_mode')) { $mail->setReturnPath($from); } $mail->setSubject(utf8_decode("Antwort Termineinladung (" . ucfirst($text) . "): " . $event->getProperty("SUMMARY"))); $mail->addAttachment(new stringAttachment($ics, "invite.ics", 'application/ics')); $mail->setCalendar($ics, "REPLY"); $mail->setCalendarCharset("UTF-8"); $mail->setTextCharset("UTF-8"); $mail->setText("{$fromName} hat diesen Termin {$text}"); $organizer = str_replace("MAILTO:", "", $event->getProperty("ORGANIZER")); return $mail->send(array($organizer)); }
/** * 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; }