Support the ongoing development of Laravel.io →
posted 4 years ago
Laravel Mail

Hi, I am new to Laravel and trying to setup the mail functionality. I opened a mailtrap.io account for this and used my credentials in the .env config

MAIL_MAILER=smtp

MAIL_HOST=smtp.mailtrap.io

MAIL_PORT=2525

MAIL_USERNAME=xxxxxxx//replaced with my true username

MAIL_PASSWORD=xxxxx//replaced with my true password

MAIL_ENCRYPTION=tls

MAIL_FROM_ADDRESS=test@example.com

MAIL_FROM_NAME="${APP_NAME}"

I created a mailable named WelcomeMail.php

namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class WelcomeMail 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->markdown('emails.welcome');
}

}

and a view welcome.blade.php

@component('mail::message')
# Hello from my site on Laravel
The body of your message
Thanks,<br>
{{ config('app.name') }}
@endcomponent

then I added a route to web.php

 Route::get('/email', function () {
     Mail::to('me@mydomain')->send(new WelcomeMail());
     return 'done';
 });

I restarted the server visited localhost:8000/email and I got this

Swift_TransportException
Expected response code 354 but got an empty response
http://localhost:8000/email 

The trouble is the same when I use other servers like gmail or the one of my personal hosting.

Could somebody help me finding out what's happening?

Last updated 3 years ago.
0

I must say that I am trying everything from my own computer using the laravel enbedded server. Eventually I managed to meet success 1 with smtp.mailtrap.io using port 465 with tls encryption (simulated mails) 2 with my personnal email service provider (smtp.mailbox.org) using 465 and tls (acutal mails)

telnet has been of some use to check the connection to the server.

0

Sign in to participate in this thread!

PHPverse

Your banner here too?

José Fournier jaaf Joined 30 Aug 2020

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.