0
votes

I have a laravel 5.8 on the AWS lightsail instance then when sending email it works perfectly on localhost but not on live server. I have also two laravel 5.2 application that can send email on each instance server in AWS lightsail and it works well. Then my problem is when i try to used laravel 5.8 it doesnt send email using smtp. I'm running php 7.1 on centos 7 with nginx. I don't get an error too.

I tried to telnet smtp.muumuu-mail.com with 25,587,465 , the respond is okay. that is also the smtp that i used both laravel 5.2 application and it works okay.

I tried also putting my configuration on config/mail.php but it doesn't work too.

This is my .env file

MAIL_DRIVER=smtp
MAIL_HOST=smtp.muumuu-mail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=null

This is the code i used for sending email

 Mail::send('main\mail',['data' => $data], function($msg) use($data) {

            $msg->to('[email protected]');
            $msg->subject('this is a sample');
 });
1

1 Answers

0
votes

this is for sending on gmail. this will help you. .env

MAIL_DRIVER=sendmail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls

Here is email store controller

public function store(SendEmailRequest $request)

{
    $data = [
        'email'=>$request->email,
        'subject'=>$request->subject,
        'message'=>$request->message
    ];
    // sending email
    Mail::to('[email protected]')->send(new ContactMail($data));
    session()->flash('success' , 'Thanks For Contacting! We Will Right Back Soon');
    return redirect()->back();
}