Mail Queue processed but the Laravel don't send email - laravel

The Mail::queue method processes the service but does not send the mail.Nothing arrives in the destination email. The redis is working normally.
$data = ['nome_prefeitura'=>$gestora->pessoa->nome,'empresa'=>$n->economico->pessoa->nome,'pessoa'=>$n->pessoa->nome,'link'=>$link,'nome_secretaria'=>'Secretaria Fazenda de Dom Joaquim.'];
Mail::queue('layout_email.email_nfse', $data, function ($m) use ($n) {
$m->from('nfe#mail.com.br', 'NFS-e');
$m->to($n->email_envio, $n->pessoa->nome)->subject('Notificação de emissão de NFS-e');
});
CACHE_DRIVER=redis
SESSION_DRIVER=redis
QUEUE_DRIVER=redis
MAIL_DRIVER=smtp
MAIL_HOST=mail.com.br
MAIL_PORT=25
MAIL_USERNAME=nfenfe#mail.com.br
MAIL_PASSWORD=****
MAIL_ENCRYPTION=null

I changed my email server and it worked.

Related

I am getting error when i am sending mail in laravel

I am getting error when i am sending mail at gmail id,I am using laravel 5.7,
I am getting this errot
Call to undefined function App\Http\Controllers\send()
and my controller code is :
public function postEmail(Request $r)
{
$data=[
'user_email'=>$r->user_email,
'user_name'=>$r->user_name,
'user_phone'=>$r->user_phone,
'user_desc'=>$r->user_desc,
];
Mail:send('mail.mail', $data, function($user_desc) use($data)
{
$message->from('sumitsaoni#gmail.com', 'Send by Sumit');
$messge->to($data['sumit123#gmail.com']);
$message->subject($data['user_desc']);
});
return redirect()->back()->with('message','successfully data insertd');
}
And My Route is
Route::resource('contact', 'ContactController');
Route::post('/postEmail', 'ContactController#postEmail');
My .env file mail gmail: .env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=my_email (Using my email id)
MAIL_PASSWORD=password (using my email id password)
MAIL_ENCRYPTION=tls
You should try this:
use Mail;
Mail::send('mail', $data, function($user_desc) use($data)
{
$message->from('sumitsaoni#gmail.com', 'Send by Sumit');
$message->to($data['user_email']);
$message->subject($data['user_desc']);
});
Updated answer
Mail::send('mail', $data, function($message) use($data)
{
$message->from('sumitsaoni#gmail.com', 'Send by Sumit');
$message->to($data['user_email']);
$message->subject($data['user_desc']);
});
change
Mail:send('mail.mail', $data, function($user_desc) use($data)
to
Mail::send('mail.mail', $data, function($user_desc) use($data)
try this one
Mail:send to replace Mail::send

Laravel 5.5 Send MAil

I a trying to send an email from localhost to my email but i alwasy get this error
Connection could not be established with host smtp.gmail.com [Une tentative de connexion a �chou� car le parti connect� n�a pas r�pondu convenablement au-del� d�une certaine dur�e ou une connexion �tablie a �chou� car l�h�te de connexion n�a pas r�pondu. #10060]
and i didn't found any solution
this is a screen shot for the error
this is the controller code
public function contact_sent(Request $request)
{
$emails = "mohamedfarjallah8#gmail.com";
$messages = "This body message......";
$subject = "This is subject from email";
$fromEmail = "mohamedfarjallah8#gmail.com";
$data = array('emails'=>$emails,'messages'=>$messages,'fromEmail'=>$fromEmail,'subject'=>$subject);
Mail::send([],$data, function ($message) use ($data) {
$message->from($data['fromEmail'],'SubText that show in header part of email');
$message->to($data['emails'])->setBody($data['messages']);
$message->subject($data['subject']);
$message->replyTo($data['fromEmail'],'Some text you can test this');
});
echo "Ok you can check your email";exit;
}
and this is the .env configuration
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=2525
MAIL_USERNAME=mohamedfarjallah8#gmail.com
MAIL_PASSWORD=**************
MAIL_ENCRYPTION=tls
You are using wrong mail port. Port 2525 is for Mailtrap, for Google it should be 587 for MAIL_PORT

Issue with laravel and mailgun

Have a nice time,
I am wondering if there is anyone has the correct steps for using Mailgun with laravel 5.4
Many thanks and best regards,
These are my steps that i follow.
first open .env file and bellow code:
MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=uremail#gmail.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
create new account in mailgun.com SignUp if you don't have before.
After registeration active your mailgun account and click on Domails
and click on Add New Domail button. then you can see bellow screen.
After add name you can copy domain name and API Key.
Now you have to open services.php and add mailgun configration this
way :
on config/services.php
'mailgun' => array(
'domain' => 'youremail.com',
'secret' => 'key-11796c09e58-056a9e975c96dd334da0dd',
),
Now we are ready to send mail for test so first create test route
for email sending.
app/Http/routes.php define route: Route::get('mail', 'HomeController#mail');
Ok, now add mail function in HomeController.php file so add this way
public function mail()
{
$user = User::find(1)->toArray();
Mail::send('emails.mailEvent', $user, function($message) use ($user) {
$message->to($user->email);
$message->subject('Mailgun Testing');
});
dd('Mail Send Successfully');
}
At last create email template file for send mail so let's create mailEvent.blade.php file in emials folder.
resources/views/emails/mailEvent.blade.php`

Send email from lumen

I am using vue.js as my front end and Lumen as my api service. Now I need to send emails from lumen. This is what i did for this.
.env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=********#gmail.com
MAIL_PASSWORD=**********
MAIL_FROM_ADDRESS=******#gmail.com
MAIL_FROM_NAME=Sample Email App
MAIL_ENCRYPTION=tls
and then edited the file bootstrap\app.php and uncommented the following lines.
$app->register(App\Providers\AppServiceProvider::class);
$app->withFacades();
Dotenv::load(__DIR__.'/../');
$app->withEloquent();
In the controller, I have used the following code
use Illuminate\Support\Facades\Mail;
private function sendActivationEmail( $email = null ){
$email_sent = false;
if( $email != null ){
// send email
Mail::raw('Raw string email', function($msg) {
$msg->to(['tismon#gmail.com']); $msg->from(['x#x.com']);
});
}
return $email_sent;
}
Unfortunately, this is not working. Can anyone tell me where I went wrong ?
Register MailServiceProvider in bootstrap/app.php file
$app->register(\Illuminate\Mail\MailServiceProvider::class);
$app->configure('mail');
try adding below code to AppServiceProvider.php within register function
$this->app->singleton('mailer', function ($app) {
$app->configure('services');
return $app->loadComponent('mail', 'Illuminate\Mail\MailServiceProvider', 'mailer');
});
if not working After the above configuration, try Mail send function
Mail::send('user.emails.registration' , $data, function($msg) use ($to,$from,$subject)
{
$msg->to($to)->from($from)->subject($subject);
});

Laravel forgot password emails not being sent

I have an extremely odd issue with Laravel emails.
Generally speaking I can send emails fine like so:
Mail::send('foo', $templateData,
function (Message $message) use ($name, $email) {
$message
->from('admin#example.com', 'My Example Company')
->to($email, $name)
->subject('Blah');
}
);
However, when trying to reset password, an email is not sent on my production server, despite acting like it has sent (i.e. no exceptions!). It is however sent when using mailtrap.io.
This is how my .env file looks like:
APP_ENV=prod
APP_KEY=XXXX
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://example.co.uk
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=XXX
DB_USERNAME=XXX
DB_PASSWORD=XXX
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=XXX
MAIL_PORT=XXX
MAIL_USERNAME=XXX
MAIL_PASSWORD=XXX
MAIL_ENCRYPTION=ssl
MAIL_FROM=admin#example.com
MAIL_FROM_NAME="My Example Company"
GOOGLE_API_KEY=XXX
I also tried:
composer dump-autoload
php artisan clear-compiled
php artisan config:clear
But to no avail.
Interestingly, when I use Mailer as opposed to the Mail facade, the email is again not sent with no exceptions raised.
public function foo(Illuminate\Mail\Mailer $mailer)
{
$mailer->send('ViewName', [],
function (Message $message) {
$message
->from('admin#example.com', 'My Example Company')
->to('you#example.com', 'John Smith')
->subject('Blah');
}
);
}

Resources