diff --git a/appinfo/routes.php b/appinfo/routes.php index eeeec68a0d28bc10ea95abc3ba3981dd78e5ccfe..3496d5ad79a9667442a57811415212e9f7e63e4c 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -28,6 +28,7 @@ return ['routes' => [ ['name' => 'account#index', 'url' => '/accounts/{lang}/signup', 'verb' => 'GET', 'postfix' => 'signwithlang'], ['name' => 'account#index', 'url' => '/accounts/signup', 'verb' => 'GET', 'postfix' => 'signwithoutlang'], ['name' => 'account#create', 'url' => '/accounts/create', 'verb' => 'POST'], + ['name' => 'account#sendemail', 'url' => '/accounts/sendemail', 'verb' => 'GET'], ['name' => 'account#captcha', 'url' => '/accounts/captcha', 'verb' => 'GET'], ['name' => 'account#verify_captcha', 'url' => '/accounts/verify_captcha', 'verb' => 'POST'], ['name' => 'account#check_username_available', 'url' => '/accounts/check_username_available', 'verb' => 'POST'], diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index b6aab24169abc9856842ffd528e1ea664807a44f..959b4c5e2bf0525a21a7332d370895c0ee85de58 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -122,7 +122,21 @@ class AccountController extends Controller { } return $response; } - + /** + * @NoAdminRequired + * @PublicPage + * @NoCSRFRequired + * + **/ + public function sendemail() { + $displayname = 'Avinash'; + $username = 'avinashrecovery1'; + $userEmail = 'avinashrecovery1@dev.eeo.one'; + $language = 'en'; + $this->userService->sendWelcomeEmail($displayname, $username, $userEmail, $language); + echo 'sent'; + die; + } /** * @NoAdminRequired * @PublicPage diff --git a/lib/Service/UserService.php b/lib/Service/UserService.php index 7cca2d81f14eeafa4934d8f1633858365a5f23fe..96138bc1f016ac411f3d755d24bc239419171596 100644 --- a/lib/Service/UserService.php +++ b/lib/Service/UserService.php @@ -172,12 +172,16 @@ class UserService { $sendgridAPIkey = $this->getSendGridAPIKey(); if (empty($sendgridAPIkey)) { + print_r("sendgrid_api_key is missing or empty."); + die; $this->logger->warning("sendgrid_api_key is missing or empty.", ['app' => Application::APP_ID]); return; } $templateIDs = $this->getSendGridTemplateIDs(); if (empty($templateIDs)) { + print_r("welcome_sendgrid_template_ids is missing or empty."); + die; $this->logger->warning("welcome_sendgrid_template_ids is missing or empty.", ['app' => Application::APP_ID]); return; } @@ -189,11 +193,13 @@ class UserService { $fromEmail = Util::getDefaultEmailAddress('noreply'); $fromName = $this->defaults->getName(); - + $fromEmail = 'noreply@murenatest.io'; try { $email = $this->createSendGridEmail($fromEmail, $fromName, $username, $displayname, $userEmail, $templateID); $this->sendEmailWithSendGrid($email, $sendgridAPIkey); } catch (Throwable $e) { + print_r('Error sending welcome email to user: ' . $username . ': ' . $e->getMessage()); + die; $this->logger->error('Error sending welcome email to user: ' . $username . ': ' . $e->getMessage()); } } @@ -232,7 +238,8 @@ class UserService { $response = $sendgrid->send($email, [ CURLOPT_TIMEOUT => 15 ]); if ($response->statusCode() < 200 || $response->statusCode() > 299) { - $this->logger->error("SendGrid API error - Status Code: " . $response->statusCode()); + print_r("SendGrid API error - Status Code: " . $response->statusCode()); + die; } } /**