Before production version I used mailtrap to test my emails and everything worked like it should be, but today I uploaded my website to a public server and decided to use mailgun, I know its not so simple like mailtrap.io
, but still. Anyway I verified my account and can now send 10k emails per month. Not bad, but the thing is when I try to send an email I get a notification that the email was sent, but there is no email in any inbox.
My .env
file
MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=myEmail
MAIL_PASSWORD=myPassword
MAIL_ENCRYPTION=tls
My services.php
file
return [
'mailgun' => [
'domain' => env('myDomain'),
'secret' => env('secretKey'),
],
'ses' => [
'key' => env('SES_KEY'),
'secret' => env('SES_SECRET'),
'region' => 'us-east-1',
],
'sparkpost' => [
'secret' => env('SPARKPOST_SECRET'),
],
'stripe' => [
'model' => App\User::class,
'key' => env('STRIPE_KEY'),
'secret' => env('STRIPE_SECRET'),
],
];
One of the functions:
public function store(StoreListingContactFormRequest $request, Area $area, Listing $listing){
Mail::to($listing->user)->queue(
new ListingContactCreated($listing,
$request->name,
$request->email,
$request->number,
$request->message
)
);
return back()->withSuccess("Teie sõnum on edukalt saadetud firmale {$listing->user->name}");
}
Another one:
public function __construct()
{
$this->middleware(['auth']);
}
public function index(Area $area, Listing $listing){
return view('listings.share.index', compact('listing'));
}
public function store(StoreListingShareFormRequest $request, Area $area, Listing $listing){
collect(array_filter($request->emails))->each(function($email) use ($listing, $request){
Mail::to($email)->queue(
new ListingShared($listing, $request->user(), $request->messages)
);
});
return redirect()->route('listings.show',[$area, $listing])->withSuccess('Kuulutus on jagatud edukalt!');
}