lundi 1 août 2016

Broken Email Template

I am using laravel 5 framework for a project and it has a features that a user can construct a email message. But when I test it on my email I got html tags.

<p> <small>Julius Cesar</small></p><p><small>Julius</small></p><p><small> Cesar<br></small></p><p><small>tester@mail.com </small> <br></p> 

I have no idea why it goes like that. Here is my code in laravel. This is for the view of that displays the form: eblast-form.blade.php

<form action="  " id="eblast-form" method="post">
    
    <div class="box-body">
        <div class="form-group ">
            <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="" required="required" />
            </div>
        </div>
        <br><br>
        <div class="form-group ">
            <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>
                    
                </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>

This is on my controller's method that sends the email:

 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'));

        });
        ....
    }

This is the email template of emails.e-blast / emails.e-blast.blade.php

<!DOCTYPE html>
<html lang="en-US">
<head>
    <meta charset="utf-8">
</head>
<body>

</body>
</html>

Does anyone have an idea about my case?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2aWewUL
via IFTTT

Aucun commentaire:

Enregistrer un commentaire