Saturday, September 3, 2016

Sending Email Using SMTP-GMAIL in Laravel 5.3 - Part II

In the previous post, we have sent an email using Mail::raw, so in this post we are going to use another method, Mail::send, with it's another properties. First... Let's change our Mail::raw to Mail:send as shown below :

Next... Let's create our emailcontent within view folder :
Yaaaps.... That's all... Let's hit "Send Mail" link {turn off antivirus first}...
Aaand... Here is our email...
Next, let's some properties to our email so change the Mail::send to be like this :
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use Log;
use Mail;

class emailcontroller extends Controller
{
    public function defaultSend()
    {
        Log::info("Request cycle without Queues started");

        Mail::send('emailcontent', ['data'=>'data'], function ($message) {
            $message->subject("Default Email");
            $message->from('adiatstei07@gmail.com', 'Hisoka');
            $message->to('hyosoka187@gmail.com');
            $message->cc('maryadi@astrnt.co');
            $message->attachData('This is my pdf Data...','hisoka.pdf');
            log::info("End of mail processing...");
        });


        Log::info("Request cycle without Queues finished");
        return redirect()->back();

    }
}

Result is like this :
Yeepp... That's all for this second part... :D... B-)
Demo :


Source code:
https://github.com/HyosokaPoipo/maillaravel53/tree/1._Part_2

No comments:

Post a Comment