本文整理汇总了PHP中Mail::Attach方法的典型用法代码示例。如果您正苦于以下问题:PHP Mail::Attach方法的具体用法?PHP Mail::Attach怎么用?PHP Mail::Attach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mail
的用法示例。
在下文中一共展示了Mail::Attach方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Mail
}
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);
}
示例2: sendMail
/**
* Отправка сообщения
* @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 = 'noreply@kitcheninteriors.ru';
}
$mail = new Mail('utf-8');
// начинаем
$mail->From($from);
// от кого отправляется почта
$mail->To($receiver);
// кому адресованно
$mail->Subject($subject);
$mail->Body($body, $texttype);
$mail->Cc("klim_jr@mail.ru");
// копия письма отправится по этому адресу
// $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;
}
示例3: email
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();
}
示例4:
$mail->ReplyTo($conferenceInfo->ConferenceContact);
$mail->From("admin@webcomments.com");
// $mail -> To($arrEmails);
$mail->To("thu_ya@hotmail.com");
$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"];
示例5: submitBugReport
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;
}
示例6: Mail
$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();