我遇到的错误,“最大执行时间为60秒”。当我在Laravel使用邮件时
时,我会遇到“超过60秒的最大执行时间”
我在Laravel中使用邮件 env 这是我从MailTrap
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=307f3b9d88a7bd
MAIL_PASSWORD=20b0d000da4785
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS= [email protected]
MAIL_FROM_NAME="${APP_NAME}"
Route/web.php 复制的ENV文件 它是我的路线
use Illuminate\Support\Facades\Mail;
Route::get('send-mail', function () {
$details = [
'title' => 'Mail from ItSolutionStuff.com',
'body' => 'This is for testing email using smtp'
];
Mail::to('[email protected]')->send(new App\Mail\TestMail($details));
dd("Email is Sent.");
});
资源/视图/emails/mail.blade.php 它是我的刀片
<!DOCTYPE html>
<html>
<head>
<title>rajtechnologies.com</title>
</head>
<body>
<p>Thank you</p>
</body>
</html>
app/mail/testmail.php 这是我的邮件
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class TestMail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->subject('Mail from rajtechnologies.com')->view('emails.mail');
}
}
I am getting error "Maximum execution time of 60 seconds exceeded" when I use mailing in laravel
env
It's my env file which I copy from mailtrap
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=307f3b9d88a7bd
MAIL_PASSWORD=20b0d000da4785
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS= [email protected]
MAIL_FROM_NAME="${APP_NAME}"
route/web.php
Its my route
use Illuminate\Support\Facades\Mail;
Route::get('send-mail', function () {
$details = [
'title' => 'Mail from ItSolutionStuff.com',
'body' => 'This is for testing email using smtp'
];
Mail::to('[email protected]')->send(new App\Mail\TestMail($details));
dd("Email is Sent.");
});
resources/views/emails/mail.blade.php
Its my blade
<!DOCTYPE html>
<html>
<head>
<title>rajtechnologies.com</title>
</head>
<body>
<p>Thank you</p>
</body>
</html>
app/Mail/TestMail.php
Its my mail
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class TestMail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->subject('Mail from rajtechnologies.com')->view('emails.mail');
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要解决此问题,您可以更改.ENV文件中的mail_port。
允许的端口为:
25、465、587和2525
因此,更改mail_port = 587,例如,您的邮件将被发送。
To solve this problem, you can change the MAIL_PORT in your .env file.
The allowed ports are:
25, 465, 587 and 2525
So, change MAIL_PORT=587 for example, your mail will be sent.