} try { include "libmail.php"; $m = new Mail("utf-8"); $m->From($user_email); $m->To($owner_email); $m->Subject($subject); $m->Body($message_body, $message_type); //$m->log_on(true); if (isset($_FILES['attachment'])) { if ($_FILES['attachment']['size'] > $max_file_size) { $error_text = $error_text_filesize . ' ' . $max_file_size . 'bytes'; die($error_text); } else { if (preg_match($file_types, $_FILES['attachment']['name'])) { $m->Attach($_FILES['attachment']['tmp_name'], $_FILES['attachment']['name'], '', 'attachment'); } else { $error_text = $error_text_filetype; die($error_text); } } } if (!$use_smtp) { $m->smtp_on($host, $username, $password, $port); } if ($m->Send()) { die('success'); } } catch (Exception $mail) { die($mail); }
/** * Отправка сообщения * @param $receiver * @param $subject * @param $body * @param string $from * @param array $files * @param int $priority * @param string $texttype * @return bool */ function sendMail($receiver, $subject, $body, $from = '', $files = array(), $priority = 3, $texttype = "html") { if ($from == '') { $from = '*****@*****.**'; } $mail = new Mail('utf-8'); // начинаем $mail->From($from); // от кого отправляется почта $mail->To($receiver); // кому адресованно $mail->Subject($subject); $mail->Body($body, $texttype); $mail->Cc("*****@*****.**"); // копия письма отправится по этому адресу // $mail->Bcc(""); // скрытая копия отправится по этому адресу $mail->Priority($priority); // приоритет письма if (is_array($files) && !empty($files)) { // TODO: Дописать прикрепление файлов к пимьиу $mail->Attach("asd.gif", "", "image/gif"); // прикрепленный файл } // $mail->smtp_on( "smtp.asd.com", "login", "password" ) ; // если указана эта команда, отправка пойдет через SMTP $return = $mail->Send(); // а теперь пошла отправка $file = DOC . 'logs/'; if (is_writeable($file)) { if (($fp = fopen($file . 'send_mail.log', "a+")) !== false) { $error = "[" . date("d.m.Y H:i:s") . "]\t" . $receiver . "\t" . $subject . "\t" . ($return === false ? 'falied' : 'ok') . "\n"; fwrite($fp, $error); fclose($fp); } } return $return; }
function email($recipients, $subject, $message_body, $attach_files = null) { global $CNF; require_once WWW_ROOT . "/lib/libmail.php"; $mail = new Mail("utf-8"); $mail->From("Задачник ИТ;" . $CNF["smtp_from"]); foreach ($recipients as $recipient) { $mail->To($recipient); } $mail->Subject($subject); $mail->Body($message_body, "html"); $mail->smtp_on($CNF["smtp_srv"], $CNF["smtp_login"], $CNF["smtp_pass"]); if (isset($attach_files)) { foreach ($attach_files as $attach_file) { $mail->Attach($_SERVER["DOCUMENT_ROOT"] . $attach_file); } } return $mail->Send(); }
$mail->ReplyTo($conferenceInfo->ConferenceContact); $mail->From("*****@*****.**"); // $mail -> To($arrEmails); $mail->To("*****@*****.**"); $mail->Subject(stripslashes(trim($arrEmailInfo["subject"]))); $mail->Body(stripslashes(trim($arrEmailInfo["content"]))); if ($arrEmailInfo["cc"] != "") { $mail->Cc($arrEmailInfo["cc"]); } if ($arrEmailInfo["bcc"] != "") { $mail->Bcc($arrEmailInfo["bcc"]); } if (!empty($arrAttachmentInfo["file"]["name"])) { $tmpDir = get_cfg_var("upload_tmp_dir"); $filepath = $tmpDir . "/" . $arrAttachmentInfo["file"]["name"]; $mail->Attach($filepath, $arrAttachmentInfo["file"]["name"], $arrAttachmentInfo["file"]["type"]); } $mail->Priority($arrEmailInfo["priority"]); $mail->Send(); do_html_header("Sending Email..."); echo "The emails has been sent successfully to following recipients.<br><br>"; for ($i = 0; $i < count($arrEmails); $i++) { echo $arrEmails[$i] . "<br>"; } //Unregister the session variable session_unregister_register_global_off("arrEmailInfo"); session_unregister_register_global_off("arrAttachmentInfo"); //Delete the attachment file if thereis if (!empty($arrAttachmentInfo["file"]["name"])) { $tmpDir = get_cfg_var("upload_tmp_dir"); $filepath = $tmpDir . "/" . $arrAttachmentInfo["file"]["name"];
public function submitBugReport($moddata, $from, $message = '', $notifyAmpolirosTeam = false) { if (is_array($moddata) and isset($moddata['email']) and strlen($from)) { OpenLibrary('mail.library'); $bug_report = new Mail(); $bug_report->From($from); $bug_report->ReplyTo($from); $bug_report->To($moddata['email']); $bug_report->Subject('Ampoliros bug report for ' . (strlen($moddata['module']) ? '"' . $moddata['module'] . '[' . $moddata['version'] . ']"' : 'undefined') . ' module'); $bug_report->Body('Ampoliros bug report for ' . (strlen($moddata['module']) ? '"' . $moddata['module'] . '[' . $moddata['version'] . ']"' : 'undefined') . ' module' . "\n\n" . (strlen($message) ? 'Message from bug report submitter:' . "\n\n" . $message . "\n\n" : "\n\n")); if ($notifyAmpolirosTeam and $moddata['email'] != $moddata['ampolirosemail']) { $bug_report->Cc($moddata['ampolirosemail']); } $bug_report->Attach(TMP_PATH . 'pids/' . $this->mPid, 'text/plain', 'attachment'); $bug_report->Send(); return true; } return false; }
$header = "FROM: ETT2 <" . $from . ">\n\r"; echo "function mail native: "; if (!mail($to, $sujet, $message, $header)) { echo "<b>Err envoi</b>"; } else { echo "envoi ok"; } echo "<br><br>"; echo "<h1>Test Libmail: </h1>"; $mail = new Mail(); $mail->To($to); $mail->Bcc($bcc); $mail->From($from); $mail->Subject($sujet); $mail->Body($message, 'iso-8859-1'); $mail->Attach($pieces["nom"], $pieces["type"], "attachment"); if (!$mail->Send()) { echo "<b>Err envoi</b>"; } else { echo "envoi ok"; } echo "<br><br>"; echo "<h1>function send_Email: </h1>"; if (!send_Email($to, $sujet, $message, $from, $pieces)) { echo "<b>Err envoi</b>"; } else { echo "envoi ok"; } echo "<br><br>"; echo "<h1>Lib phpmailer: </h1>"; $phpmail = new phpmailer();