Skip to content

Commit

Permalink
fix: Application freezing issues on mail sending
Browse files Browse the repository at this point in the history
  • Loading branch information
dogukanoksuz committed Sep 24, 2023
1 parent 36ba833 commit c1994bf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ MAIL_MAILER=smtp

# MAIL HOST
# Mail server
MAIL_HOST=smtp.mailtrap.io
MAIL_HOST=0.0.0.0

# MAIL PORT
# Mail server port
MAIL_PORT=2525
MAIL_PORT=1025

# MAIL USERNAME
# The user that exists on mail server
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/Extension/Sandbox/InternalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ private function checkPermissions()
*/
public function sendMail()
{
if (! (bool) env('MAIL_ENABLED', false)) return;

Mail::to(request('to'))->send(
new ExtensionMail(
request('subject'),
Expand Down
4 changes: 4 additions & 0 deletions app/Observers/UserObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class UserObserver
*/
public function created(User $user)
{
if (! (bool) env('MAIL_ENABLED', false)) return;

try {
Mail::to($user->email)
->send(new Information(
Expand All @@ -32,6 +34,8 @@ public function created(User $user)
*/
public function updating(User $user)
{
if (! (bool) env('MAIL_ENABLED', false)) return;

if ($user->isDirty('password')) {
try {
Mail::to($user->getOriginal('email'))
Expand Down

0 comments on commit c1994bf

Please sign in to comment.