简体   繁体   中英

Sending Email From A Custom Email Address

Is there a way to send email using a customized Email address. For example, i have a domain (www.laracast.com) and a customised Email (noreply@laracast.com).

How do i send Email from noreply@laracast.com to my users

I have this in env

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=xxxxxxxxxxxxx
MAIL_PASSWORD=xxxxxxxxxxxx
MAIL_ENCRYPTION=null

and my config/mail.php

return [



    'driver' => env('MAIL_DRIVER', 'smtp'),


    'host' => env('MAIL_HOST', 'smtp.mailgun.org'),


    'port' => env('MAIL_PORT', 587),



    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', 'noreply@pconnect.com'),
        'name' => env('MAIL_FROM_NAME', 'PConnect'),
    ],



    'encryption' => env('MAIL_ENCRYPTION', 'tls'),



    'username' => env('MAIL_USERNAME'),

    'password' => env('MAIL_PASSWORD'),



    'sendmail' => '/usr/sbin/sendmail -bs',



    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],

];

You are going to send an email, so the protocol you are going to use is smtp. Then

  1. Setup Your Host Variable (Ex: smtp.laracast.com )
  2. Set the Username and Password
  3. Then in your config/mail file, set the from variables, including address and name.

'from' => [ 'address' => env('MAIL_FROM_ADDRESS', 'The Email Address THAT I WANT TO USE'), 'name' => env('MAIL_FROM_NAME', 'THE NAME WHICH IS GOING TO APPEAR IN THE USER'S INBOX'), ],

OR instead of 3:
in your env file, set the MAIL_FROM_NAME and MAIL_FROM_ADDRESS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM