2016-05-30 9 views
-1

Laravelで構築されたWebサイトで電子メールを送信するフォームを作成しました。以前は問題なく動作していましたが、電子メールにhtml/cssテンプレートを追加しました。ユーザーは電子メールでhtml/cssテンプレートを受信する必要がありますが、テキストのみを受信して​​います。Laravelで電子メールでhtml/cssテンプレートを送信

は、これは私の送信機能

public function sendmail(Request $request) 
    { 
     $str = preg_replace('/\s\s+/', ' ', $request->emails); 
     $arr=explode(" ", $str); 
     $emails = array_slice($arr, 1, -1); 
     $subject = $request->subject; 
     $body = $request->body; 

     $sent = 0; 
     $declined = 0; 
     $decEmails=[]; 

     $send = 0; 
     $declined = 0; 

     foreach($emails as $email) 
     { 
      $send = Mail::send(['html' => 'pages.sendemail'],['subject'=>$subject, 'body'=>$body], function($message) use ($email, $subject) 
      { 
       $message->to($email)->subject($subject); 
      }); 
      if($send == 1) 
      { 
       $sent++; 
      } 
      else 
      { 
       array_push($decEmails, $email); 
       $declined++;     
      } 
     } 

     return view('sent', compact('sent','declined','decEmails')); 
} 

であり、これはデフォルトで私の見解

<!DOCTYPE html> 
 
<html> 
 
<head> 
 
\t <title>Ebay Georgia</title> 
 
\t <!--<link type="image/x-icon" rel="icon" href="images/icon.ico">--> 
 
\t <meta charset="utf-8" /> \t 
 
\t <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
 
\t <meta name="SKYPE_TOOLBAR" content="SKYPE_TOOLBAR_PARSER_COMPATIBLE" /> 
 
<script> 
 
\t document.createElement("header"); \t 
 
\t document.createElement("nav"); 
 
\t document.createElement("footer"); 
 
\t document.createElement("section") 
 
</script> 
 
<style> 
 
*{ margin:0; padding:0} 
 
html, body{width:100%; min-height:100%;} 
 
a{ text-decoration:none;} 
 
li{ list-style-type:none;} 
 
img{border:0;} 
 
@font-face { 
 
\t font-family: 'Conv_BPG DejaVu Sans ExtraLight 2012'; 
 
\t src: url('fonts/BPG DejaVu Sans ExtraLight 2012.eot'); 
 
\t src: local('☺'), url('fonts/BPG DejaVu Sans ExtraLight 2012.ttf') format('truetype'), url('../fonts/BPG DejaVu Sans ExtraLight 2012.svg') format('svg'); 
 
\t font-weight: normal; 
 
\t font-style: normal; 
 
} 
 
@font-face { 
 
\t font-family: 'Conv_BPG DejaVu Sans ExtraLight Caps 2012'; 
 
\t src: url('fonts/BPG DejaVu Sans ExtraLight Caps 2012.eot'); 
 
\t src: local('☺'), url('fonts/BPG DejaVu Sans ExtraLight Caps 2012.ttf') format('truetype'), url('../fonts/BPG DejaVu Sans ExtraLight Caps 2012.svg') format('svg'); 
 
\t font-weight: normal; 
 
\t font-style: normal; 
 
} 
 

 
/*main css*/ 
 
#wrapper{ 
 
\t width:92%; 
 
\t max-width:600px; 
 
\t padding:29px 4% 10px 4%; 
 
\t background:#1c75d7 url(../images/corner.png) no-repeat right bottom; 
 
\t background-size:auto 100%; 
 
\t margin:50px auto; \t 
 
} 
 
#maincContent{ 
 
\t -webkit-box-shadow: 0px 0px 4px 2px rgba(0,0,0,0.24); 
 
\t -moz-box-shadow: 0px 0px 4px 2px rgba(0,0,0,0.24); 
 
\t box-shadow: 0px 0px 4px 2px rgba(0,0,0,0.24); 
 
\t background-color:#fff; 
 
\t margin-bottom:13px; 
 
\t position:relative; 
 
\t clear:both; 
 
\t overflow:hidden; 
 
\t border-bottom-right-radius:40px; 
 
} 
 
#head{ 
 
\t width:92%; 
 
\t max-width:550px; 
 
\t margin:25px auto; 
 
} 
 
#head h1{ 
 
\t width:94px; 
 
\t height:47px; 
 
\t margin:25px 5.45%; 
 

 
} 
 
#head h1 a{ 
 
\t display:block; 
 
\t text-indent:-9999px; 
 
\t width:100%; 
 
\t height:100%; 
 
\t background: url(../images/logo.png) no-repeat center center; \t 
 
} 
 
#content{ 
 
\t width:92%; 
 
\t max-width:550px; 
 
\t margin:25px auto; 
 
} 
 
#content h2{ 
 
\t color:#5c5c5c; 
 
\t font-size:15px; \t 
 
\t margin-bottom:20px; 
 
