Support the ongoing development of Laravel.io →
Mail Configuration Installation
Last updated 1 year ago.
0

Hello Mark,

#Laravel supports sending email over SMTP. To have laravel relay email through Pepipost, follow the below steps:

#Step 1 – Register Pepipost Account

  • Go to https://pepipost.com
  • Click Try Pepipost Now
  • Fill all the necessary details
  • Wait for a email from Pepipost conforming that your account is provisioned.

Cool,you are ready to go!

#Step 2 – Change mail configurations in .env and mail.php files

Open .env located at root of the application, edit the file as below

MAIL_DRIVER=smtp
MAIL_HOST=smtp.pepipost.com	
MAIL_PORT=587
MAIL_USERNAME=pepipostUsername
MAIL_PASSWORD=pepipostPassword

Now open mail.php located in /config/mail.php.

Edit the file as below:

<?php
return [ 
        
        'driver' => 'smtp',
        
        'host' => 'smtp.pepipost.com',
        
        'port' => 587,
        
            'encryption' => 'tls', 
        
        'username' => 'pepipostUsername',
        
        'password' => 'pepipostPassword',
        
        'sendmail' => '/usr/sbin/sendmail -bs' 
];

#Step 3 – Send emails the way you want

Lets's create some textarea, and the text entered will be sent as a mail when an valid email is entered, check the form below,

<form class="w3-container" action="sendemail" method="POST"
            role="email">
            {{ csrf_field() }}
            <p>
                <label>Enter Some Text</label>
                <textarea class="w3-input" type="text" name="message"></textarea>
            </p>
            <p>
                <label>Email</label> <input class="w3-input" type="email"> <input
                    type="submit" name="toEmail" class="w3-btn w3-orange" value="Send">
            </p>
        </form>

and create another form just with email field.

<form class="w3-container" action="sendemail" method="POST"
            role="email">
            {{ csrf_field() }}
            <p>
                <label>Email</label> <input class="w3-input" name="toEmail" 
                                    type="email">
            </p>
            <p>
                <input type="submit" class="w3-btn w3-orange" value="Send">
            </p>
        </form>

When the send button is clicked route it to the following function.

Route::any ( 'sendemail', function () {
    if (Request::get ( 'message' ) != null)
        $data = array (
                'bodyMessage' => Request::get ( 'message' ) 
        );
    else
        $data [] = '';
    Mail::send ( 'email', $data, function ($message) {
        
        $message->from ( '[email protected]', 'Just Laravel' );
        
        $message->to ( Request::get ( 'toEmail' ) )->subject ( 'Just Laravel demo email using Pepipost' );
    } );
    return Redirect::back ()->withErrors ( [ 
            'Your email has been sent successfully' 
    ] );
} );

and the view for the emails which we are going to be send be like.

<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
</head>
<body>
    <h2>Demo mail from JustLaravel</h2>
 
    @if(isset($bodyMessage))
    <div class="w3-container w3-orange">
 
        <p>
            <b>The data you have entered is :</b><span
                style="color: #e36c39; background: #EEE";> {{ $bodyMessage }}</span>
 
        </p>
 
    </div>
    @endif
</body>
</html>

For any help visit : Pepipost Help Center

Last updated 7 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.