【发布时间】:2018-10-17 21:14:46
【问题描述】:
我有一个域:www.mydomain.ro,我创建了一个这样的电子邮件:office@mydomain.ro
我正在尝试从我的 laravel 应用程序(laravel 5.7)发送电子邮件,我做了以下配置:
在 .env 文件中:
MAIL_DRIVER=smtp
MAIL_HOST=office@my-domain.ro
MAIL_PORT=26
MAIL_USERNAME=office@my-domain.ro
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=null
在 config/mail.php 中:
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'mail.my-domain.ro '),
'port' => env('MAIL_PORT', 26),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'office@muy-domain.ro'),
'name' => env('MAIL_FROM_NAME', 'Office my-domain'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('office@my-domain.ro'),
'password' => env('mypassword'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
在控制器中我正在这样做:
$data = array(
'name' => 'Ioan Andrei',
'body' => 'Test Email'
);
Mail::send('emails.demandreceived',$data,function ($message){
$message->from('office@my-domain.ro','TEST');
$message->to('ioan.andrei97@gmail.com');
$message->subject('Test email');
我得到这个错误:
Connection could not be established with host office@msipremiumcars.ro [php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known #0]
我做错了什么?它不起作用,因为我试图从我的本地服务器发送它们?
我可以使用 mailgun 来发送电子邮件,并且仍然从 office@mydomain.ro 发送电子邮件吗?
我尝试在配置后重新启动本地服务器。
Laravel 版本:5.7
【问题讨论】: