Email Setup & Usage


/.env
MAIL_MAILER=smtp
MAIL_HOST=mail.activetechsystems.com
MAIL_PORT=465
MAIL_USERNAME=postmaster@activetechsystems.com
MAIL_PASSWORD=pwd
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS="postmaster@activetechsystems.com"
MAIL_FROM_NAME="${APP_NAME}"

use App\Http\Controllers\TheController;
use Illuminate\Support\Facades\Mail;
..
public function send_mail() {
    $to_name = "John Doe";
    $to_email = "to@gmail.com";
    $from_name = "From Name";
    $from_email = "postmaster@mailserver.com";
    $subject = 'Subject 123';
    $body = 'Body HTML 123';
    $reply_to = $from_email;

    Mail::html($body, function ($message) use ($to_email, $to_name, $subject, $from_email, $from_name, $reply_to) {
        $message
            ->to($to_email, $to_name)
            ->subject($subject)
            ->from($from_email, $from_name)
            ->replyto($reply_to, $from_name);
    });
}