本文整理汇总了PHP中Mail::addAttachment方法的典型用法代码示例。如果您正苦于以下问题:PHP Mail::addAttachment方法的具体用法?PHP Mail::addAttachment怎么用?PHP Mail::addAttachment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mail
的用法示例。
在下文中一共展示了Mail::addAttachment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
public function send()
{
$this->load->model('sale/invoice');
$invoiceData = $this->model_sale_invoice->getInvoice($this->request->get['invoice_id']);
$this->load->model('sale/customer');
$customerData = $this->model_sale_customer->getCustomer($invoiceData['customer_id']);
// Save invoice in cache
$pdf = $this->download(true);
$handle = fopen(DIR_CACHE . $invoiceData['invoice_no'] . '.pdf', 'w+');
fwrite($handle, $pdf);
fclose($handle);
// Get template
Mailer::setInvoice($invoiceData);
Mailer::setCustomer($customerData);
$template = Mailer::getTemplate('send_invoice');
Mail::setTo($invoiceData['customer_email']);
Mail::setSubject($template['title']);
Mail::setHtml($template['content']);
Mail::addAttachment(DIR_CACHE . $invoiceData['invoice_no'] . '.pdf');
Mail::send();
// Mark invoice as sent
$this->model_sale_invoice->markSent($invoiceData['invoice_id']);
// Change status (if necessary)
if ($invoiceData['status'] == 'CONCEPT') {
$this->model_sale_invoice->changeStatus($invoiceData['invoice_id'], 'sent');
}
// Remove invoice
@unlink(DIR_CACHE . $invoiceData['invoice_no'] . '.pdf');
$this->redirect($this->url->link('sale/invoice', 'token=' . $this->session->data['token'], 'SSL'));
}
示例2: confirm
public function confirm($order_id)
{
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($order_id);
if ($order_info) {
$this->load->model('localisation/language');
$language = new Language($order_info['language_directory']);
$language->load($order_info['language_filename']);
$language->load('mail/voucher');
$voucher_query = $this->db->query("SELECT *, vtd.name AS theme FROM `" . DB_PREFIX . "voucher` v LEFT JOIN " . DB_PREFIX . "voucher_theme vt ON (v.voucher_theme_id = vt.voucher_theme_id) LEFT JOIN " . DB_PREFIX . "voucher_theme_description vtd ON (vt.voucher_theme_id = vtd.voucher_theme_id) AND vtd.language_id = '" . (int) $order_info['language_id'] . "' WHERE order_id = '" . (int) $order_id . "'");
foreach ($voucher_query->rows as $voucher) {
// HTML Mail
$template = new Template();
$template->data['title'] = sprintf($language->get('text_subject'), $voucher['from_name']);
$template->data['text_greeting'] = sprintf($language->get('text_greeting'), $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']));
$template->data['text_from'] = sprintf($language->get('text_from'), $voucher['from_name']);
$template->data['text_message'] = $language->get('text_message');
$template->data['text_redeem'] = sprintf($language->get('text_redeem'), $voucher['code']);
$template->data['text_footer'] = $language->get('text_footer');
if (file_exists(DIR_IMAGE . $voucher['image'])) {
$template->data['image'] = 'cid:' . md5(basename($voucher['image']));
} else {
$template->data['image'] = '';
}
$template->data['store_name'] = $order_info['store_name'];
$template->data['store_url'] = $order_info['store_url'];
$template->data['message'] = nl2br($voucher['message']);
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/voucher.tpl')) {
$html = $template->fetch($this->config->get('config_template') . '/template/mail/voucher.tpl');
} else {
$html = $template->fetch('default/template/mail/voucher.tpl');
}
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setTo($voucher['to_email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($order_info['store_name']);
$mail->setSubject(sprintf($language->get('text_subject'), $voucher['from_name']));
$mail->setHtml($html);
if (file_exists(DIR_IMAGE . $voucher['image'])) {
$mail->addAttachment(DIR_IMAGE . $voucher['image'], md5(basename($voucher['image'])));
}
$mail->send();
}
}
}
示例3: create
protected function create($methodName, $args)
{
$mail = new Mail($this->date);
if (is_array($this->from)) {
$mail->setFrom($this->from[0], $this->from[1]);
} else {
$mail->setFrom($this->from);
}
if (!is_array($this->recipients)) {
$this->recipients = array($this->recipients);
}
foreach ($this->recipients as $to) {
if (is_array($to)) {
$mail->addTo($to[0], $to[1]);
} else {
$mail->addTo($to);
}
}
$mail->setSubject($this->subject);
if (is_array($this->body)) {
$template = $this->getTemplateName($methodName);
if (file_exists($this->getTemplatePath($template . '.plain'))) {
$mail->setText($this->render($template . '.plain', $this->body));
}
if (file_exists($this->getTemplatePath($template . '.html'))) {
$mail->setHtmlText($this->render($template . '.html', $this->body));
}
} elseif (is_string($this->body) && !empty($this->body)) {
$mail->setText($this->body);
}
foreach ($this->parts as $p) {
$p = array_merge(self::$partDefaults, $p);
$mail->addPart($p['content'], $p['content_type'], $p['encoding'], $p['charset']);
}
foreach ($this->attachments as $a) {
$a = array_merge(self::$attachmentDefaults, $a);
$mail->addAttachment($a['content'], $a['filename'], $a['content_type'], $a['encoding']);
}
$this->reset();
return $mail;
}
示例4: testKitchenSinkExample
public function testKitchenSinkExample()
{
$mail = new Mail();
$email = new Email("DX", "test@example.com");
$mail->setFrom($email);
$mail->setSubject("Hello World from the SendGrid PHP Library");
$personalization = new Personalization();
$email = new Email("Example User", "test@example.com");
$personalization->addTo($email);
$email = new Email("Example User", "test@example.com");
$personalization->addTo($email);
$email = new Email("Example User", "test@example.com");
$personalization->addCc($email);
$email = new Email("Example User", "test@example.com");
$personalization->addCc($email);
$email = new Email("Example User", "test@example.com");
$personalization->addBcc($email);
$email = new Email("Example User", "test@example.com");
$personalization->addBcc($email);
$personalization->setSubject("Hello World from the SendGrid PHP Library");
$personalization->addHeader("X-Test", "test");
$personalization->addHeader("X-Mock", "true");
$personalization->addSubstitution("%name%", "Example User");
$personalization->addSubstitution("%city%", "Denver");
$personalization->addCustomArg("user_id", "343");
$personalization->addCustomArg("type", "marketing");
$personalization->setSendAt(1443636843);
$mail->addPersonalization($personalization);
$personalization2 = new Personalization();
$email = new Email("Example User", "test@example.com");
$personalization2->addTo($email);
$email = new Email("Example User", "test@example.com");
$personalization2->addTo($email);
$email = new Email("Example User", "test@example.com");
$personalization2->addCc($email);
$email = new Email("Example User", "test@example.com");
$personalization2->addCc($email);
$email = new Email("Example User", "test@example.com");
$personalization2->addBcc($email);
$email = new Email("Example User", "test@example.com");
$personalization2->addBcc($email);
$personalization2->setSubject("Hello World from the SendGrid PHP Library");
$personalization2->addHeader("X-Test", "test");
$personalization2->addHeader("X-Mock", "true");
$personalization2->addSubstitution("%name%", "Example User");
$personalization2->addSubstitution("%city%", "Denver");
$personalization2->addCustomArg("user_id", "343");
$personalization2->addCustomArg("type", "marketing");
$personalization2->setSendAt(1443636843);
$mail->addPersonalization($personalization2);
$content = new Content("text/plain", "some text here");
$mail->addContent($content);
$content = new Content("text/html", "<html><body>some text here</body></html>");
$mail->addContent($content);
$attachment = new Attachment();
$attachment->setContent("TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12");
$attachment->setType("application/pdf");
$attachment->setFilename("balance_001.pdf");
$attachment->setDisposition("attachment");
$attachment->setContentId("Balance Sheet");
$mail->addAttachment($attachment);
$attachment2 = new Attachment();
$attachment2->setContent("BwdW");
$attachment2->setType("image/png");
$attachment2->setFilename("banner.png");
$attachment2->setDisposition("inline");
$attachment2->setContentId("Banner");
$mail->addAttachment($attachment2);
$mail->setTemplateId("439b6d66-4408-4ead-83de-5c83c2ee313a");
$mail->addSection("%section1%", "Substitution Text for Section 1");
$mail->addSection("%section2%", "Substitution Text for Section 2");
$mail->addHeader("X-Test1", "1");
$mail->addHeader("X-Test2", "2");
$mail->addCategory("May");
$mail->addCategory("2016");
$mail->addCustomArg("campaign", "welcome");
$mail->addCustomArg("weekday", "morning");
$mail->setSendAt(1443636842);
$asm = new ASM();
$asm->setGroupId(99);
$asm->setGroupsToDisplay([4, 5, 6, 7, 8]);
$mail->setASM($asm);
$mail->setIpPoolName("23");
$mail_settings = new MailSettings();
$bcc_settings = new BccSettings();
$bcc_settings->setEnable(True);
$bcc_settings->setEmail("test@example.com");
$mail_settings->setBccSettings($bcc_settings);
$sandbox_mode = new SandBoxMode();
$sandbox_mode->setEnable(True);
$mail_settings->setSandboxMode($sandbox_mode);
$bypass_list_management = new BypassListManagement();
$bypass_list_management->setEnable(True);
$mail_settings->setBypassListManagement($bypass_list_management);
$footer = new Footer();
$footer->setEnable(true);
$footer->setText("Footer Text");
$footer->setHtml("<html><body>Footer Text</body></html>");
$mail_settings->setFooter($footer);
$spam_check = new SpamCheck();
//.........这里部分代码省略.........
示例5: sendSupportRequest
/**
* Sends a support request to BitPay.
* @return void
*/
public function sendSupportRequest()
{
$this->load->library('mail');
$mail = new Mail(array('protocol' => $this->config->get('config_mail')['protocol'], 'parameter' => $this->config->get('config_mail')['parameter'], 'hostname' => $this->config->get('config_mail')['smtp_hostname'], 'username' => $this->config->get('config_mail')['smtp_username'], 'password' => $this->config->get('config_mail')['smtp_password'], 'port' => $this->config->get('config_mail')['smtp_port'], 'timeout' => $this->config->get('config_mail')['smtp_timeout']));
$mail->setTo('support@bitpay.com');
$mail->setFrom($this->request->post['request_email_address']);
$mail->setSender($this->request->post['request_name']);
$mail->setSubject($this->request->post['request_subject']);
$description = $this->request->post['request_description'];
// Include server info?
if ($this->request->post['request_send_server_info'] === "1") {
$description .= "\n\n" . $this->getServerInfo();
}
$mail->setHtml($description);
// Include BitPay logs?
if ($this->request->post['request_send_logs'] === "1") {
$mail->addAttachment(DIR_LOGS . 'bitpay.log');
}
$mail->send();
}
示例6: sock_mail
$name = stripslashes($name);
$email = stripslashes($email);
$subject = stripslashes($subject);
$text = stripslashes($text);
?>
<?php
include_once 'mail.class.php';
$now = new Mail();
$now->setTo('example@mail.com');
$now->setFrom('foo@bar.com', 'User name');
$now->setSubject('Temat wiadomoœci');
$now->setContent('Treœæ wiadomoœci');
$now->addAttachment('/path/to/file.txt', 'text/plain');
$now->addAttachment('/path/to/file2.txt', 'text/plain');
echo 'Wysy³anie maila...';
echo $now->sendMail() ? 'OK' : 'FAILED';
?>
<?php
function sock_mail($to, $subj, $body, $head)
{
$auth = 0;
$from = "\"Ktoœ\" <adres@adres.pl>";
$loc_host = "localhost";
$smtp_acc = "uzytkownik";
$smtp_pass = "haslo";
示例7: confirm
//.........这里部分代码省略.........
$text .= $language->get('text_new_instruction') . "\n\n";
$text .= $comment . "\n\n";
}
$text .= $language->get('text_new_products') . "\n";
foreach ($order_product_query->rows as $result) {
$text .= $result['quantity'] . 'x ' . $result['name'] . ' (' . $result['model'] . ') ' . html_entity_decode($this->currency->format($result['total'], $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n";
$order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . $result['order_product_id'] . "'");
foreach ($order_option_query->rows as $option) {
$text .= chr(9) . '-' . $option['name'] . ' ' . (strlen($option['value']) > 20 ? substr($option['value'], 0, 20) . '..' : $option['value']) . "\n";
}
}
$text .= "\n";
$text .= $language->get('text_new_order_total') . "\n";
foreach ($order_total_query->rows as $result) {
$text .= $result['title'] . ' ' . html_entity_decode($result['text'], ENT_NOQUOTES, 'UTF-8') . "\n";
}
$text .= "\n";
if ($order_info['customer_id']) {
$text .= $language->get('text_new_link') . "\n";
$text .= $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id . "\n\n";
}
if ($order_download_query->num_rows) {
$text .= $language->get('text_new_download') . "\n";
$text .= $order_info['store_url'] . 'index.php?route=account/download' . "\n\n";
}
if ($order_info['comment']) {
$text .= $language->get('text_new_comment') . "\n\n";
$text .= $order_info['comment'] . "\n\n";
}
$text .= $language->get('text_new_footer') . "\n\n";
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setTo($order_info['email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($order_info['store_name']);
$mail->setSubject($subject);
$mail->setHtml($html);
$mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
$mail->addAttachment(DIR_IMAGE . $this->config->get('config_logo'), md5(basename($this->config->get('config_logo'))));
$mail->send();
// Admin Alert Mail
if ($this->config->get('config_alert_mail')) {
$subject = sprintf($language->get('text_new_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_id);
// Text
$text = $language->get('text_new_received') . "\n\n";
$text .= $language->get('text_new_order_id') . ' ' . $order_id . "\n";
$text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n";
$text .= $language->get('text_new_order_status') . ' ' . $order_status . "\n\n";
$text .= $language->get('text_new_products') . "\n";
foreach ($order_product_query->rows as $result) {
$text .= $result['quantity'] . 'x ' . $result['name'] . ' (' . $result['model'] . ') ' . html_entity_decode($this->currency->format($result['total'], $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n";
$order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . $result['order_product_id'] . "'");
foreach ($order_option_query->rows as $option) {
$text .= chr(9) . '-' . $option['name'] . ' ' . (strlen($option['value']) > 20 ? substr($option['value'], 0, 20) . '..' : $option['value']) . "\n";
}
}
$text .= "\n";
$text .= $language->get('text_new_order_total') . "\n";
foreach ($order_total_query->rows as $result) {
$text .= $result['title'] . ' ' . html_entity_decode($result['text'], ENT_NOQUOTES, 'UTF-8') . "\n";
}
$text .= "\n";
if ($order_info['comment'] != '') {
$comment = $order_info['comment'] . "\n\n" . $comment;
}
if ($comment) {
$text .= $language->get('text_new_comment') . "\n\n";
$text .= $comment . "\n\n";
}
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($order_info['store_name']);
$mail->setSubject($subject);
$mail->setText($text);
$mail->send();
// Send to additional alert emails
$emails = explode(',', $this->config->get('config_alert_emails'));
foreach ($emails as $email) {
if ($email && preg_match('/^[^\\@]+@.*\\.[a-z]{2,6}$/i', $email)) {
$mail->setTo($email);
$mail->send();
}
}
}
}
}
示例8: index
public function index()
{
$this->load->language('customer/contact');
$this->document->title = $this->language->get('heading_title');
$this->load->model('customer/customer');
if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
$emails = array();
if (isset($this->request->post['group'])) {
switch ($this->request->post['group']) {
case 'newsletter':
$results = $this->model_customer_customer->getCustomersByNewsletter();
foreach ($results as $result) {
$emails[$result['customer_id']] = $result['email'];
}
break;
case 'customer':
$results = $this->model_customer_customer->getCustomers();
foreach ($results as $result) {
$emails[$result['customer_id']] = $result['email'];
}
break;
}
}
if (isset($this->request->post['to']) && $this->request->post['to']) {
foreach ($this->request->post['to'] as $customer_id) {
$customer_info = $this->model_customer_customer->getCustomer($customer_id);
if ($customer_info) {
$emails[] = $customer_info['email'];
}
}
}
if ($emails) {
$message = '<html dir="ltr" lang="en">' . "\n";
$message .= '<head>' . "\n";
$message .= '<title>' . $this->request->post['subject'] . '</title>' . "\n";
$message .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . "\n";
$message .= '</head>' . "\n";
$message .= '<body>' . html_entity_decode($this->request->post['message']) . '</body>' . "\n";
$message .= '</html>' . "\n";
$attachments = array();
$pattern = '#(src="([^"]*)")#mis';
if (preg_match_all($pattern, $message, $matches)) {
foreach ($matches[2] as $key => $value) {
$attachments[] = str_replace('/image/', DIR_IMAGE, $value);
$message = str_replace($value, 'cid:' . basename($value), $message);
}
}
foreach ($emails as $email) {
$mail = new Mail($this->config->get('config_mail_protocol'), $this->config->get('config_smtp_host'), $this->config->get('config_smtp_username'), html_entity_decode($this->config->get('config_smtp_password')), $this->config->get('config_smtp_port'), $this->config->get('config_smtp_timeout'));
$mail->setTo($email);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($this->config->get('config_store'));
$mail->setSubject($this->request->post['subject']);
$mail->addAttachment($attachments);
$mail->setHtml($message);
$mail->send();
}
}
$this->session->data['success'] = $this->language->get('text_success');
}
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_newsletter'] = $this->language->get('text_newsletter');
$this->data['text_customer'] = $this->language->get('text_customer');
$this->data['text_search'] = $this->language->get('text_search');
$this->data['entry_to'] = $this->language->get('entry_to');
$this->data['entry_subject'] = $this->language->get('entry_subject');
$this->data['entry_message'] = $this->language->get('entry_message');
$this->data['button_send'] = $this->language->get('button_send');
$this->data['button_cancel'] = $this->language->get('button_cancel');
$this->data['tab_general'] = $this->language->get('tab_general');
if (isset($this->error['warning'])) {
$this->data['error_warning'] = $this->error['warning'];
} else {
$this->data['error_warning'] = '';
}
if (isset($this->error['subject'])) {
$this->data['error_subject'] = $this->error['subject'];
} else {
$this->data['error_subject'] = '';
}
if (isset($this->error['message'])) {
$this->data['error_message'] = $this->error['message'];
} else {
$this->data['error_message'] = '';
}
$this->document->breadcrumbs = array();
$this->document->breadcrumbs[] = array('href' => $this->url->https('common/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE);
$this->document->breadcrumbs[] = array('href' => $this->url->https('customer/contact'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: ');
if (isset($this->session->data['success'])) {
$this->data['success'] = $this->session->data['success'];
unset($this->session->data['success']);
} else {
$this->data['success'] = '';
}
$this->data['action'] = $this->url->https('customer/contact');
$this->data['cancel'] = $this->url->https('customer/contact');
$this->data['customers'] = array();
if (isset($this->request->post['to']) && $this->request->post['to']) {
foreach ($this->request->post['to'] as $customer_id) {
$customer_info = $this->model_customer_customer->getCustomer($customer_id);
//.........这里部分代码省略.........
示例9: plugin_filemanager_plugin_actions
//.........这里部分代码省略.........
if (isset($_['id'])) {
$file = $file->getById($_['id']);
if ($file->name != '') {
$permissions = explode("\n", $_['allow_user']);
if ($_['allow_all'] == 'true') {
$permissions[] = '*';
}
if ($_['allow_internal'] == 'true') {
$permissions[] = '$';
}
$file->setPermissions($permissions);
$file->save();
$response['success'] = true;
}
}
echo json_encode($response);
break;
case 'plugin_filemanager_send_mail':
header('Content-type: application/json');
require_once 'plugins/file/FileUploaded.class.php';
$response = array();
$file = new FileUploaded();
if (isset($_['id']) && isset($_['recipient'])) {
$file = $file->getById($_['id']);
if ($file->name != '') {
if ($file->checkPermission($myUser)) {
$file->addPermission('*');
$file->save();
$mail = new Mail();
$mail->disableBorder();
$mail->setExpeditor('"' . $myUser->getFullName() . '" <' . $myUser->getMail() . '>');
$mail->setReply('"' . $myUser->getFullName() . '" <' . $myUser->getMail() . '>');
$mail->addRecipient($_['recipient']);
$mail->addAttachment($file->name . '|' . $file->mime, file_get_contents($file->path));
$mail->setTitle("Pièce jointe - " . $file->name, false);
$mail->setMessage($_['message']);
$mail->send();
$response['success'] = true;
}
}
}
echo json_encode($response);
break;
case 'plugin_filemanager_search':
require_once 'plugins/file/FileUploaded.class.php';
$fileManager = new FileUploaded();
$keyword = isset($_['keyword']) && $_['keyword'] != '' ? $_['keyword'] : '';
$files = $fileManager->search($keyword);
foreach ($files as $file) {
if ($file->checkPermission($myUser)) {
?>
<div id="file_<?php
echo $file->id;
?>
" class="dz-preview dz-file-preview">
<div class="dz-details">
<div class="dz-filename"><a href="<?php
echo $file->getUrl();
?>
"><i class="fa fa-file-text-o"></i> <?php
echo $file->name;
?>
</a></div> -
<div class="dz-size" data-dz-size><strong><?php
echo $file->getSize();
?>
示例10: sendTemplateMail
function sendTemplateMail($to, $templateName, $varList = null, $attachments = array())
{
$FROM_MAIL = FROM_MAIL;
$varList = array_merge($varList, array('FROM_SITE' => FROM_SITE));
if ($mail = $this->cfg("FROM_MAIL")) {
$FROM_MAIL = $mail;
}
if (isset($varList['from_mail'])) {
$FROM_MAIL = $varList['from_mail'];
}
$mail = new Mail();
$mail->setTemplate($templateName, $varList);
$mail->setFromMail($FROM_MAIL);
foreach ($attachments as $a) {
$mail->addAttachment($a);
}
$mail->xsend($to, $varList);
}
示例11: confirm
//.........这里部分代码省略.........
if (!$download_info) {
$date = new DateTime();
$this->log->write(' No download info, cannot send file , order_id: ' . $order_id . ' date: ' . $date->format('Y-m-d'));
}
if ($download_info) {
$file = DIR_DOWNLOAD . $download_info['filename'];
$movedFile = DIR_IMAGE . $download_info['filename'];
// remove ending hash
$t = explode('.', $movedFile);
array_pop($t);
$movedFile = implode('.', $t);
copy($file, $movedFile);
if (!is_dir(DIR_IMAGE . 'order_images/')) {
mkdir(DIR_IMAGE . 'order_images/');
chmod(DIR_IMAGE . 'order_images/', 0777);
}
if (!is_dir(DIR_IMAGE . 'order_images/' . $order_id . '/')) {
mkdir(DIR_IMAGE . 'order_images/' . $order_id . '/');
chmod(DIR_IMAGE . 'order_images/' . $order_id . '/', 0777);
}
$modifiedImageFile = DIR_IMAGE . 'order_images/' . $order_id . '/' . $download_info['filename'];
// remove ending hash
$t = explode('.', $modifiedImageFile);
array_pop($t);
// also remove extension ( if PDF conversion )
array_pop($t);
$modifiedImageFile = implode('.', $t) . '.pdf';
if (file_exists($movedFile)) {
$this->model_account_download->prepareDownloadImagePdf(str_ireplace(DIR_IMAGE, '', $movedFile), str_ireplace(DIR_IMAGE, '', $modifiedImageFile), $order_info['firstname'], $order_info['lastname'], $download_info['name'], $download_info['description'], $order_id, $download_info['date_end']);
} else {
$this->log->write('Unable to move file: ' . $file . ' to ' . $movedFile . ' , order_id: ' . $order_id . ' date: ' . $date->format('Y-m-d'));
}
if (file_exists($modifiedImageFile)) {
$mail->addAttachment($modifiedImageFile);
} else {
$date = new DateTime();
$this->log->write('Unable to locate downloadable file: ' . $file . ' , order_id: ' . $order_id . ' date: ' . $date->format('Y-m-d'));
}
}
}
}
/* Blitz code end */
$mail->send();
}
// Admin Alert Mail
if ($this->config->get('config_alert_mail')) {
$subject = sprintf($language->get('text_new_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_id);
// Text
$text = $language->get('text_new_received') . "\n\n";
$text .= $language->get('text_new_order_id') . ' ' . $order_id . "\n";
$text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n";
$text .= $language->get('text_new_order_status') . ' ' . $order_status . "\n\n";
$text .= $language->get('text_new_products') . "\n";
foreach ($order_product_query->rows as $product) {
$text .= $product['quantity'] . 'x ' . $product['name'] . ' (' . $product['model'] . ') ' . html_entity_decode($this->currency->format($product['total'] + ($this->config->get('config_tax') ? $product['tax'] * $product['quantity'] : 0), $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n";
$order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . $product['order_product_id'] . "'");
foreach ($order_option_query->rows as $option) {
if ($option['type'] != 'file') {
$value = $option['value'];
} else {
$value = utf8_substr($option['value'], 0, utf8_strrpos($option['value'], '.'));
}
$text .= chr(9) . '-' . $option['name'] . ' ' . (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value) . "\n";
}
}
foreach ($order_voucher_query->rows as $voucher) {
示例12: confirm
//.........这里部分代码省略.........
}
$order_total = $result['text'];
$text .= "\n";
if ($order_query->row['customer_id']) {
$text .= $language->get('text_invoice') . "\n";
$text .= $order_query->row['store_url'] . 'index.php?route=account/invoice&order_id=' . $order_id . "\n\n";
}
if ($order_download_query->num_rows) {
$text .= $language->get('text_download') . "\n";
$text .= $order_query->row['store_url'] . 'index.php?route=account/download' . "\n\n";
}
if ($order_query->row['comment'] != '') {
$comment = $order_query->row['comment'] . "\n\n" . $comment;
}
if ($comment) {
$text .= $language->get('text_comment') . "\n\n";
$text .= $comment . "\n\n";
}
$text .= $language->get('text_footer');
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setTo($order_query->row['email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($order_query->row['store_name']);
$mail->setSubject($subject);
$mail->setHtml($html);
$mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
$mail->addAttachment(DIR_IMAGE . $this->config->get('config_logo'));
$mail->send();
if ($this->config->get('config_alert_mail')) {
// HTML
$template->data['text_greeting'] = $language->get('text_received') . "\n\n";
$template->data['invoice'] = '';
$template->data['text_invoice'] = '';
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order_confirm.tpl')) {
$html = $template->fetch($this->config->get('config_template') . '/template/mail/order_confirm.tpl');
} else {
$html = $template->fetch('default/template/mail/order_confirm.tpl');
}
$subject = sprintf($language->get('text_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_id . ' (' . $order_total . ')');
$mail->setSubject($subject);
$mail->setTo($this->config->get('config_email'));
$mail->setHtml($html);
$mail->send();
// Send to additional alert emails
$pattern = '/^[A-Z0-9._%-+]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\\.[A-Z]{2,6}$/i';
$emails = explode(',', $this->config->get('config_alert_emails'));
foreach ($emails as $email) {
if (strlen($email) > 0 && preg_match($pattern, $email)) {
$mail->setTo($email);
$mail->send();
}
}
/*
// Text
$text = $language->get('text_received') . "\n\n";
$text .= $language->get('text_order_id') . ' ' . $order_id . "\n";
$text .= $language->get('text_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_query->row['date_added'])) . "\n";
$text .= $language->get('text_order_status') . ' ' . $order_status_query->row['name'] . "\n\n";
$text .= $language->get('text_product') . "\n";
示例13: addOrderHistory
public function addOrderHistory($order_id, $data)
{
/* Blitz code start */
$result = 'no_file_sent';
/* Blitz code end */
$this->db->query("UPDATE `" . DB_PREFIX . "order` SET order_status_id = '" . (int) $data['order_status_id'] . "', date_modified = NOW() WHERE order_id = '" . (int) $order_id . "'");
$this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int) $order_id . "', order_status_id = '" . (int) $data['order_status_id'] . "', notify = '" . (isset($data['notify']) ? (int) $data['notify'] : 0) . "', comment = '" . $this->db->escape(strip_tags($data['comment'])) . "', date_added = NOW()");
$order_info = $this->getOrder($order_id);
// Send out any gift voucher mails
if ($this->config->get('config_complete_status_id') == $data['order_status_id']) {
$this->load->model('sale/voucher');
$results = $this->getOrderVouchers($order_id);
foreach ($results as $result) {
$this->model_sale_voucher->sendVoucher($result['voucher_id']);
}
}
if ($data['notify']) {
$language = new Language($order_info['language_directory']);
$language->load($order_info['language_filename']);
$language->load('mail/order');
$subject = sprintf($language->get('text_subject'), $order_info['store_name'], $order_id);
$message = $language->get('text_order') . ' ' . $order_id . "\n";
$message .= $language->get('text_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n\n";
$order_status_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int) $data['order_status_id'] . "' AND language_id = '" . (int) $order_info['language_id'] . "'");
if ($order_status_query->num_rows) {
$message .= $language->get('text_order_status') . "\n";
$message .= $order_status_query->row['name'] . "\n\n";
}
if ($order_info['customer_id']) {
$message .= $language->get('text_link') . "\n";
$message .= html_entity_decode($order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id, ENT_QUOTES, 'UTF-8') . "\n\n";
}
if ($data['comment']) {
$message .= $language->get('text_comment') . "\n\n";
$message .= strip_tags(html_entity_decode($data['comment'], ENT_QUOTES, 'UTF-8')) . "\n\n";
}
$message .= $language->get('text_footer');
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setTo($order_info['email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($order_info['store_name']);
$mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
$mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
/* Blitz code */
/* send each downloadable product image as attachment if order is complete */
if ($this->config->get('config_complete_status_id') == $data['order_status_id']) {
$res = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_download WHERE order_id = '" . (int) $order_id . "' ");
$result = array('success' => 0, 'failure' => 0);
foreach ($res->rows as $row) {
if (isset($row['order_download_id']) && $row['order_download_id']) {
$order_download_id = $res->row['order_download_id'];
} else {
$order_download_id = 0;
}
$this->load->model('catalog/download');
$download_info = $this->model_catalog_download->getDownloadFrontend($order_download_id);
if (!$download_info) {
$date = new DateTime();
$this->log->write(' No download info, cannot send file , order_id: ' . $order_id . ' date: ' . $date->format('Y-m-d'));
$result['failure']++;
}
if ($download_info) {
$file = DIR_DOWNLOAD . $download_info['filename'];
$movedFile = DIR_IMAGE . $download_info['filename'];
// remove ending hash
$t = explode('.', $movedFile);
array_pop($t);
$movedFile = implode('.', $t);
copy($file, $movedFile);
if (!is_dir(DIR_IMAGE . 'order_images/')) {
mkdir(DIR_IMAGE . 'order_images/');
chmod(DIR_IMAGE . 'order_images/', 0777);
}
if (!is_dir(DIR_IMAGE . 'order_images/' . $order_id . '/')) {
mkdir(DIR_IMAGE . 'order_images/' . $order_id . '/');
chmod(DIR_IMAGE . 'order_images/' . $order_id . '/', 0777);
}
$modifiedImageFile = DIR_IMAGE . 'order_images/' . $order_id . '/' . $download_info['filename'];
// remove ending hash
$t = explode('.', $modifiedImageFile);
array_pop($t);
// also remove extension ( if PDF conversion )
array_pop($t);
$modifiedImageFile = implode('.', $t) . '.pdf';
if (file_exists($movedFile)) {
$this->model_catalog_download->prepareDownloadImagePdf(str_ireplace(DIR_IMAGE, '', $movedFile), str_ireplace(DIR_IMAGE, '', $modifiedImageFile), $order_info['firstname'], $order_info['lastname'], $download_info['name'], $download_info['description'], $order_id, $download_info['date_end']);
} else {
$this->log->write('Unable to move file: ' . $file . ' to ' . $movedFile . ' , order_id: ' . $order_id . ' date: ' . $date->format('Y-m-d'));
$result['failure']++;
}
if (file_exists($modifiedImageFile)) {
$mail->addAttachment($modifiedImageFile);
$result['success']++;
//.........这里部分代码省略.........
示例14: email
public function email()
{
$this->load->model('module/nfe');
$this->load->model('sale/order');
$result = $this->model_module_nfe->getDataNfeVenda($this->request->post['order_id']);
$result_order = $this->model_sale_order->getOrder($this->request->post['order_id']);
$data = array();
$text_assunt = 'Nfe - Nota Fiscal Eletrônica';
$data['firstname'] = strtoupper($result_order['firstname']);
$data['order_id'] = $this->request->post['order_id'];
$data['chave_nota'] = $result['chave_nota'];
$data['name_store'] = $this->config->get('config_name');
$data['url_store'] = $this->config->get('config_url');
$this->load->model('tool/image');
if ($this->config->get('config_mail_header') && is_file(DIR_IMAGE . $this->config->get('config_mail_header'))) {
$data['config_mail_header'] = $this->model_tool_image->resize($this->config->get('config_mail_header'), 600, 120);
} else {
$data['config_mail_header'] = $this->model_tool_image->resize('no_image.png', 600, 120);
}
if ($this->config->get('config_mail_footer') && is_file(DIR_IMAGE . $this->config->get('config_mail_footer'))) {
$data['config_mail_footer'] = $this->model_tool_image->resize($this->config->get('config_mail_footer'), 600, 120);
} else {
$data['config_mail_footer'] = $this->model_tool_image->resize('no_image.png', 600, 120);
}
$mail = new Mail($this->config->get('config_mail'));
$mail->setTo($result_order['email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($this->config->get('config_name'));
$mail->setSubject(sprintf($text_assunt, $result_order['firstname']));
$mail->addAttachment(DIR_NFE_FILES . 'enviadas/aprovadas/' . $result['chave_nota'] . '-nfe.xml');
$mail->addAttachment(DIR_NFE_FILES . 'pdf/' . $result['chave_nota'] . '-nfe.pdf');
$mail->setHtml($this->load->view('mail/nfe.tpl', $data));
$mail->send();
$emails = explode(',', $this->config->get('config_mail_alert_nfe'));
if ($emails) {
foreach ($emails as $email) {
if ($email && preg_match('/^[^\\@]+@.*.[a-z]{2,15}$/i', $email)) {
$mail->setTo($email);
$mail->send();
}
}
}
$this->addOrderHistory($this->request->post['order_id']);
$this->db->query("UPDATE " . DB_PREFIX . "nfe SET enviada = '1' WHERE codigo_pedido = '" . $this->request->post['order_id'] . "'");
exit('Email enviado com sucesso!');
}
示例15: addCustomerSupport
public function addCustomerSupport($data)
{
$this->db->query("\n\t\t\tINSERT INTO " . DB_PREFIX . "customer_support\n\t\t\tSET\n\t\t\t\t customer_support_topic_id = '" . (int) $data['customer_support_topic_id'] . "' \n\t\t\t\t, store_id = '" . (int) $data['store_id'] . "'\n\t\t\t\t, customer_id = '" . (int) $data['customer_id'] . "'\n\t\t\t\t, reference = '" . $data['reference'] . "' \n\t\t\t\t, customer_support_status = '" . $data['customer_support_status'] . "' \n\t\t\t\t, subject = '" . $this->db->escape(strip_tags($data['subject'])) . "'\n\t\t\t\t, enquiry = '" . $this->db->escape(strip_tags($data['enquiry'])) . "'\n\t\t\t\t, date_added = NOW() \n\t\t\t\t, date_updated = NOW() \n\t\t\t\t, customer_support_1st_category_id = '" . (int) $data['customer_support_1st_category_id'] . "' \n\t\t\t\t, customer_support_2nd_category_id = '" . (int) $data['customer_support_2nd_category_id'] . "'\n\t\t");
$customer_support_id = $this->db->getLastId();
$this->db->query("\n\t\t\tUPDATE " . DB_PREFIX . "customer_support\n\t\t\tSET\n\t\t\t\tdate_updated = NOW()\n\t\t\t\t, customer_support_status ='" . $data['customer_support_status'] . "'\n\t\t\tWHERE\n\t\t\t\tcustomer_support_id = '" . (int) $data['customer_support_topic_id'] . "'\n\t\t");
if (isset($data['notify_customer']) && $data['notify_customer'] == 'notify') {
$data = $this->getCustomerSupport($customer_support_id);
if (!empty($data)) {
$parent_data = $this->getCustomerSupport($data['customer_support_topic_id']);
$language = new Language('english');
$language->load('mail/customer_support');
$subject = "[" . $this->config->get('config_name') . "] " . html_entity_decode($data['subject'], ENT_QUOTES, 'UTF-8') . " - " . $language->get('text_answered');
// HTML Mail
$template = new Template();
$template->data['title'] = $language->get('text_subject');
$template->data['text_greeting'] = sprintf($language->get('text_greeting'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'));
$template->data['text_category'] = $language->get('text_category');
$template->data['text_reference'] = $language->get('text_reference');
$template->data['text_subject'] = $language->get('text_subject');
$template->data['text_enquiry'] = $language->get('text_enquiry');
$template->data['text_lead_url'] = $language->get('text_lead_url');
$template->data['text_powered_by'] = $language->get('text_powered_by');
$template->data['store_url'] = $this->config->get('config_url');
$template->data['store_name'] = $this->config->get('config_name');
$template->data['subject'] = $data['subject'];
$template->data['enquiry'] = nl2br(html_entity_decode($data['enquiry'], ENT_QUOTES, 'UTF-8'));
$template->data['category'] = $data['customer_support_1st_category'] . '/' . $data['customer_support_2nd_category'];
$template->data['lead_url'] = $this->config->get('config_url') . 'index.php?route=account/customer_support';
$template->data['logo'] = 'cid:' . basename($this->config->get('config_logo'));
$html = $template->fetch('/mail/customer_support.tpl');
// Text Mail
$text = sprintf($language->get('text_greeting'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8')) . "\n\n";
$text .= $language->get('text_category') . ": " . html_entity_decode($data['customer_support_1st_category'] . '/' . $data['customer_support_2nd_category'], ENT_QUOTES, 'UTF-8') . "\n\n";
$text .= $language->get('text_reference') . ": " . html_entity_decode($data['reference'], ENT_QUOTES, 'UTF-8') . "\n\n";
$text .= $language->get('text_subject') . ": " . html_entity_decode($data['subject'], ENT_QUOTES, 'UTF-8') . "\n\n";
$text .= $language->get('text_enquiry') . ": " . nl2br(html_entity_decode($data['enquiry'], ENT_QUOTES, 'UTF-8')) . "\n\n";
$text .= $language->get('text_lead_url') . ": " . $this->config->get('config_url') . 'index.php?route=account/customer_support';
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
$mail->setHtml($html);
$mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
$mail->addAttachment(DIR_IMAGE . $this->config->get('config_logo'));
$mail->setTo($parent_data['customer_email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($this->config->get('config_name'));
$mail->send();
// Send to additional alert emails
$mail->setSubject(html_entity_decode("[ADMIN]" . $subject, ENT_QUOTES, 'UTF-8'));
$mail->setTo($this->config->get('config_email'));
$mail->setHtml($html);
$mail->send();
}
}
}