我爲項目使用laravel 5框架,它具有用戶可以構造電子郵件消息的功能。但是當我在我的電子郵件上測試它時,我收到了html標籤。破損的電子郵件模板
<p> <small>Julius Cesar</small></p><p><small>Julius</small></p><p><small> Cesar<br></small></p><p><small>[email protected] </small> <br></p>
預計輸出用戶從電子郵件接收應該是:
Julius Cesar
Julius
Cesar
[email protected]
我不知道爲什麼它會這樣。這是我在laravel的代碼。 這對於該視圖顯示形式:eblast-form.blade.php
<form action=" {{ url('app/esetting/emailblast') }} " id="eblast-form" method="post">
{{ csrf_field() }}
<div class="box-body">
<div class="form-group {{ $errors->has('subject') ? 'has-error' : '' }}">
<label for="subject" class="control-label col-sm-2">Subject</label>
<div class="col-sm-10">
<input type="text" name="subject" class="form-control" id="subject" placeholder="Subject" value="{{ old('subject') }}" required="required" />
</div>
</div>
<br><br>
<div class="form-group {{ $errors->has('message') ? 'has-error' : '' }}">
<label for="message" class="control-label">Email Message Content</label>
<div class="col-sm-12">
<textarea class="form-control" name="message-cont" id="message" required>
{{ old('message') }}
</textarea>
<p><small> [fullname] [first_name] [last_name] [email] </small></p>
<input type="hidden" id="msg" name="message" value="">
</div>
</div>
</div>
<br>
<br>
<div class="box-footer">
<div class=" pull-right">
<button type="submit" class="btn btn-info " id="send-mail">Send</button>
</div>
</div>
</form>
這是我的控制器的方法發送電子郵件:
public function postEmailblast(Request $request)
{
....
$user = Auth::user();
$message = $request->input('message');
$m_user = User::find($egm->user_id);
$rep_this = array(
"[fullname]",
"[first_name]",
"[last_name]",
"[email]"
);
$rep_with = array(
$m_user->common_name,
$m_user->first_name,
$m_user->last_name,
$m_user->email
);
$data = array(
'email_content' => str_replace($rep_this, $rep_with, $message),
);
Mail::send('emails.e-blast', $data, function ($message) use ($request, $user, $m_user) {
$message->from($user->email, $user->common_name)->to($m_user->email, $m_user->common_name)->subject($request->input('subject'));
});
....
}
這是emails.e-blast
/emails.e-blast.blade.php
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
</head>
<body>
{{$email_content}}
</body>
</html>
有沒有人有關於我的情況的想法?