class ContactMail extends Mailable
{
use Queueable, SerializesModels;
public $details;
/**
* Create a new message instance.
*/
public function __construct($object)
{
$this->details = $object;
}
/**
* Get the message envelope.
*/
public function envelope(): Envelope
{
return new Envelope(
from: new Address($this->details['from'], $this->details['name']),
subject: $this->details['subject'],
);
}
/**
* Get the message content definition.
*/
public function content(): Content
{
return new Content(
text: $this->details['content'],
);
}
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
*/
public function attachments(): array
{
return [];
}
}
The configuration in the .env file and the code in the RegisterUserController and ContactMail classes look correct for setting up mail using SMTP with SSL encryption. However, it's important to ensure that the credentials provided in the .env file are correct and that the SMTP host is reachable from the server where the application is running.
To test if the mail setup is working, you can try sending a test email using the tinker REPL:
php artisan tinker
Then, run the following command to send a test email:
Connection could not be established with host "mailpit:1025": stream_socket_client(): php_network_getaddresses: getaddrinfo for mailpit failed: No such host is known.
Also I cannot find any reference to mailpit:1025 in my app.