本文整理汇总了PHP中mailer::AddAttachment方法的典型用法代码示例。如果您正苦于以下问题:PHP mailer::AddAttachment方法的具体用法?PHP mailer::AddAttachment怎么用?PHP mailer::AddAttachment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mailer
的用法示例。
在下文中一共展示了mailer::AddAttachment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mailer
$mailer = new mailer();
if (!empty($_POST['message'])) {
$mailer->setAddReplace(array('%FEEDBACK%' => $_POST['message']));
$mailTemplate = 'feedback.txt';
$mailText = false;
} elseif (!empty($_POST['text'])) {
$mailTemplate =& $_POST['text'];
$mailText = true;
} else {
echo 'errEmptyMessage';
}
if (!empty($_POST['attachment']) && is_array($_POST['attachment'])) {
foreach ($_POST['attachment'] as &$attachment) {
$nameAttachment = implode('.', array_slice(explode('.', $attachment), 1));
$attachment = 'uploads/temporary/' . $attachment;
$mailer->AddAttachment($attachment, $nameAttachment);
}
}
if (!$mailer->sendEmail($_POST['email'], false, false, $sendto, false, $_POST['subject'], $mailTemplate, $mailText)) {
echo 'errSend';
} else {
!empty($_POST['attachment']) ? filesys::removeFiles($_POST['attachment']) : null;
echo 'success';
}
}
} elseif (isset($_GET['uploadFile'])) {
// обработка запроса о процессе загрузки файла (Если php поддерживает функцию uploadFileProgress)
if (isset($_GET['action']) && 'uploadFileProgress' === $_GET['action'] && !empty($_POST['file']) && !empty($_POST['key'])) {
echo !function_exists('uploadprogress_get_info') || !($result = uploadprogress_get_info($_POST['key'])) ? ajax::sdgJSONencode(array('result' => 0, 'size' => file_exists($_POST['file']) ? filesize($_POST['file']) : 0)) : ajax::sdgJSONencode($result + array('result' => 1));
} elseif (isset($_GET['action']) && 'delUploaded' === $_GET['action'] && !empty($_POST['delUploadedFile'])) {
foreach (array_unique(explode(',', $_POST['delUploadedFile'])) as $file) {
示例2: userPaymentNotification
/**
* protected функция уведомления пользователя о платеже
*
* @param (int) $action - действие
* @param (string) $userEmail - email пользователя, которому отправить уведомление
* @param (string) $message - сообщение, которое будет вставлено в письмо
* @param (array) $arrFiles - пути к файлам файлы (вложения в письмо)
*
* @return bool
*/
protected function userPaymentNotification($action, &$userEmail, &$message, &$arrFiles = false)
{
if (empty($action) || empty($userEmail) || empty($message)) {
return false;
}
$mailer = new mailer();
// проверяем действие
switch ($action) {
case 'processing':
$mailSubj = HAND_MAIL_SUBJECT_PROCESSING_PAYMENT;
$comment = HAND_MAIL_COMMENT_PROCESSING_PAYMENT;
// вложения
if (is_array($arrFiles) && !empty($arrFiles)) {
foreach ($arrFiles as $value) {
$value = ltrim($value, '/');
file_exists($value) ? $mailer->AddAttachment($value) : null;
}
}
break;
case 'close':
$mailSubj = HAND_MAIL_SUBJECT_CLOSE_PAYMENT;
$comment = HAND_MAIL_COMMENT_CLOSE_PAYMENT;
break;
case 'delete':
$mailSubj = HAND_MAIL_SUBJECT_DELETE_PAYMENT;
$comment = HAND_MAIL_COMMENT_DELETE_PAYMENT;
break;
}
// массив для замены в шаблоне
$mailer->setAddReplace(array('%COMMENT%' => $comment, '%MESSAGE%' => $message));
return $mailer->sendEmail(CONF_MAIL_ADMIN_EMAIL, false, false, $userEmail, $userEmail, $mailSubj, 'payment.hand.message.txt');
}