英文:
laravel verify emaIl error smtp 550. how to handle this error?
问题
用户已注册,并发送邮件确认帐户。
响应代码为250,但得到代码为550,邮箱无效。同时,Web服务器出现错误500,。
如何处理此错误并向用户显示其电子邮件不存在?
我的.env文件的一部分:
MAIL_MAILER=smtp
MAIL_DRIVER=smtp
MAIL_HOST=smtp.dmd120.com
MAIL_PORT=465
MAIL_USERNAME=noreply@dmd120.com
MAIL_PASSWORD=pass
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=noreply@dmd120.com
MAIL_FROM_NAME="${APP_NAME}"
我理解这是一个SMTP服务器错误。确实,该邮箱不存在。如何向用户报告此错误(处理错误)?目前,在执行此操作时,Laravel返回500错误。
英文:
the user is registered and mail is sent to confirm the account
response code 250, but got code 550
invalid mailbox
and i have error 500 with web server
how to handle this error and show the user that his email does not exist?
part of my .env
MAIL_MAILER=smtp
MAIL_DRIVER=smtp
MAIL_HOST=smtp.dmd120.com
MAIL_PORT=465
MAIL_USERNAME=noreply@dmd120.com
MAIL_PASSWORD=pass
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=noreply@dmd120.com
MAIL_FROM_NAME="${APP_NAME}"
I understand that this is an smtp server error. And indeed this mailbox does not exist. How do I report this to the user (handle the error)? now, when performing this action, laravel issues error 500
答案1
得分: 0
在app/Exceptions/Handler.php中添加以下函数:
public function render($request, Throwable $e)
{
if ($e instanceof TransportException){
return response()->view('errors.550',[],550);
}
return parent::render($request, $e);
}
然后在resources/views/errors/目录下添加550.blade.php视图文件,其中包含您的错误文本和向用户显示的文本。
然后大家都开心
英文:
I tell you how to handle the error, I found the solution myself:
in app/Exceptions/Handler.php add function
public function render($request, Throwable $e)
{
if ($e instanceof TransportException){
return response()->view('errors.550',[],550);
}
return parent::render($request, $e);
}
add view resources/views/errors/550.blade.php with you text error and text to user
and everyone is happy
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论