\t font-family: 'Conv_BPG DejaVu Sans ExtraLight 2012'; 
 
\t margin:0px 5.45% 25px 5.45%; 
 
} 
 
#content .parpagraph{ 
 
\t color:#5c5c5c; 
 
\t font-size:15px; \t 
 
\t margin-bottom:20px; 
 
\t font-family: 'Conv_BPG DejaVu Sans ExtraLight 2012'; 
 
\t font-weight:600; 
 
\t margin:0px 5.45% 25px 5.45%; 
 
} 
 
#content .parpagraphGreen{ 
 
\t color:#86b817; 
 
\t font-size:14px; \t 
 
\t margin-bottom:20px; 
 
\t font-family: 'Conv_BPG DejaVu Sans ExtraLight Caps 2012'; 
 
\t font-weight:600; 
 
\t margin:0px 5.45% 44px 5.45%; 
 
} 
 
#content img{ 
 
\t display:block; 
 
\t margin:0px 5.45% 60px 5.45%; \t 
 
} 
 
#maincContent::after { 
 
    content: ""; 
 
    position: absolute; 
 
    z-index:2; 
 
    bottom: 0; 
 
    right: 0%; 
 
    width: 0px; 
 
    height: 0px; 
 
    border-top:35px solid #dbdbdb; 
 
    border-right: 35px solid #dbdbdb; 
 
#footer{ 
 
\t width:92%; 
 
\t max-width:550px; 
 
\t margin:0 auto; 
 
} 
 
#footer ul{ 
 
\t margin-left:7%; 
 
\t overflow:hidden; \t 
 
} 
 
#footer ul li{ 
 
\t display:inline-block; 
 
\t float:left; 
 
\t width: \t 31px; 
 
\t height:35px; 
 
\t margin-right:2%; 
 
} 
 
#footer ul li a{ 
 
\t display:block; 
 
\t width:100%; 
 
\t height:100%; 
 
\t text-indent:-9999px; \t 
 
\t margin-bottom:8px; 
 
} 
 
#footer ul li a.mail{ 
 
\t background:url(../images/mail.png) no-repeat center center; 
 
} 
 
#footer ul li a.fb{ 
 
\t background:url(../images/fb.png) no-repeat center center; 
 
} 
 
#footer ul li a.link{ 
 
\t background:url(../images/link.png) no-repeat center center; 
 
} 
 
</style> 
 
</head> 
 
<body> 
 
\t <section id="wrapper"><!--id="wrapper"--> 
 
    \t <section id="maincContent"><!--id="maincContent"--> 
 
     \t <header id="head"><!--header--> 
 
     \t \t <h1><a href="index.html" target="_blank">Ebay Georgia</a></h1>   
 
     \t </header><!--End of header--> 
 
     \t <section id="content"><!--id="content"--> 
 
       <h2> {!! $subject !!}</h2> 
 
       <div class="parpagraph"> 
 
       {!! $body !!}  
 
       </div><br> 
 
       <div class="parpagraphGreen"> 
 
       \t მადლობა ჩვენი სერვისით სარგებლობისთვის. 
 
       </div> 
 
       <img src="../images/line.png" alt="#" /> 
 
      </section><!--End of id="content"--> 
 
      
 
     </section><!--En dof id="maincContent"--> 
 
     <footer id="footer"><!--id="footer"--> 
 
     \t <ul> 
 
      \t <li><a href="#" target="_blank" class="mail">mail</a></li> 
 
       <li><a href="#" target="_blank" class="fb">facebook</a></li> 
 
       <li><a href="#" target="_blank" class="link">link</a></li> 
 
      </ul> 
 
     </footer><!--End of id="footer"--> 
 
    </section><!--End of id="wrapper"--> 
 
</body> 
 
</html>

+0

質問は何ですか?最小限の例を投稿できますか? –

答えて

1

で、Mail::send()方法についてビューはHTMLが含まれていると想定されます。だからあなたのビューアレイにhtmlキーを与える必要があり、これは動作するはずがない:

Mail::send('pages.sendemail', ['subject'=>$subject, 'body'=>$body]... 

しかし、あなたは、プレーンテキストを送信したい場合は['text' => 'pages.sendemail']としてそれを定義する必要があります。

+0

こんにちは、返信いただきありがとうございます!残念ながら、それは役に立たず、私はまだ同じ問題を抱えています。問題はGmailがhtml/cssをブロックしていることでしょうか?もしそうなら、それを防ぐ方法はありますか? – Kabaneri

+0

@Kabaneri私はあなたのメールテンプレートをコピーしてそれを 'pages/sendmail.blade.php'として保存しました。スタイリングが乱れていない限り、私のために働いているようです。https://www.diigo。 com/item/image/5kg0i/8ks4 – Rifki

+0

これは普通のHTMLで、私にとってもうまくいきます。私はCSSスタイルに問題があります。ページは次のようになります。 http://imgur.com/munhGVZ それ自体では、必要なように表示されますが、電子メールで送信された場合は動作しません。 – Kabaneri

関連する問題