Anonymous
Отправить шаблон HTML/CSS по электронной почте с Laravel
Сообщение
Anonymous » 19 фев 2025, 13:35
Я сделал форму для отправки электронной почты на веб -сайте, построенном на Laravel. Раньше он работал без проблем, но затем я добавил шаблон HTML/CSS в электронное письмо. Пользователь должен получить шаблон 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') );
}
< /code>
и это моя точка зрения < /p>
Ebay Georgia
document.createElement("header");
document.createElement("nav");
document.createElement("footer");
document.createElement("section")
*{ 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 {
font-family: 'Conv_BPG DejaVu Sans ExtraLight 2012';
src: url('fonts/BPG DejaVu Sans ExtraLight 2012.eot');
src: local('☺'), url('fonts/BPG DejaVu Sans ExtraLight 2012.ttf') format('truetype'), url('../fonts/BPG DejaVu Sans ExtraLight 2012.svg') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Conv_BPG DejaVu Sans ExtraLight Caps 2012';
src: url('fonts/BPG DejaVu Sans ExtraLight Caps 2012.eot');
src: local('☺'), url('fonts/BPG DejaVu Sans ExtraLight Caps 2012.ttf') format('truetype'), url('../fonts/BPG DejaVu Sans ExtraLight Caps 2012.svg') format('svg');
font-weight: normal;
font-style: normal;
}
/*main css*/
#wrapper{
width:92%;
max-width:600px;
padding:29px 4% 10px 4%;
background:#1c75d7 url(../images/corner.png) no-repeat right bottom;
background-size:auto 100%;
margin:50px auto;
}
#maincContent{
-webkit-box-shadow: 0px 0px 4px 2px rgba(0,0,0,0.24);
-moz-box-shadow: 0px 0px 4px 2px rgba(0,0,0,0.24);
box-shadow: 0px 0px 4px 2px rgba(0,0,0,0.24);
background-color:#fff;
margin-bottom:13px;
position:relative;
clear:both;
overflow:hidden;
border-bottom-right-radius:40px;
}
#head{
width:92%;
max-width:550px;
margin:25px auto;
}
#head h1{
width:94px;
height:47px;
margin:25px 5.45%;
}
#head h1 a{
display:block;
text-indent:-9999px;
width:100%;
height:100%;
background: url(../images/logo.png) no-repeat center center;
}
#content{
width:92%;
max-width:550px;
margin:25px auto;
}
#content h2{
color:#5c5c5c;
font-size:15px;
margin-bottom:20px;
font-family: 'Conv_BPG DejaVu Sans ExtraLight 2012';
margin:0px 5.45% 25px 5.45%;
}
#content .parpagraph{
color:#5c5c5c;
font-size:15px;
margin-bottom:20px;
font-family: 'Conv_BPG DejaVu Sans ExtraLight 2012';
font-weight:600;
margin:0px 5.45% 25px 5.45%;
}
#content .parpagraphGreen{
color:#86b817;
font-size:14px;
margin-bottom:20px;
font-family: 'Conv_BPG DejaVu Sans ExtraLight Caps 2012';
font-weight:600;
margin:0px 5.45% 44px 5.45%;
}
#content img{
display:block;
margin:0px 5.45% 60px 5.45%;
}
#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{
width:92%;
max-width:550px;
margin:0 auto;
}
#footer ul{
margin-left:7%;
overflow:hidden;
}
#footer ul li{
display:inline-block;
float:left;
width: 31px;
height:35px;
margin-right:2%;
}
#footer ul li a{
display:block;
width:100%;
height:100%;
text-indent:-9999px;
margin-bottom:8px;
}
#footer ul li a.mail{
background:url(../images/mail.png) no-repeat center center;
}
#footer ul li a.fb{
background:url(../images/fb.png) no-repeat center center;
}
#footer ul li a.link{
background:url(../images/link.png) no-repeat center center;
}
[url=index.html]Ebay Georgia[/url]
{!! $subject !!}
{!! $body !!}
მადლობა ჩვენი სერვისით სარგებლობისთვის.
[img]../images/line.png[/img]
[list]
[url=#]mail[/url]
[*][url=#]facebook[/url]
[*][url=#]link[/url]
[/list]
Подробнее здесь:
https://stackoverflow.com/questions/375 ... th-laravel
1739961311
Anonymous
Я сделал форму для отправки электронной почты на веб -сайте, построенном на Laravel. Раньше он работал без проблем, но затем я добавил шаблон HTML/CSS в электронное письмо. Пользователь должен получить шаблон HTML /CSS в электронном письме, но получает только текст. >[code] 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') ); } < /code> и это моя точка зрения < /p> Ebay Georgia document.createElement("header"); document.createElement("nav"); document.createElement("footer"); document.createElement("section") *{ 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 { font-family: 'Conv_BPG DejaVu Sans ExtraLight 2012'; src: url('fonts/BPG DejaVu Sans ExtraLight 2012.eot'); src: local('☺'), url('fonts/BPG DejaVu Sans ExtraLight 2012.ttf') format('truetype'), url('../fonts/BPG DejaVu Sans ExtraLight 2012.svg') format('svg'); font-weight: normal; font-style: normal; } @font-face { font-family: 'Conv_BPG DejaVu Sans ExtraLight Caps 2012'; src: url('fonts/BPG DejaVu Sans ExtraLight Caps 2012.eot'); src: local('☺'), url('fonts/BPG DejaVu Sans ExtraLight Caps 2012.ttf') format('truetype'), url('../fonts/BPG DejaVu Sans ExtraLight Caps 2012.svg') format('svg'); font-weight: normal; font-style: normal; } /*main css*/ #wrapper{ width:92%; max-width:600px; padding:29px 4% 10px 4%; background:#1c75d7 url(../images/corner.png) no-repeat right bottom; background-size:auto 100%; margin:50px auto; } #maincContent{ -webkit-box-shadow: 0px 0px 4px 2px rgba(0,0,0,0.24); -moz-box-shadow: 0px 0px 4px 2px rgba(0,0,0,0.24); box-shadow: 0px 0px 4px 2px rgba(0,0,0,0.24); background-color:#fff; margin-bottom:13px; position:relative; clear:both; overflow:hidden; border-bottom-right-radius:40px; } #head{ width:92%; max-width:550px; margin:25px auto; } #head h1{ width:94px; height:47px; margin:25px 5.45%; } #head h1 a{ display:block; text-indent:-9999px; width:100%; height:100%; background: url(../images/logo.png) no-repeat center center; } #content{ width:92%; max-width:550px; margin:25px auto; } #content h2{ color:#5c5c5c; font-size:15px; margin-bottom:20px; font-family: 'Conv_BPG DejaVu Sans ExtraLight 2012'; margin:0px 5.45% 25px 5.45%; } #content .parpagraph{ color:#5c5c5c; font-size:15px; margin-bottom:20px; font-family: 'Conv_BPG DejaVu Sans ExtraLight 2012'; font-weight:600; margin:0px 5.45% 25px 5.45%; } #content .parpagraphGreen{ color:#86b817; font-size:14px; margin-bottom:20px; font-family: 'Conv_BPG DejaVu Sans ExtraLight Caps 2012'; font-weight:600; margin:0px 5.45% 44px 5.45%; } #content img{ display:block; margin:0px 5.45% 60px 5.45%; } #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{ width:92%; max-width:550px; margin:0 auto; } #footer ul{ margin-left:7%; overflow:hidden; } #footer ul li{ display:inline-block; float:left; width: 31px; height:35px; margin-right:2%; } #footer ul li a{ display:block; width:100%; height:100%; text-indent:-9999px; margin-bottom:8px; } #footer ul li a.mail{ background:url(../images/mail.png) no-repeat center center; } #footer ul li a.fb{ background:url(../images/fb.png) no-repeat center center; } #footer ul li a.link{ background:url(../images/link.png) no-repeat center center; } [url=index.html]Ebay Georgia[/url] {!! $subject !!} {!! $body !!} მადლობა ჩვენი სერვისით სარგებლობისთვის. [img]../images/line.png[/img] [list] [url=#]mail[/url] [*][url=#]facebook[/url] [*][url=#]link[/url] [/list] [/code] Подробнее здесь: [url]https://stackoverflow.com/questions/37522925/send-html-css-template-by-email-with-laravel[/url]