I can't understand what's going on. I am working on a project for a month now and I've been using Mailtrap almost each day. just yesterday it was working perfectly, but now when I send an email, the page keeps loading until I get the message that says "Maximum execution time of 60 seconds exceeded" but nothing shows up in the Mailtrap inbox.
The error message I am getting is also unreasonable because the $recipient
variable contains only a single email address, and one single email won't take a whole minute to be sent.
my .env file:
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME= [hidden]
MAIL_PASSWORD= [hidden]
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=hello@example.com
MAIL_FROM_NAME="${APP_NAME}"
mailController.php:
Mail::to($recipient)->send(new \App\Mail\InvitationMail($data[$userIndex],$recipient,$status,$invitation,$event,$Campaign))
->attach(public_path($invitation["attachmentPath"]),['as' => $invitation['attachmentName']]);
sleep(2);
App\Mail\InvitationMail:
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class InvitationMail extends Mailable
{
use Queueable, SerializesModels;
public $emailOfthisRecipient;
public $CampaignStatus;
public $invitationData;
public $eventData;
public $campaignData;
public $dataRecipient;
public function __construct($data,$recipient,$status,$invitation,$event,$Campaign)
{
$this->dataRecipient = $data; //^ done
$this->emailOfthisRecipient = $recipient; //^ done
$this->CampaignStatus = $status; //^ done
$this->invitationData = $invitation; //^ done
$this->eventData = $event; //^ done
$this->campaignData = $Campaign;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->subject('Event Invitation')->view('emails.InvitationMail');
}
}
I solved it guys. The problem was that I am an intern in an agency, and their network was blocking smtp requests. When I returned home, I tested it and it worked like a charm