当前位置: 首页>>代码示例>>PHP>>正文


PHP message::set_attachByPathOnAppServer方法代码示例

本文整理汇总了PHP中message::set_attachByPathOnAppServer方法的典型用法代码示例。如果您正苦于以下问题:PHP message::set_attachByPathOnAppServer方法的具体用法?PHP message::set_attachByPathOnAppServer怎么用?PHP message::set_attachByPathOnAppServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在message的用法示例。


在下文中一共展示了message::set_attachByPathOnAppServer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array


//.........这里部分代码省略.........
                         $boundary = trim(str_replace(array("'", '"'), '', $parts[1]));
                     }
                     continue;
                 }
                 // Explode them out
                 list($name, $content) = explode(':', trim($header), 2);
                 // Cleanup crew
                 $name = trim($name);
                 $content = trim($content);
                 switch (strtolower($name)) {
                     // Mainly for legacy -- process a From: header if it's there
                     case 'from':
                         if (strpos($content, '<') !== false) {
                             // So... making my life hard again?
                             $from_name = substr($content, 0, strpos($content, '<') - 1);
                             $from_name = str_replace('"', '', $from_name);
                             $from_name = trim($from_name);
                             $from_email = substr($content, strpos($content, '<') + 1);
                             $from_email = str_replace('>', '', $from_email);
                             $from_email = trim($from_email);
                         } else {
                             $from_name = trim($content);
                         }
                         break;
                     case 'content-type':
                         if (strpos($content, ';') !== false) {
                             list($type, $charset) = explode(';', $content);
                             $content_type = trim($type);
                             if (false !== stripos($charset, 'charset=')) {
                                 $charset = trim(str_replace(array('charset=', '"'), '', $charset));
                             } elseif (false !== stripos($charset, 'boundary=')) {
                                 $boundary = trim(str_replace(array('BOUNDARY=', 'boundary=', '"'), '', $charset));
                                 $charset = '';
                             }
                         } else {
                             $content_type = trim($content);
                         }
                         break;
                     case 'cc':
                         $cc = array_merge((array) $cc, explode(',', $content));
                         break;
                     case 'bcc':
                         $bcc = array_merge((array) $bcc, explode(',', $content));
                         break;
                     default:
                         // Add it to our grand headers array
                         $headers[trim($name)] = trim($content);
                         break;
                 }
             }
         }
     }
     // From email and name
     // If we don't have a name from the input headers
     if (!isset($from_name)) {
         $from_name = '';
     }
     /* If we don't have an email from the input headers default to $noreply
      * Some hosts will block outgoing mail from this address if it doesn't exist but
      * there's no easy alternative. Defaulting to admin_email might appear to be another
      * option but some hosts may refuse to relay mail from an unknown domain. See
      * http://trac.wordpress.org/ticket/5007.
      */
     if (!isset($from_email)) {
         // Get the site domain and get rid of www.
         $sitename = strtolower($_SERVER['SERVER_NAME']);
         if (substr($sitename, 0, 4) == 'www.') {
             $sitename = substr($sitename, 4);
         }
         $from_email = $replyto;
     }
     // Set destination addresses
     if (!is_array($to)) {
         $to = explode(',', $to);
     }
     // Set Content-Type and charset
     // If we don't have a content-type from the input headers
     if (!isset($content_type)) {
         $content_type = 'text/html';
     }
     $content_type = apply_filters('wp_mail_content_type', $content_type);
     $msg = new message($content_type, $log, $debug, $logpath);
     $msg->set_to($to);
     $msg->set_cc($cc);
     $msg->set_bcc($bcc);
     $msg->set_subject($subject);
     $msg->set_bodyContent(nl2br($message));
     if (!empty($attachments)) {
         foreach ($attachments as $attachment) {
             $msg->set_attachByPathOnAppServer(basename($attachment), $attachment);
         }
     }
     //add message to mailsender
     if (!$sender->add($msg)) {
         return false;
     }
     // Send!
     $result = $sender->send_mail();
     return $result;
 }
