Controller:
$sent = Mail::to('[email protected]')->send(new Welcome($name, $email, $phone, $msg));
.send:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.dominio.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
View:
<h3>Contacto Web</h3>
<br>
<br>
<b>Nombre:</b> {{$name}}
<br>
<b>Email:</b> {{$email}}
<br>
<b>Teléfono:</b> {{$phone}}
<br>
<b>Mensaje:</b> {{$msg}}
Mailable:
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; use Illuminate\Contracts\Queue\ShouldQueue;
class Welcome extends Mailable {
use Queueable, SerializesModels;
/**
* @var
*/
public $name;
public $email;
public $phone;
public $msg;
/**
* Create a new message instance.
*
* @param $name
* @param $email
* @param $phone
* @param $msg
*/
public function __construct($name, $email, $phone, $msg)
{
$this->name = $name;
$this->email = $email;
$this->phone = $phone;
$this->msg = $msg;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$address = '[email protected]';
$dest_name = 'Web';
$subject = 'Contacto Web';
return $this->view('emails.welcome')
->to($address, $dest_name)
->from($this->email, $this->name)
->subject($subject);
} }
In theory this code worked for me until now and suddenly it has stopped sending emails, it does not show any error. I've tried changing the send to queue and it doesn't change anything. I don't know what else to try, I have created a new mailable and the same thing.
Version: Laravel 5.4