我遇到的错误,“最大执行时间为60秒”。当我在Laravel使用邮件时

发布于 2025-02-13 19:28:39 字数 1905 浏览 0 评论 0原文

时,我会遇到“超过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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尾戒 2025-02-20 19:28:39

要解决此问题,您可以更改.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文