I know this question has been asked many times before, but I have attempted a lots of these solutions without any success.
Hello i have issue in sending mail to laravel as its working fine but after migrating site to other server with ssl and now having issue as its giving below error.
Expected response code 220 but got code \"\", with message \"\"
below is the code used for .end and mail.php
.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=myemail#gmail.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
mail.php
<?php
return [
'driver' => env('MAIL_DRIVER'),
'host' => env('MAIL_HOST'),
'port' => env('MAIL_PORT'),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'developer.eww#gmail.com'),
'name' => env('MAIL_FROM_NAME', 'GBAN'),
],
'encryption' => env('MAIL_ENCRYPTION','tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/lib/sendmail -i -t',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
Related
My email set up works well and send emails using my mailtrap set up but when I change the .env and mail.php file to that of Mailgun it does not sends the email. I only get a success message without any email. The emails I am using for testing are verified in my mailgun accounts
.ENV
MAIL_MAILER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=postmaster#sandboxaf*********.mailgun.org
MAIL_PASSWORD=3b0d1862f55dcb18c62b***********
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=test#gmail.com
MAIL_FROM_NAME="${APP_NAME}"
MAIL_SECRET=53774448859c1ffa6fad57b4a8*****************
MAIL_DOMAIN=sandboxaf49fa3222d1441e8*********.mailgun.org
MAIL_PASSWORD=3b0d1862f55dcb18c62bf***************
Mail.php
'default' => env('MAIL_MAILER', 'mailgun'),
'mailers' => [
'smtp' => [
'transport' => 'mailgun',
'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',
],
]
Controller
Mail::to($request->email)->send(new PasswordResetMail($code,$url));
if (Mail::failures()) {
return response('failure');
}
else{
return response('success');
}
Have tried working on the suggestions from this
linkEmail Not Being Sent in Laravel 8 using Mailgun APIand this linkMailgun emails not sending from Laravel 8 Valet app as well as other links without any success
This question already has answers here:
Laravel certificate verification errors when sending TLS email
(2 answers)
Closed 2 years ago.
I'm trying to send a mail from my localhost laravel 8 app using Gmail SMTP after entering the configurations but keep getting
Swift_TransportException
Connection could not be established with host smtp.gmail.com :stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
I have turned on the Less Secure App settings on my gmail and even downloaded cacert.pem and added the location to my php.ini but it just keeps loading after submitting the form and then giving me the above error. What do I need to do to get it to work?
Here are my related .env file settings
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=mygmailaddress
MAIL_PASSWORD=******
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=mygmailaddress
MAIL_FROM_NAME="${APP_NAME}"
mail.php
'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'),
],
],
];
php.ini
openssl.cafile=C:\wamp64\ssl\cacert.pem
openssl.capath=C:\wamp64\ssl
Maybe I'm supposed to change something in my mail.php file? Or just one of the fields in the php.ini should be present?
I've tried to change the smtp mail host, port and encryption to smtp.gmail.com, 465, and ssl in mail.php respectively, but that didn't work either. Neither did changing .env port to 587 and encryption TLS. What am I missing? Please help.
Fairly new to Laravel though, please be nice lol.
Can you try to change MAIL_PORT=587 . After than you need to give permission in your account to Less secure apps.
I develop a laravel app and I want to automatically send emails with remainder to users.
I created command like in this article. But I get this error:
[Illuminate\Contracts\Container\BindingResolutionException]
Unresolvable dependency resolving [Parameter #0 [ <required> $config ]] in
class RollbarNotifier
This is my code:
.env
MAIL_DRIVER=smtp
MAIL_HOST=example.com
MAIL_PORT=465
MAIL_USERNAME=noreply#example.com
MAIL_PASSWORD=PAssWord
MAIL_ENCRYPTION=SSL
MAIL_FROM_ADDRESS=noreply#example.com
MAIL_FROM_NAME="FROM FROM"
ROLLBAR_TOKEN=<my_token>
config/mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'example.com'),
'port' => env('MAIL_PORT', 465),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'noreply#example.com'),
'name' => env('MAIL_FROM_NAME', 'FROM FROM'),
],
'encryption' => env('MAIL_ENCRYPTION', 'SSL'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
It looks like your dependency injection is not working. It is missing a configuration file.
I am not sure which package you are using. But when I look at the installation manual at https://github.com/jenssegers/laravel-rollbar I see you also have to add some configuration in the services.php:
'rollbar' => [
'access_token' => env('ROLLBAR_TOKEN'),
'level' => env('ROLLBAR_LEVEL'),
],
I am using smtp protocol to send mails using mailtrap. It is working perfectly in localhost but it is giving error.
Symfony\Component\Debug\Exception\FatalThrowableError Type error: Too
few arguments to function Illuminate\Support\Manager::createDriver(),
0 passed in
public_html/vendor/laravel/framework/src/Illuminate/Support/Manager.php
on line 88 and exactly 1 expected
.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=name
MAIL_PASSWORD=pass
MAIL_ENCRYPTION=null
mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailtrap.org'),
'port' => env('MAIL_PORT', 2525,
'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'),
],
],
];
First: Make Sure that you have mail.php and services.php in config folder set
with the following respectively:
mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailtrap.org'),
'port' => env('MAIL_PORT', 2525,
'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'),
],
],
];
And services.php (note that this includes the mailgun configuration)
<?php
return [
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
],
'ses' => [
'key' => env('SES_KEY'),
'secret' => env('SES_SECRET'),
'region' => 'us-east-1',
],
'sparkpost' => [
'secret' => env('SPARKPOST_SECRET'),
],
'stripe' => [
'model' => App\User::class,
'key' => env('STRIPE_KEY'),
'secret' => env('STRIPE_SECRET'),
],
];
ADD THIS ON YOUR boostrap/app/php file
$app->configure('mail'); // this is to configure the mail
$app->configure('services'); // and to configure the services
//$con = env('MAIL_DRIVER');
// dd($con);
dd(config('mail')); // this is to print the mail configuration so you can know what mail configuration are being read.
return $app;
run php artisan serve within the terminal
just to see the contents of the mail configuration.
PLEASE NOTE
I Noticed that the simple fix is to just UPDATE/MODIFY THE .env file with the credentials(using gmail smtp server as example)
MAIL_DRIVER_=smtp (instead of MAIL_DRIVER, update it the mail.php)
MAIL_HOST_=smtp.gmail.com (instead of MAIL_HOST)
MAIL_PORT_=587
MAIL_USERNAME=youremail#domain.com
MAIL_PASSWORD=yourpassword
MAIL_ENCRYPTION=tls
MAILGUN_DOMAIN=
MAILGUN_SECRET=
After that, if you were already running your server. Kill it and rerun it again. This should solve your errors,
REASON
For reasons I couldn't explain, some of the mail config parameter didn't reflect until I applied the change above.
Secondly I later changed the .env settings to the original name eliminating the extra "_" as well as updated the mail.php, and had to kill the already running server and rerun it again before it reflected and ran well or worked!.
Hope this helps
I have just moved my laravel 5.5 website to a server (digitalocean, debian9). For some reason emails wont get sent from my server and I'm not getting any errors.
.env:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAILGUN_DOMAIN=MYDOMAIN
MAILGUN_SECRET=key-SECRET_KEY
MAIL_USERNAME=MYUSERNAME
MAIL_PASSWORD=MYPASSWORD
MAIL_ENCRYPTION=tls
config/mail.php:
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'MY_EMAIL'),
'name' => env('MAIL_FROM_NAME', 'NAME'),
],
'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'),
],
],
];
config/services.php:
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
],
send mail controller:
public function sendMail( $id, Request $request )
{
$user = User::find($id);
$data = [
'subject' => $request->subject,
'bodyMessage' => $request->message,
'image' => $request->image,
];
Mail::to($user->email)
->send(new test($data));
Session::flash('email', 'Message !');
return back();
}
I looked through my UFW firewall and i couldn't see anything related to mail getting blocked.
My email Service (mailgun) doesn't output anything in the logs when i try to send a mail. So I guess its not even reaching them.
I have no idea what to do at this point. I don't even know where I should look for the problem, is it a server problem? laravel problem? firewall problem?...
Would really appreciate some help!
Well, you can check several things :
• Is your production .env correct ?
• Have you make a composer-install recently ?
• Are you sure the php versions of your dev and prod environnement are the same ? because Swift Mailer requires PHP 7.0 or higher (proc_* functions must be available).
I have no idea why it didn't work, feels like i tried everything. Ended up using PHPMailer instead, which worked fine.