Environment
.env
MAIL_DRIVER=smtp
MAIL_HOST=sv[YOUR_NUM].xserver.jp
MAIL_PORT=587
MAIL_USERNAME=[YOUR_MAIL]
MAIL_PASSWORD=[PASSWORD_FOR_YOUR_MAIL]
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=[ADDRESS_YOU_WANT]
MAIL_FROM_NAME=[ANYTHING_YOU_WANT]
※Domain name of MAIL_FROM_ADDRESS have to be same as MAIL_HOST.
Controller
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Mail;
class SendmailController extends Controller
{
public function sendMail()
{
Mail::send('mail', array(), function($message){
$message->to('address@example.com', 'Title')->subject('Test mail');
});
}
}
SPF Record
If you can't send mail from xserver, please check your spf record on xserver.
CAUTION
If you put your server without Japan.
You need to change setting like below.