欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Laravel框架實(shí)現(xiàn)的使用smtp發(fā)送郵件功能示例

 更新時(shí)間:2019年03月12日 10:56:30   作者:0colonel0  
這篇文章主要介紹了Laravel框架實(shí)現(xiàn)的使用smtp發(fā)送郵件功能,結(jié)合實(shí)例形式分析了Laravel框架相關(guān)配置及郵件發(fā)送操作技巧,需要的朋友可以參考下

本文實(shí)例講述了Laravel框架實(shí)現(xiàn)的使用smtp發(fā)送郵件功能。分享給大家供大家參考,具體如下:

1、.env文件中配置

MAIL_DRIVER=smtp
MAIL_HOST=smtp.郵箱后綴
MAIL_PORT=郵件服務(wù)器發(fā)送端口
MAIL_USERNAME=發(fā)送方郵件地址
MAIL_PASSWORD=發(fā)送方郵箱生成的第三方登陸碼
MAIL_FROM_ADDRESS=發(fā)送郵箱地址
MAIL_FROM_NAME=發(fā)送方名稱

2、config目錄下mail.php文件配置

可以不配置,因?yàn)闀?huì)被.env文件覆蓋掉。(只有在.env中沒有的時(shí)候才會(huì)去該文件中取值)

3、app/console/commonds/sendMail.php

namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
class SendMailCommand extends Command
{
  /**
   * The name and signature of the console command.
   *
   * @var string
   */
  protected $signature = 'demo:SendMail';
  /**
   * The console command description.
   *
   * @var string
   */
  protected $description = '測(cè)試腳本SendMail';
  /**
   * constructor
   */
  public function __construct()
  {
    parent::__construct();
  }
  /**
   * Execute the console command.
   *
   * @return mixed
   */
  public function handle()
  {
    $content = '這是一封的測(cè)試郵件.';
    $toMail = '目標(biāo)郵箱';
    Mail::raw($content, function ($message) use ($toMail) {
      $message->subject('[ 測(cè)試 ] 測(cè)試郵件SendMail - ' .date('Y-m-d H:i:s'));
      $message->to($toMail);
    });
  }
}

4、測(cè)試

cmd切換到項(xiàng)目根目錄下,執(zhí)行

php artisan demo:SendMail

更多關(guān)于Laravel相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Laravel框架入門與進(jìn)階教程》、《php優(yōu)秀開發(fā)框架總結(jié)》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總

希望本文所述對(duì)大家基于Laravel框架的PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論