<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 郵件發送 ### [](https://octobercms.com/docs/services/mail#sending-mail)發送郵件 要發送消息,請使用外觀`send`上的方法,該方法`Mail`接受三個參數。第一個參數是用于查找[郵件視圖](https://octobercms.com/docs/services/mail#mail-views)或[郵件模板](https://octobercms.com/docs/services/mail#mail-templates)的唯一*郵件代碼*。第二個參數是您希望傳遞給視圖的數據數組。第三個參數是一個回調,它接收消息實例,使您可以自定義郵件的收件人,主題和其他方面:[](https://octobercms.com/docs/services/mail#mail-views)[](https://octobercms.com/docs/services/mail#mail-templates)`Closure` ~~~ // These variables are available inside the message as Twig $vars = ['name' => 'Joe', 'user' => 'Mary']; Mail::send('acme.blog::mail.message', $vars, function($message) { $message->to('admin@domain.tld', 'Admin Person'); $message->subject('This is a reminder'); }); ~~~ 由于`name`在上面的示例中傳遞了包含鍵的數組,因此可以使用以下Twig標記在電子郵件視圖中顯示值: ~~~ {{ name }} ~~~ > **注意:**您應該避免`message`在郵件中傳遞變量,該變量始終會傳遞并允許[附件](https://octobercms.com/docs/services/mail#attachments)的[內聯嵌入](https://octobercms.com/docs/services/mail#attachments)。 #### 快速發送 十月還包括一個稱為的替代方法`sendTo`,可以簡化郵件的發送: ~~~ // Send to address using no name Mail::sendTo('admin@domain.tld', 'acme.blog::mail.message', $params); // Send using an object's properties Mail::sendTo($user, 'acme.blog::mail.message', $params); // Send to multiple addresses Mail::sendTo(['admin@domain.tld' => 'Admin Person'], 'acme.blog::mail.message', $params); // Alternatively send a raw message without parameters Mail::rawTo('admin@domain.tld', 'Hello friend'); ~~~ 中的第一個參數`sendTo`用于收件人可以采用不同的值類型: | 類型 | 描述 | | --- | --- | | 串 | 單個收件人地址,未定義名稱。 | | 數組 | 多個收件人,其中數組鍵是地址,值是名稱。 | | 目的 | 單個收件人對象,其中*email*屬性用于地址,*名稱*可選用于名稱。 | | 采集 | 如上所述,收件人對象的集合。 | 的完整簽名`sendTo`如下: ~~~ Mail::sendTo($recipient, $message, $params, $callback, $options); ~~~ * `$recipient`如上定義。 * `$message`是原始發送的模板名稱或消息內容。 * `$params`模板內部提供的變量數組。 * `$callback`會使用一個參數`send`(方法描述的消息生成器)被調用(可選,默認為null)。如果不是可調用的值,則代替下一個options參數。 * `$options`作為數組傳遞的自定義發送選項(可選) `$options`支持以下自定義發送 * **queue**指定是對消息進行排隊還是直接發送(可選,默認為false)。 * **BCC**指定是否添加收件人作為密件抄送或經常要地址(默認為false)。 #### 建立訊息 如前所述,該`send`方法的第三個參數是`Closure`允許您在電子郵件本身上指定各種選項。使用此閉包,您可以指定消息的其他屬性,例如復本,盲目復本等: ~~~ Mail::send('acme.blog::mail.welcome', $vars, function($message) { $message->from('us@example.com', 'October'); $message->to('foo@example.com')->cc('bar@example.com'); }); ~~~ 這是`$message`消息生成器實例上可用方法的列表: ~~~ $message->from($address, $name = null); $message->sender($address, $name = null); $message->to($address, $name = null); $message->cc($address, $name = null); $message->bcc($address, $name = null); $message->replyTo($address, $name = null); $message->subject($subject); $message->priority($level); $message->attach($pathToFile, array $options = []); // Attach a file from a raw $data string... $message->attachData($data, $name, array $options = []); // Get the underlying SwiftMailer message instance... $message->getSwiftMessage(); ~~~ > **注意:**傳遞給`Mail::send`Closure的消息實例擴展了[SwiftMailer](http://swiftmailer.org/)消息類,使您可以調用該類上的任何方法來構建電子郵件。 #### 郵寄純文本 默認情況下,`send`假定提供給該方法的視圖包含HTML。但是,通過將數組作為方法的第一個參數`send`傳遞,除了HTML視圖外,您還可以指定要發送的純文本視圖: ~~~ Mail::send(['acme.blog::mail.html', 'acme.blog::mail.text'], $data, $callback); ~~~ 或者,如果只需要發送純文本電子郵件,則可以使用`text`數組中的鍵進行指定: ~~~ Mail::send(['text' => 'acme.blog::mail.text'], $data, $callback); ~~~ #### 郵寄已解析的原始字符串 `raw`如果您希望直接通過電子郵件發送原始字符串,則可以使用該方法。Markdown將解析此內容。 ~~~ Mail::raw('Text to e-mail', function ($message) { // }); ~~~ 此外,Twig將解析此字符串,如果您希望將變量傳遞到此環境,請改用`send`方法,將內容作為`raw`鍵。 ~~~ Mail::send(['raw' => 'Text to email'], $vars, function ($message) { // }); ~~~ #### 郵寄原始字符串 如果傳遞包含`text`或`html`鍵的數組,這將是發送郵件的顯式請求。不使用布局或降價解析。 ~~~ Mail::raw([ 'text' => 'This is plain text', 'html' => '<strong>This is HTML</strong>' ], function ($message) { // }); ~~~ ### [](https://octobercms.com/docs/services/mail#attachments)附件 要將附件添加到電子郵件中,請使用傳遞給Closure`attach`的`$message`對象上的方法。該`attach`方法接受文件的完整路徑作為其第一個參數: ~~~ Mail::send('acme.blog::mail.welcome', $data, function ($message) { // $message->attach($pathToFile); }); ~~~ 在將文件附加到消息時,您還可以通過將an`array`作為第二個參數傳遞給`attach`方法來指定顯示名稱和/或MIME類型: ~~~ $message->attach($pathToFile, ['as' => $display, 'mime' => $mime]); ~~~ ### [](https://octobercms.com/docs/services/mail#inline-attachments)內聯附件 #### 將圖像嵌入郵件內容 將嵌入式圖像嵌入到電子郵件中通常很麻煩;但是,有一種簡便的方法可以將圖像附加到電子郵件并檢索適當的CID。若要嵌入嵌入式圖像,請在電子郵件視圖中`embed`的`message`變量上使用方法。請記住,該`message`變量可用于所有郵件視圖: ~~~ <body> Here is an image: <img src="{{ message.embed(pathToFile) }}"> </body> ~~~ 如果您打算使用排隊的電子郵件,請確保文件的路徑是絕對路徑。為此,您可以簡單地使用[應用過濾器](https://octobercms.com/docs/markup/filter-app): ~~~ <body> Here is an image: {% set pathToFile = 'storage/app/media/path/to/file.jpg' | app %} <img src="{{ message.embed(pathToFile) }}"> </body> ~~~ #### 將原始數據嵌入郵件內容 如果您已經有想要嵌入到電子郵件中的原始數據字符串,則可以`embedData`對`message`變量使用方法: ~~~ <body> Here is an image from raw data: <img src="{{ message.embedData(data, name) }}"> </body> ~~~ ### [](https://octobercms.com/docs/services/mail#queueing-mail)排隊郵件 #### 排隊郵件 由于發送郵件消息會大大延長應用程序的響應時間,因此許多開發人員選擇將消息排隊等待后臺發送。使用內置的[統一隊列API](https://octobercms.com/docs/services/queues)可以輕松實現。要使郵件排隊,請使用外觀`queue`上的方法`Mail`: ~~~ Mail::queue('acme.blog::mail.welcome', $data, function ($message) { // }); ~~~ 此方法將自動處理將作業推入隊列以在后臺發送郵件的情況。當然,在使用此功能之前,您將需要[配置隊列](https://octobercms.com/docs/services/queues)。 #### 延遲的消息排隊 如果您希望延遲發送排隊的電子郵件,則可以使用該`later`方法。首先,只需將您希望延遲發送消息的秒數作為方法的第一個參數傳遞: ~~~ Mail::later(5, 'acme.blog::mail.welcome', $data, function ($message) { // }); ~~~ #### 推送到特定隊列 如果希望指定要在其上推送消息的特定隊列,則可以使用`queueOn`和`laterOn`方法來這樣做: ~~~ Mail::queueOn('queue-name', 'acme.blog::mail.welcome', $data, function ($message) { // }); Mail::laterOn('queue-name', 5, 'acme.blog::mail.welcome', $data, function ($message) { // }); ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看