I am following this link https://lumen.laravel.com/docs/5.7/mail
here is my bootstrap/app.php code
$app->withFacades();
$app->withEloquent();
$app->register(\Illuminate\Mail\MailServiceProvider::class);
$app->configure('services');
$app->configure('mail');
$app->alias('mailer', Illuminate\Mail\Mailer::class);
$app->alias('mailer', Illuminate\Contracts\Mail\Mailer::class);
$app->alias('mailer', Illuminate\Contracts\Mail\MailQueue::class);
I run below code as well
composer require illuminate/mail
composer update
Here is my .env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=abc#gmail.com
MAIL_PASSWORD=Abc#12345
MAIL_ENCRYPTION=tls
I installed fresh lumen and i am sure i did not missed anything.
I am getting this error
Unable to resolve NULL driver for [Illuminate\Mail\TransportManager].
The problem. you need to add config file for mail. (config/mail.php)
Just Copy Laravel mail.php config file to lumen root_dir/config/mail.php
Reference THIS LINK
Related
env file parameters:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=<emailadress>
MAIL_PASSWORD=<password>
MAIL_ENCRYPTION=ssl
system Features:
PHP 7.4.33
Composer version 1.10.26
I am waiting mail in MailBox. But it is giving error.
i wanted to use mail in laravel 8 with Laravel Jetstream but I encountered a lot of problems i try use ssl and tsl ,change port 2525,587,465 but also it didnot work
so the perfect answer was as follwing
just set my env as:
```
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=haidarfmgphp#gmail.com
MAIL_PASSWORD=***********
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=haidarfmgphp#gmail.com
MAIL_FROM_NAME=fmg
```
and go to this file:
C:\xampp\htdocs\itis_db\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php
exactly in
private function _establishSocketConnection()
and paste these two lines
$options['ssl']['verify_peer'] = FALSE;
$options['ssl']['verify_peer_name'] = FALSE;
but the problem now is the mail read message as a spam
Hint: i work from local host
I use Lumen7 (based on Laravel7) as framework for my projekt. I tried to install the mailer, but it doesn't work.
I did the following steps:
Installed illuminate/mail via composer require illuminate/mail:7
Added the following to bootstrap/app.php
$app->register(Illuminate\Mail\MailServiceProvider::class);
$app->configure('mail');
$app->alias('mail.manager', Illuminate\Mail\MailManager::class);
$app->alias('mail.manager', Illuminate\Contracts\Mail\Factory::class);
$app->alias('mailer', Illuminate\Mail\Mailer::class);
$app->alias('mailer', Illuminate\Contracts\Mail\Mailer::class);
$app->alias('mailer', Illuminate\Contracts\Mail\MailQueue::class);
Copied the mail.php from
https://github.com/laravel/laravel/blob/master/config/mail.php to
config/mail.php
Added the following to my .env
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=hello#example.com
MAIL_FROM_NAME="Example app"
When I try to generate my mailable via php artisan make:mail MyMailable, then I get the following error: Command "make:mail" is not defined.
When I use php artisan, then I don't see mail in the command list of make, just the following make commands:
make
make:migration Create a new migration file
make:seeder Create a new seeder class
I have no idea what the issue is, hopefully someone can help me.
I think I've found a way to achieve this. Apparently Lumen needs another package installed to have all the Laravel methods. Simply add the composer package:
composer require flipbox/lumen-generator
And enable it in your bootstrap/app.php file:
$app->register(Flipbox\LumenGenerator\LumenGeneratorServiceProvider::class);
Afterwards your "php artisan" should return way more methods, also for "make:mail".
I've a very strange issue sending SMTP email from Laravel
Mail::raw('Email body', function ($message) use ($filename) {
$message->from('sender#email.com', 'Ordini')
->to('user#email.com')
->subject('subject')
->attach(storage_path($filename));
});
This code actually works within server's tinker environment but it doesn't when it's executed within controller.
I've double checked .env and config/mail.php, everything is fine
The server mail is my client's smtp mail server
I also tried without any attachment
The response is "Expected response code 250 but got an empty response"
I can't figure out why it works in tinker while it doesn't in app. What's the difference?
Thanks in advice
Make sure your you have not enabled two step authentication on your gmail and you have allowed less secured apps on your google account
After Checking all that Just try to run command
php artisan config:clear
php artisan cache:clear
php artisan view:clear
Make sure your env file contain these info
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=your_email
MAIL_PASSWORD=your_password
MAIL_ENCRYPTION=tls
And then
Instead of your mail code code try like this
Mail::raw('Email body', function ($message) use ($filename) {
$message->from('sender#email.com', 'Ordini');
$message->to('user#email.com');
$message->subject('subject');
$message->attach(storage_path($filename));
});
Check in the config/mail.php
If it is getting every thing from env or not if not make changes in config file
I use Laravel 5.1 and want to send the admin of the page a mail with the content of a contact form.
In my .env file I added the following lines:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=admintest#gmail.com
MAIL_PASSWORD=adminpassword
MAIL_ENCRYPTION=tls
In my controller I have the following:
Mail::send('Site::email', ['contactObject' => $contactObject], function ($message) use ($contactObject) {
$message->from($contactObject->email, $contactObject->vorname)->subject('New contact!');
$message->to('admintest#gmail.com');
});
$contactObject == contains the form which was filled out in the form from the user
Desired result:
When admintest#gmail.com receive a email, the sender of the mail should be $contactObject->email
Actual result:
When admintest#gmail.com receive a email, the sender of the mail is admintest#gmail.com
Any ideas what goes wrong? Thank you
Try This:
In Live server you have no need to configure any type of mail service.
You have to just use this:
MAIL_DRIVER=mail
AND remove this code:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=admintest#gmail.com
MAIL_PASSWORD=adminpassword
MAIL_ENCRYPTION=tls
You have to just use in .env file:
MAIL_DRIVER=mail
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=xyz#gmail.com
MAIL_PASSWORD=yourpassword
MAIL_ENCRYPTION=tls
After change in .env file, restart service, or use command php artisan config:cache and php artisan config:clear.
Have you configured the global from address in the config?
Specifically here: https://github.com/laravel/laravel/blob/master/config/mail.php#L49
Chances are that you've set that and it's just using that, making these values blank should let you override it.
Failing that, because you're using Gmail to send an email to Gmail, it's likely not letting you spoof the from and is indeed a security feature on their end.