我想发送一封包含Laravel的电子邮件。我不确定我做错了什么。
这是我的邮件:
public function __construct()
{
//
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from('test@test.de')
->view('emails.testemail');
}
这是我的控制器:
public function send_email_test(){
Mail::to("my_email@mail.net")->send(new testemail());
}
以下是我尝试测试它的方法:
Route::get('/sendemailtext','testcontroller@send_test_email');
这是错误:
Swift_TransportException in AbstractSmtpTransport.php line 383:
Expected response code 220 but got code "", with message ""
有什么想法吗?
答案 0 :(得分:1)
尝试这样做
$user_email = 'my_email@mail.net';
Mail::send('emails.testemail', array(), function($message) use ($user_email)
{
$message->from('test@test.de', 'From');
$message->to($user_email)->subject('Test mail');
});
答案 1 :(得分:1)
试一试。它应该工作。
<?php
//activation is a blade for email inside emails folder
//$email is destination email ex: my_email@mail.net
//other things are pretty clear, I giess
Mail::send('emails.activation', $data , function($message) use ($email)
{
$message->from('no-reply@mydomain.com', 'Name of Email Sender');
$message->to($email)->subject('Email Subject');
});