お世話になっております。
Laravel5.8で通知機能を利用してHTMLメールを送信しているのですが
本番環境でメールは送信できるものの、ヘッダーとフッター以外のタグがすべて丸見えになってしまいます。
(開発環境では問題無く表示されています。)
どこを修正すれば良いのかがさっぱり分かりません。
###環境
さくらのマネージドサーバ
PHP 7.2
Laravel 5.8
###やったこと
こちらの記事を参考に通知機能を実装し
php artisan vendor:publish でnotificationのテンプレートを
/resources/views/vendor/notifications/ にコピーして編集しました。
email.blade.phpのコードです。
1@component('mail::message') 2 3 {{-- Greeting --}} 4 @if (! empty($greeting)) 5 {{ $greeting }} 6 @else 7 @if ($level === 'error') 8 @lang('Whoops!') 9 @else 10 @lang(__('Hello!')) 11 @endif 12 @endif 13 14 {{-- Intro Lines --}} 15 @foreach ($introLines as $line) 16 {{ $line }} 17 18 @endforeach 19 20 {{-- Action Button --}} 21 @component('mail::button', ['url' => $actionUrl, 'color' => 'blue']) 22 {{ $actionText }} 23 @endcomponent 24 25 {{-- Outro Lines --}} 26 @foreach ($outroLines as $line) 27 {{ $line }} 28 29 @endforeach 30 31 {{-- Salutation --}} 32 @if (! empty($salutation)) 33 {{ $salutation }} 34 @else 35 {{ config('app.name') }} 36 @endif 37 38 {{-- Subcopy --}} 39 @isset($actionText) 40 @slot('subcopy') 41 @lang(__('If you’re having trouble clicking the button above, copy and paste the URL below.')) 42 <br> 43 @lang(__('into your web browser:')) 44 @lang( 45 ' [:actionURL](:actionURL)', 46 [ 47 'actionText' => $actionText, 48 'actionURL' => $actionUrl, 49 ] 50 ) 51 @endslot 52 @endisset 53 54@endcomponent
通知機能です。
いくつか実装していますがどれも「メールは届くけどコードが見える」状態です。
一例としてパスワード再設定メールの通知を記載しておきます。
CustomResetPassword
1<?php 2 3namespace App\Notifications; 4 5use Illuminate\Bus\Queueable; 6use Illuminate\Notifications\Notification; 7use Illuminate\Contracts\Queue\ShouldQueue; 8use Illuminate\Notifications\Messages\MailMessage; 9 10class CustomResetPassword extends Notification 11{ 12 13 public $token; 14 15 16 public static $toMailCallback; 17 18 19 public function __construct($token) 20 { 21 $this->token = $token; 22 } 23 24 25 public function via($notifiable) 26 { 27 return ['mail']; 28 } 29 30 31 public function toMail($notifiable) 32 { 33 if (static::$toMailCallback) { 34 return call_user_func(static::$toMailCallback, $notifiable, $this->token); 35 } 36 return (new MailMessage) 37 ->from('email address', config('app.name')) 38 ->subject(__('Reset Password')) 39 ->line(__('Click button below and reset password.')) 40 ->action('パスワード再設定', url(config('app.url') . route('password.reset', ['token' => $this->token, 'email' => $notifiable->getEmailForPasswordReset()], false))) 41 ->line(__('If you did not request a password reset, no further action is required.')); 42 } 43 44 /** 45 * Get the array representation of the notification. 46 * 47 * @param mixed $notifiable 48 * @return array 49 */ 50 public function toArray($notifiable) 51 { 52 return [ 53 // 54 ]; 55 } 56 57 58 public static function toMailUsing($callback) 59 { 60 static::$toMailCallback = $callback; 61 } 62} 63
届いたメールがこちらです。
Gmailで受信しています。
1お知らせ 2 3 ボタンをクリックしてパスワードを再設定してください。 4 5<table class="action" align="center" width="100%" cellpadding="0" cellspacing="0" role="presentation"> 6<tr> 7 <td align="center"> 8 <table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation"> 9 <tr> 10 <td align="center"> 11 <table border="0" cellpadding="0" cellspacing="0" role="presentation"> 12 <tr> 13 <td> 14 <a href="http://(リセット用URL)" class="button button-blue" target="_blank">パスワード再設定</a> 15 </td> 16 </tr> 17 </table> 18 </td> 19 </tr> 20 </table> 21 </td> 22</tr> 23 このメールに心当たりがない場合は、このまま削除してください。 24 25 アプリ名 26ボタンがクリックできない場合は、下のURLをコピーしてブラウザのアドレス欄に貼り付け、直接アクセスしてください。 27ブラウザでアクセス: http://(リセット用URL)
ActionButton部分のタグが崩れている状態でしたので
ActionButtonに関する記述を削除して試したところ
タグの崩れはなくなりましたがCSSは適用されないままです。
調べてみましたがメールの表示に関する情報が出ておらず
どこから手を付ければいいのか困っております。
その他必要な情報などございましたらお知らせ下さい。
よろしくお願いいたします。

回答1件
あなたの回答
tips
プレビュー