if (!$current) { header("location: tiki-webmail.php?locSection=settings"); die; } // Send a message if (isset($_REQUEST["reply"]) || isset($_REQUEST["replyall"])) { check_ticket('webmail'); $webmaillib->set_mail_flag($current["accountId"], $user, $_REQUEST["realmsgid"], 'isReplied', 'y'); } $smarty->assign('sent', 'n'); $smarty->assign('attaching', 'n'); if (isset($_REQUEST["send"])) { $mail = new htmlMimeMail(); $mail->setFrom($current["account"]); $mail->setCc($_REQUEST["cc"]); $mail->setBcc($_REQUEST["bcc"]); $mail->setSubject($_REQUEST["subject"]); if ($_REQUEST["attach1"]) { check_ticket('webmail'); $a1 = $mail->getFile('temp/mail_attachs/' . $_REQUEST["attach1file"]); $mail->addAttachment($a1, $_REQUEST["attach1"], $_REQUEST["attach1type"]); @unlink('temp/mail_attachs/' . $_REQUEST["attach1file"]); } if ($_REQUEST["attach2"]) { check_ticket('webmail'); $a2 = $mail->getFile('temp/mail_attachs/' . $_REQUEST["attach2file"]); $mail->addAttachment($a2, $_REQUEST["attach2"], $_REQUEST["attach2type"]); @unlink('temp/mail_attachs/' . $_REQUEST["attach2file"]); } if ($_REQUEST["attach3"]) { check_ticket('webmail');
static function sendEmail($to, $subject, $html, $text = "", $from = false, $return = false, $cc = false, $bcc = false, $headers = array()) { $mailer = new htmlMimeMail(); $headers["X-Mailer"] = "BigTree CMS (http://www.bigtreecms.org) + HTML Mime mail class (http://www.phpguru.org)"; foreach ($headers as $key => $val) { $mailer->setHeader($key, $val); } $mailer->setSubject($subject); $mailer->setHtml($html, $text); if (!$from) { $from = "no-reply@" . (isset($_SERVER["HTTP_HOST"]) ? str_replace("www.", "", $_SERVER["HTTP_HOST"]) : str_replace(array("http://www.", "https://www.", "http://", "https://"), "", DOMAIN)); } $mailer->setFrom($from); if ($return) { $mailer->setReturnPath($return); } if ($cc) { $mailer->setCc(is_array($cc) ? $cc : array($cc)); } if ($bcc) { $mailer->setBcc(is_array($bcc) ? $bcc : array($bcc)); } return $mailer->send(is_array($to) ? $to : array($to)); }
function send_mail_new($to_name, $to_email, $from_name = "", $from_email = "", $subject = "", $message, $mail_type = "", $att_ids = "", $bcc_email = "", $cc_email = "", $reply = "", $f_type = "") { //require_once 'swift/lib/swift_required.php'; global $Site_Name; global $AdminName; global $AdminMail; global $AdminToName; global $AdminToEmail; global $USESENDGRID; if ($from_name == "") { $from_name = $AdminName; } if ($from_email == "") { $from_email = $AdminMail; } if ($to_name == "") { $to_name = $AdminToName; } if ($to_email == "") { $to_email = $AdminToEmail; } $message = str_replace("\\n", "\\r\\n", $message); $from = "{$from_name} <{$from_email}>"; $to = "{$to_name} <{$to_email}>"; if ($USESENDGRID == 0) { $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= "From: {$from}\n"; if ($reply) { $headers .= "Reply-To: {$reply} \n"; } if ($cc_email) { $headers .= "CC: {$cc_email} \n"; } $headers .= "BCC: " . $bcc_email; if ($att_ids != "" && $f_type != '') { $mail = new htmlMimeMail(); $mail->setSubject($subject); //$mail->setText($message); $mail->setHtml($message); $mail->setFrom($from); if ($cc_email) { $mail->setCc($cc_email); } if ($bcc_email) { $mail->setBcc($bcc_email); } if ($reply) { $mail->setHeader("Return-Path", $reply); $mail->setHeader("Reply-To", $reply); } $result = $mail->send(array($to)); //print $result; } else { @mail($to, $subject, $message, $headers); } } else { global $Sendgrid_Email, $Sendgrid_Pass; $transport = Swift_SmtpTransport::newInstance('smtp.sendgrid.net', 25)->setUsername($Sendgrid_Email)->setPassword($Sendgrid_Pass); //Create the Mailer using your created Transport $mailer = Swift_Mailer::newInstance($transport); $orig_msg = $message; //Create a message $message = Swift_Message::newInstance($subject)->setFrom(array($from_email => $from_name))->setTo(array($to_email => $to_name)); $message->setSender($from_email); $message->setBody($orig_msg, 'text/html'); if ($reply) { $message->setReplyTo($reply); } if ($cc_email) { $message->setCc($cc_email); } if ($bcc_email) { $message->addBcc($bcc_email); } //Send the message $result = $mailer->send($message); } }
error_reporting(E_ALL); include 'htmlMimeMail.php'; /** * Example of usage. This example shows * how to use the class to send Bcc: * and/or Cc: recipients. * * Create the mail object. */ $mail = new htmlMimeMail(); /** * We will just send a text email */ $text = $mail->getFile('example.txt'); $mail->setText($text); /** * Send the email using smtp method. The setSMTPParams() * method simply changes the HELO string to example.com * as localhost and port 25 are the defaults. */ $mail->setSMTPParams('localhost', 25, 'example.com'); $mail->setReturnPath('*****@*****.**'); $mail->setBcc('*****@*****.**'); $mail->setCc('Carbon Copy <*****@*****.**>'); $result = $mail->send(array('postmaster@localhost'), 'smtp'); // These errors are only set if you're using SMTP to send the message if (!$result) { print_r($mail->errors); } else { echo 'Mail sent!'; }
/** * Enter description here... * * @param htmlMimeMail $mail * @param unknown_type $fromAdress * @param unknown_type $fromName * @return unknown */ public function prepareEmail(htmlMimeMail $mail, $fromAdress, $fromName) { // Adds attachments foreach ($this->attachments as $attach) { $mail->addAttachment($attach['body'], $attach['name'], $attach['c_type'], $attach['encoding']); } // Subject, To, Cc $mail->setSubject($this->subject); $to = (array) $this->to; if (!empty($this->cc)) { $mail->setCc($this->cc); } // Bcc $bcc = $this->cci; $alwaysBcc = CopixConfig::get('|mailAlwaysBcc'); if (!empty($alwaysBcc)) { $bcc = empty($bcc) ? $alwaysBcc : "{$alwaysBcc}; {$bcc}"; } if (!empty($bcc)) { $mail->setBcc($bcc); } // Adresse de retour $fromAdress = $fromAdress == null ? $this->from : $fromAdress; $fromName = $fromName == null ? $this->fromName : $fromName; $mail->setFrom('"' . $fromName . '" <' . $fromAdress . '>'); return $to; }