啥話都不說了
你們先去注冊一個賽郵 ,賽郵哪裡有編寫文檔 ,
我這裡就不廢話了 ,
我直接上代碼了,
走,
這一段是短信的接口 自己封裝一個函數
//擷取驗證碼
public function getCode(Request $request){
$phone = $request->input('phone');
$code = rand(1000,9999);
//判斷 目前手機号是否被注冊過
$res = DB::table('users')->where([
['phone',$phone],
['state',2],
])->first();
if($res){
return 2; // 已被注冊
die;
}
//引短信接口
// return public_path();
require public_path().'\sdk\app_config.php';
require_once(public_path().'\sdk\SUBMAILAutoload.php');
$submail=new MESSAGEXsend($message_configs);
$submail->setTo($phone);
$submail->SetProject('rlkn54');
$submail->AddVar('code',$code);
$submail->AddVar('time',60);
$xsend=$submail->xsend();
if($xsend['status'] == 'success'){
//cookie
\Cookie::queue('code',$code,1);
return 1; //驗證碼發送成
}else{
return 0; //驗證碼發送失敗
}
}
================================================================
這裡就是郵箱的接口了
//發送郵件
public function sendMail(){
// dd(base_path());
require base_path().'\vendor\autoload.php';
$mail = new PHPMailer(true); // Passing `true` enables exceptions
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.163.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'zwd123456'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 25; // TCP port to connect to
$mail->CharSet = "utf-8";
//Recipients 接受者
$mail->setFrom('[email protected]', '迪麗熱巴'); //誰給發的
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = '注冊';
$code = rand(1000,9999);
$mail->Body = '感謝您注冊官網。您的驗證碼是'.$code;
// $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; //備用資訊 ,
$res = $mail->send(); //傳回值 bool
if($res){
dd(1);
}else{
dd(0);
}
}
更加詳細的資訊 你們加我微信吧 分分鐘給你解決這個問題、
那個接口的參數 賽郵上面都有文檔 你們自己應該能找到