📜  laravel 邮件成功或失败 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:49.984000             🧑  作者: Mango

代码示例1
/**
 *  Send Mail from Parts Specification Form
 */
public function sendMail(Request $request) {
    $data = $request->all();

    $messageBody = $this->getMessageBody($data);

    Mail::raw($messageBody, function ($message) {
        $message->from('yourEmail@domain.com', 'Learning Laravel');
        $message->to('goper.zosa@gmail.com');
        $message->subject('Learning Laravel test email');
    });

    // check for failures
    if (Mail::failures()) {
        // return response showing failed emails
    }

    // otherwise everything is okay ...
    return redirect()->back();
}