开发者ID:pausaura,项目名称:agora_nodes,代码行数:101,代码来源:xtec-mail.php

示例2: sendMail


//.........这里部分代码省略.........
        $debug = ModUtil::getVar('SiriusXtecMailer', 'debug');
        $logpath = ModUtil::getVar('SiriusXtecMailer', 'logpath');

        $mail = new mailsender($idApp, $replyAddress, $sender, $environment, $log, $debug, $logpath);

        // add body content type
        $contenttypes = ModUtil::func('SiriusXtecMailer', 'admin', 'getContentTypes');

        // set HTML mail if required
        if (isset($args['html']) && is_bool($args['html'])) {
            if ($args['html']) {
                $bodyType = 'text/html';
            } else {
                $bodyType = TEXTPLAIN;
            }
        } else {
            $bodyType = $contenttypes[ModUtil::getVar('SiriusXtecMailer', 'contenttype')];
        }

        $message = new message($bodyType, $log, $debug, $logpath);

        // add any to addresses
        if (is_array($args['toaddress'])) {
            foreach ($args['toaddress'] as $to) {
                $message->set_to($to);
            }
        } else {
            // $toaddress is not an array -> old logic
            // process multiple names entered in a single field separated by commas (#262)
            foreach (explode(',', $args['toaddress']) as $to) {
                $message->set_to($to);
            }
        }

        // add any cc addresses
        if (isset($args['cc']) && is_array($args['cc'])) {
            foreach ($args['cc'] as $cc) {
                $message->set_cc($cc['address']);
            }
        }

        // add any bcc addresses
        if (isset($args['bcc']) && is_array($args['bcc'])) {
            foreach ($args['bcc'] as $bcc) {
                $message->set_bcc($bcc['address']);
            }
        }

        // add message subject and body
        $subject = $args['subject'];
        $message->set_subject($subject);
        $body = $args['body'];
        $message->set_bodyContent($body);

        // add attachments
        if (isset($args['attachments']) && !empty($args['attachments'])) {
            foreach ($args['attachments'] as $attachment) {
                if (is_array($attachment)) {
                    if (count($attachment) != 4) {
                        // skip invalid arrays
                        continue;
                    }
                    $message->set_attachByPathOnAppServer($attachment[1], $attachment[0]);
                } else {
                    $message->set_attachByPathOnAppServer(basename($attachment[0]), $attachment[0]);
                }
            }
        }

        // add string attachments.
        if (isset($args['stringattachments']) && !empty($args['stringattachments'])) {
            foreach ($args['stringattachments'] as $attachment) {
                if (is_array($attachment) && count($attachment) == 4) {
                    $message->set_attachByContent($attachment[1], $attachment[0], $attachment[3]);
                }
            }
        }

        // add embedded images
        if (isset($args['embeddedimages']) && !empty($args['embeddedimages'])) {
            foreach ($args['embeddedimages'] as $embeddedimage) {
                $message->set_attachByPathOnAppServer(basename($embeddedimage), $embeddedimage);
            }
        }

        //add message to mailsender
        if (!$mail->add($message)) {
            // message not added
            return LogUtil::registerError(__f('Error! A problem occurred while adding an e-mail message to \'%1$s\' (%2$s) with subject \'%3$s\'', array($args['toname'], $args['toaddress'][0], $args['subject'])));
        }

        // send message
        if (!$mail->send_mail()) {
            // message not sent
            return LogUtil::registerError(__f('Error! A problem occurred while sending an e-mail message to \'%1$s\' (%2$s) with subject \'%3$s\'', array($args['toname'], $args['toaddress'][0], $args['subject'])));
        }
		$event->stop();
		$event->setData(true);
        return true; // message sent    
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:101,代码来源:Listeners.php


注:本文中的message::set_attachByPathOnAppServer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。