Last active
September 26, 2021 10:24
-
-
Save tararoutray/cbcf225a3d40b6fa9b079973b26c7092 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use App\Mail\HelloEmail; | |
use Illuminate\Http\Request; | |
use Illuminate\Support\Facades\Mail; | |
class EmailController extends Controller | |
{ | |
public function sendEmail() | |
{ | |
/** | |
* Store a receiver email address to a variable. | |
*/ | |
$reveiverEmailAddress = "[email protected]"; | |
/** | |
* Import the Mail class at the top of this page, | |
* and call the to() method for passing the | |
* receiver email address. | |
* | |
* Also, call the send() method to incloude the | |
* HelloEmail class that contains the email template. | |
*/ | |
Mail::to($reveiverEmailAddress)->send(new HelloEmail); | |
/** | |
* Check if the email has been sent successfully, or not. | |
* Return the appropriate message. | |
*/ | |
if (Mail::failures() != 0) { | |
return "Email has been sent successfully."; | |
} | |
return "Oops! There was some error sending the email."; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment