简体   繁体   English

Laravel记录电子邮件

[英]Laravel logging email

Is it possible to somehow see the email log from my Laravel application? 是否有可能以某种方式从我的Laravel应用程序中看到电子邮件日志? I have a contact form and some emails might be lost since the wrong email-address was set for a while, so I want to know if I can see who tried to email me? 我有一个联系表格,一些电子邮件可能会丢失,因为错误的电子邮件地址设置了一段时间,所以我想知道我是否可以看到谁试图给我发电子邮件?

The logs are found in application/storage/logs and the file is called: 日志位于应用程序/存储/日志中,并调用该文件:

laravel.log laravel.log

For the wrong or invalid email the laravel Email class throw an error, so you have to catch it by using error handling methods ie try and catch like: 对于错误或无效的电子邮件,laravel Email类会抛出错误,因此您必须使用错误处理方法捕获它,即trycatch如下:

try
{
    // Email sending logic here
}
catch (Exception $e) {
    // Exception is catched here
    Log::info('save all the required data here so that you can check it later');    // This will log all the detail that you have passed here
}

Later on you can check the log to get all such entries for which email is failed. 稍后,您可以检查日志以获取电子邮件失败的所有此类条目。

Laravel logs are found in application/storage/logs Laravel日志可在application/storage/logs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM