https://github.com/mailhog/MailHog/releases/download/v1.0.0/MailHog_Windows_amd64.exe
mailhog.exe -smtp-bind-addr 127.0.0.1:10250
端口默认为 1025, 有可能已经被系统暂用。所以使用 10250 端口 ( 接收邮件端口) (相当于服务端,打开 http://127.0.0.1:8025),程序退出,邮件将被全部删除。
config (["mail" => ["driver" => "smtp",
"sendmail" => "D:/wamp/sendmail/mailhog.exe sendmail",
"host" => "127.0.0.1",
"port" => "10250",
"from" => ['address' => "admin@linsys.test",
'name' => "admin",
]
]]);
PHP artisan make:mail Register
<?PHP
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class Register extends Mailable
{
use Queueable, SerializesModels;
public $name;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct ($name)
{$this->name = $name;
}
/**
* Build the message.
*
* @return $this
*/
public function build ()
{return $this->view ('email_test', ['name' => $this->name]);
}
}
{{$name}} 你好,这是一封测试文件。
\Mail::to ("14952516@qq.com")
->send (new \App\Mail\Register ("linson"));
if (count (\Mail::failures () == 0)) // 没有失败的
{echo "ok";} else {echo "fail";}