email not working in prod although exception storing in db
momame opened this issue · 13 comments
Hi
I configured everything fine and even the exceptions saves in "vendor_tylercd100_lern_exceptions" table. In local-host (xamp server) it simply sends emails without any problem, but not working in prod!
can Anyone help???!!!
Hey Mo,
I'm very sorry but I just got back from vacation yesterday and did not see your request for help until now.
Is your configuration set to use native mail or SMTP?
if smtp is false then you will need to properly install the recommended packages for sending native mail on you production machine
if smtp is true then you will need to properly configure your smtp settings found in config/mail.php
Hi Tyler,
I checked config/mail.php It's a SMTP,port25 kind. I set the parameters in lern.php as well.
/**
* mail, pushover, slack, etc...
*/
'drivers'=>['mail'],
/**
* Mail settings
*/
'mail'=>[
'to' => 'xyz@xyz.com',
'from' => 'xyz@xyz.com',
'smtp' => true,
],
what else should I do?
What version of Laravel are you using?
What are you using for your SMTP server?
Have you tried using a tool like https://mailtrap.io/ for email testing?
Also check this out for more help with sending mail with laravel
https://laravel.com/docs/5.4/mail#mail-and-local-development
well SMTP server is our default config in our project and in other module, mailing works fine, we don't want to use mailtrap in production. but mailtrap works in localhost like I mentioned before
what do you think?
Thanks
So, SMTP works just fine in production for your other emails? What version of Laravel are you using?
We are using the version 5.3.30
Hey Mo,
So I found some time to test it out on 5.3.30 and I am having no issues getting it to send an email using SMTP.
Can you try verifying your mail settings for production? config/mail.php
Still I have the problem
this is part of my code in handler.php
protected $dontReport = [
\Illuminate\Auth\AuthenticationException::class,
\Illuminate\Auth\Access\AuthorizationException::class,
\Symfony\Component\HttpKernel\Exception\HttpException::class,
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
\Illuminate\Session\TokenMismatchException::class,
\Illuminate\Validation\ValidationException::class,
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $exception
* @return void
*/
public function report(Exception $e)
{
if ($this->shouldReport($e)) {
//Check to see if LERN is installed otherwise you will not get an exception.
if (app()->bound("lern")) {
app()->make("lern")->handle($e); //Record and Notify the Exception
/*
OR...
app()->make("lern")->record($e); //Record the Exception to the database
app()->make("lern")->notify($e); //Notify the Exception
*/
}
}
//parent::report($e);
return parent::report($e);
}
recently after some manipulation sometimes when Laravel throwing error it says undefined index to !
which seems has to with static function nativeMail in MonologHandlerFactory.php line 352. Therefore it means it wants to use nativeMail function but like I said our mailing is smtp
By the way our user/pass is null in production
MAIL_DRIVER=smtp
MAIL_HOST=xx.xx.xx.xx
MAIL_PORT=25
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=
It is fixed now our smtp configuration was not good. thanks anyway