我想發送包含XML作爲內容的電子郵件。 我爲此創建了一個刀片視圖,其中我傳遞了符合電子郵件的變量。使用Laravel通過電子郵件發送XML
我xml_email.blade.php
看起來是這樣的:
{{ '<'.'?'.'xml version="1.0" encoding="UTF-8"?>' }}
<customer>
<contact>
<name part="full">{{$customer->name}}</name>
@if($customer->allow_phone == true)
<phone>{{$customer->phone}}</phone>
@endif
<email>{{$customer->email}}</email>
</contact>
</customer>
,我來自一個控制器
Mail::send('emails.xml_email', ['customer' => $customer], function($message){
$message->to("[email protected]", '')->subject('New Customer!');
});
然而,電子郵件被髮送發送它像這不是XML格式,所有的標籤缺失。
有沒有辦法將電子郵件的MIME類型更改爲text/xml
或在發送時保留所有XML標籤?
謝謝!
我試過這種方法,它崩潰我這樣做: Mail :: send('emails.xml_email',['customer'=> $ customer],function($ message){message-> setContentType (「text/xml」) - > to(「[email protected]」,'') - > subject('New Customer!'); }); – 2014-10-21 20:16:16
崩潰不是錯誤消息。 [如何在PHP中獲取有用的錯誤消息?](http://stackoverflow.com/q/845021/367456) - 請啓用日誌記錄,然後具體的錯誤消息應該有助於說更多。 – hakre 2014-10-22 12:21:26