i'm tring to send test email using mailtrap but i get this error:
Trying to access array offset on value of type null in file...
my env file:
MAIL_MAILER=smtp MAIL_HOST=sandbox.smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=//myusername MAIL_PASSWORD= //mycode MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS="[email protected]"
my controller
use Illuminate\Support\Facades\Mail;
class RespController extends Controller{
//code...
Mail::to('[email protected]')->send(new PasswordMail()); // the problem on this lign
}
PasswordMail:
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class PasswordMail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*/
public function __construct(){
}
/**
* Get the message envelope.
*/
public function envelope(): Envelope
{
return new Envelope(
subject: 'identifiants de connexion',
);
}
/**
* Get the message content definition.
*/
public function content(): Content
{
return new Content(
view: 'PasswordMailContent',
);
}
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
*/
public function attachments(): array
{
return [];
}
}
PasswordMailContent is just normal html file with h1 element
my error trace:
im not allowed to post links on my first day here:
some of my error trace:
#0 C:\xampp\htdocs\gs-backend\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php(256): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Trying to acces...', 'C:\\xampp\\htdocs...', 91) #1 C:\xampp\htdocs\gs-backend\vendor\symfony\mailer\Transport\Smtp\Stream\AbstractStream.php(91): Illuminate\Foundation\Bootstrap\HandleExceptions->Illuminate\Foundation\Bootstrap\{closure}(2, 'Trying to acces...', 'C:\\xampp\\htdocs...', 91) #2 C:\xampp\htdocs\gs-backend\vendor\symfony\mailer\Transport\Smtp\SmtpTransport.php(341): Symfony\Component\Mailer\Transport\Smtp\Stream\AbstractStream->readLine() #3 C:\xampp\htdocs\gs-backend\vendor\symfony\mailer\Transport\Smtp\SmtpTransport.php(196): Symfony\Component\Mailer\Transport\Smtp\SmtpTransport->getFullResponse() #4 C:\xampp\htdocs\gs-backend\vendor\symfony\mailer\Transport\Smtp\EsmtpTransport.php(118):