Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Sendgrid using laravel 4.x

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 214
    Comment on it

    Laravel 4.x provide n number of sending email library such as mandrill,sendgrid etc. These all library are used to send bulk email. To use Sendgrid in our Laravel project we have to follow few steps. By this way we can implement Sendgrid in our Laravel project. The steps are:

     

    Step 1:

    First create a sendgrid account. To sign up with sendgrid follow the below link:

    https://sendgrid.com/home/b

     

    Step 2:

    In second step we will set the configuration setting. For setting configuration setting we have to go to the

    app/config/mail.php and In app/config/mail.php you need to configure these settings:

    <?php
    
    return array(
      'driver' => 'smtp',
      'host' => 'smtp.sendgrid.net',
      'port' => 587,
      'from' => array('address' => 'from@example.com', 'name' => 'John Smith'),
      'encryption' => 'tls',
      'username' => 'sendgrid_username',
      'password' => 'sendgrid_password',
    );
    
    ?>
    

    In this we have to just mention the sendgrid username and password.

     

    Step 3:

    Now just use Laravel mail class and all mail will send through SendGrid. The syntax for sending mail is:

    <?php
    
    Mail::send('emails.demo', $data, function($message)
    {
        $message->to('ankit@example.com', 'Ankit  Bhatia')->subject('This is a demo!');
    });
    
    ?>

    In the above example instead of demo just send the email template name which you have created and in data section send the data which you want to send in your mail section.

    By this way we can send mail using SendGrid using laravel 4.x framework.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: