[英]Getting error while trying to send an email with Laravel
I want to send an email with Laravel.我想用 Laravel 发送电子邮件。 I am not sure what am I doing wrong.我不确定我做错了什么。
Here is my Mail:这是我的邮件:
public function __construct()
{
//
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from('test@test.de')
->view('emails.testemail');
}
Here is my controller:这是我的控制器:
public function send_email_test(){
Mail::to("my_email@mail.net")->send(new testemail());
}
Here is how I try to test it:这是我尝试测试它的方法:
Route::get('/sendemailtext','testcontroller@send_test_email');
Here is the error:这是错误:
Swift_TransportException in AbstractSmtpTransport.php line 383:
Expected response code 220 but got code "", with message ""
Any ideas?有任何想法吗?
Try to do like this尝试这样做
$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');
});
Give it a shot.试一试。 It should work.它应该工作。
<?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');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.