0

I am unable to send a test mail. I am using laravel php.

my .env file:

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=ca**********4b
MAIL_PASSWORD=04**********7b
MAIL_ENCRYPTION=tls

my mail.php:

'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'mailtrap.io'),
'port' => env('MAIL_PORT', 2525),
'from' => ['address' =>'******@gmail.com', 'name' => '****'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('ca**********4b'),
'password' => env('04**********7b'),
'sendmail' => '/usr/sbin/sendmail -bs',

my controller:

<?php

namespace App\Http\Controllers;

use Request;
use Response;
use App\Users;
use Mail;

class MailController extends Controller
{
public function basic_email(){
  $data = array('name'=>"Virat Gandhi");

  Mail::send(['text'=>'welcome'], $data, function($message) {
     $message->to('******@gmail.com', '*****')->subject
        ('Laravel Basic Testing Mail');
     $message->from('"******@gmail.com','Virat Gandhi');
  });
  return "Basic Email Sent. Check your inbox.";
    }
  }

i am getting this error:

Swift_TransportException in AbstractSmtpTransport.php line 383: Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required "

tried clearing cache by php artisan config:cache

what do i need to try more?

6
  • 1
    in .env file, use MAIL_PORT=587 instead of 2525,in mail.php file use 'port' => env('MAIL_PORT', 587),'username' => env('MAIL_USERNAME'),'password' => env('MAIL_PASSWORD'), Commented Sep 18, 2016 at 3:05
  • thank you @Borna changing username and password did the trick. The port had to be 2525. Commented Sep 18, 2016 at 8:20
  • great..can u mark my comment useful?? then it will be useful for other users Commented Sep 18, 2016 at 8:39
  • how can i do that? i cant find any options. @Borna Commented Sep 18, 2016 at 9:26
  • put your mouse on my comment,then u will see flag and uparrow,then click uparrow Commented Sep 18, 2016 at 9:41

1 Answer 1

1

I believe it's gonna be firewall issue, have you tried to connect to gmail provider ? it's a good way to catch the error

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your help! but i solved it the other way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.