Email error
Swift_TransportException in AbstractSmtpTransport.php line 383:
Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required
"
so far this is my mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => 'hello#example.com',
'name' => 'Example',
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
];
This is my controller
public function contactstore(Request $request)
{
$data = array_map('trim', $request->all());
$rules = [
'email' => 'required | email',
'name' => 'required',
'msg' => 'required | min:8',
];
$validator = Validator::make($data, $rules);
if ($validator->fails()) {
return redirect()->back()->withErrors($validator)->withInput()->with('error', 'Validation Error.');
}
else {
$data = [
'from' => 'quizmumbai#gmail.com',
'name' => $data['name'],
'email' => $data['email'],
'msg' => $data['msg'],
'view_name' => 'pages.email.querymail',
'to' => 'yogesh696ksingh#gmail.com',
'subject' => 'Event Query for TML 2017',
'timestamp' => date('j/M/Y', time()),
];
Mail::send($data['view_name'], $data, function ($message) use ($data) {
$message->from($data['from'], $data['name']);
$message->to($data['to'])->subject($data['subject']);
});
if (count(Mail::failures()) > 0) {
return redirect()->back()->with('error', 'Cannot send mail');
}
else return redirect()->back()->with('success', 'We will get back to you shortly')->with('message','Thanks for');
}
}
is it because i'm trying on local server?
You must restart your web server to pickup new .env values.
Related
I initially had my mail configuration settings in my .env file pointing to my gmail account and contact form was working fine. I have now changed my settings to point to a webmail and run php artisan config:cache but the mail is still being sent to my gmail. Below is my configuration settings and I've also tested the web mail by sending an email to it via gmail and sending back to gmail from the web mail and it's working fine. Any assistance is highly appreciated.
MAIL_MAILER=smtp
MAIL_HOST=mywebmail
MAIL_PORT=465
MAIL_USERNAME=sales#mydomain
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=sales#mydomain
MAIL_FROM_NAME="Laravel"
PS: My config/Mail.php
<?php
return [
'default' => env('MAIL_MAILER', 'smtp'),
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'auth_mode' => null,
],
'ses' => [
'transport' => 'ses',
],
'mailgun' => [
'transport' => 'mailgun',
],
'postmark' => [
'transport' => 'postmark',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => '/usr/sbin/sendmail -bs',
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
],
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello#example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
The problem was in my controller. I was sending email to my gmail instead of my webmail. I forgot to change that when I changed the mail settings. After changing mygmail to my webmail it works just fine.
public function store(Request $request)
{
$data = $request->validate([
//
]);
Mail::to('mygmail.com')
->send(new ContactMe($data));
return redirect(route('contact-us.index'))->with('flash', "Thank you,
we'll be in touch soon");
}
Error - Missing argument 1 for Illuminate\Support\Manager::createDriver()
My env file-
MAIL_DRIVER=smtp
MAIL_HOST=smtp.****.com
MAIL_PORT=587
MAIL_USERNAME=info#*****.com
MAIL_PASSWORD=******
MAIL_ENCRYPTION=tls
All the keys in mail.php of config folder are correct.
My controller function looks like this
function send(Request $request)
{
$this->validate($request,[
'name'=>'required',
'email'=>'required|email',
'subject'=>'required',
'message'=>'min:10'
]);
$data=array(
'name'=>$request->name,
'email'=>$request->email,
'subject'=>$request->subject,
'bodyMessage'=>$request->message
);
Mail::send('mail.admin',$data,function($message) use ($data)
{
$message->from($data['email']);
$message->to($data['info#****.com']);
$message->subject($data['subject']);
});
}
What mistake am i making here?
Here is my mail.php file
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.****.com'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello#example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs', 'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
I replaced all the settings and codes with my own codes and the email was sent correctly. I suggest removing the composer.lock file and remove the vendor directory and run the composer install again. Maybe the complete package is not installed.
I'm creating a verification email, however the mail isn't going out and I don't receive any errors.
My call to send the email:
public function register(Request $request)
{
$this->validator($request->all())->validate();
event(new Registered($user = $this->create($request->all())));
Mail::to($user->email)
->queue(new VerifyEmail($user));
return $this->registered($request, $user)
?: redirect($this->redirectPath());
}
here's my email build function:
public function build()
{
return $this->view('emails.account.verify_email')
->with([
'id' => $this->user->id,
'firstname' => $this->user->firstname,
'token' => $this->user->email_verification_token,
]);
}
I installed guzzlehttp/guzzle
and changed my files:
ENV (not sure of the port setting)
MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=postmaster#sandbox...655.mailgun.org
MAIL_PASSWORD=Default mailgun sandbox Password
MAIL_ENCRYPTION=tls
config/services
'mailgun' => [
'domain' => env('sandbox...655.mailgun.org'),
'secret' => env('key-...'),
],
config/mail
<?php
return [
'driver' => env('MAIL_DRIVER', 'mailgun'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello#example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
I don't receive any errors, however there are no outgoing mails when I check the mailgun dashboard
Your services config file is wrong:
'mailgun' => [
'domain' => env('sandbox...655.mailgun.org'),
'secret' => env('key-...'),
],
You're trying to look up the values from the .env file here. Should reference the keys, not the values. For instance:
'mailgun' => [
'domain' => env('MAIL_DOMAIN'),
'secret' => env('MAIL_SECRET'),
],
And then add them to your .env file:
MAIL_DOMAIN=sandbox...655.mailgun.org
MAIL_KEY=key-...
I'm assuming the rest is correct but I don't know for certain. :)
I am trying to send a mail using laravel but am getting this error :
"Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required"
This is my mail.php file
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => null, 'name' => null],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
This is where I send my mail from (routes.php)- for testing though.
Route::get('/send', function(){
mail::send('Email.signup', [], function ($message) {
$message->to('mymail#gmail.com', 'example_name');
$message->subject('Welcome!');
$message->from('hello#app.com', 'Your Application');
});
});
Thank you.
I want to send email from my localhost in laravel 5 using driver: smtp and host: smtp.gmail.com
here is my sample code for sending email after successful account open.
public function postRegister(Request $request)
{
$password = PropertyHelper::randomPassword();
$arrUser = [
'_token' => $request->input('_token'),
'name' => $request->input('name'),
'mobile' => $request->input('mobile'),
'email' => $request->input('email'),
'password' => $password,
'password_confirmation' => $password
];
$validator = $this->registrar->validator($arrUser);
if ($validator->fails())
{
$this->throwValidationException(
$request, $validator
);
}
$data = [
'name' => $request->input('name'),
'password' => $password,
'email' => $request->input('email'),
];
$this->auth->login($this->registrar->create($arrUser));
$data = [
'name' => $request->input('name'),
'password' => $password,
];
$emailSend = Mail::send('emails.signup', $data, function($message){
$message->to(Auth::user()->email)
->subject('নতুন একাউন্ট');
});
dd($emailSend); //output 1
if($emailSend)
{
return redirect($this->redirectPath());
}
}
Here is my config/mail.php file
return [
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'from' => ['address' => 'hizbul25#gmail.com', 'name' => 'Admin'],
'encryption' => 'tls',
'username' => 'myEmail#gmail.com',
'password' => 'gmailPassword',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];
This code did not show any error but not also send email. If i try to print the out of email send it says 1. Any idea please ??
try to change the mail info inside .inv under root folder instead of mail.php as previous versions of laravel