@@ -32,7 +32,6 @@ import { UserChangedAuditStore } from '../../../../server/lib/auditServerEvents/
3232import { i18n } from '../../../../server/lib/i18n' ;
3333import { removeOtherTokens } from '../../../../server/lib/removeOtherTokens' ;
3434import { resetUserE2EEncriptionKey } from '../../../../server/lib/resetUserE2EKey' ;
35- import { sendWelcomeEmail } from '../../../../server/lib/sendWelcomeEmail' ;
3635import { registerUser } from '../../../../server/methods/registerUser' ;
3736import { requestDataDownload } from '../../../../server/methods/requestDataDownload' ;
3837import { resetAvatar } from '../../../../server/methods/resetAvatar' ;
@@ -56,6 +55,7 @@ import { generateUsernameSuggestion } from '../../../lib/server/functions/getUse
5655import { saveCustomFields } from '../../../lib/server/functions/saveCustomFields' ;
5756import { saveCustomFieldsWithoutValidation } from '../../../lib/server/functions/saveCustomFieldsWithoutValidation' ;
5857import { saveUser } from '../../../lib/server/functions/saveUser' ;
58+ import { sendWelcomeEmail } from '../../../lib/server/functions/saveUser/sendUserEmail' ;
5959import { setStatusText } from '../../../lib/server/functions/setStatusText' ;
6060import { setUserAvatar } from '../../../lib/server/functions/setUserAvatar' ;
6161import { setUsernameWithValidation } from '../../../lib/server/functions/setUsername' ;
@@ -66,6 +66,7 @@ import { notifyOnUserChange, notifyOnUserChangeAsync } from '../../../lib/server
6666import { generateAccessToken } from '../../../lib/server/methods/createToken' ;
6767import { deleteUserOwnAccount } from '../../../lib/server/methods/deleteUserOwnAccount' ;
6868import { settings } from '../../../settings/server' ;
69+ import { isSMTPConfigured } from '../../../utils/server/functions/isSMTPConfigured' ;
6970import { getURL } from '../../../utils/server/getURL' ;
7071import { API } from '../api' ;
7172import { getPaginationItems } from '../helpers/getPaginationItems' ;
@@ -634,7 +635,22 @@ API.v1.addRoute(
634635 {
635636 async post ( ) {
636637 const { email } = this . bodyParams ;
637- await sendWelcomeEmail ( email ) ;
638+
639+ if ( ! isSMTPConfigured ( ) ) {
640+ throw new MeteorError ( 'error-email-send-failed' , 'SMTP is not configured' , {
641+ method : 'sendWelcomeEmail' ,
642+ } ) ;
643+ }
644+
645+ const user = await Users . findOneByEmailAddress ( email . trim ( ) , { projection : { name : 1 } } ) ;
646+
647+ if ( ! user ) {
648+ throw new MeteorError ( 'error-invalid-user' , 'Invalid user' , {
649+ method : 'sendWelcomeEmail' ,
650+ } ) ;
651+ }
652+
653+ await sendWelcomeEmail ( { ...user , email } ) ;
638654
639655 return API . v1 . success ( ) ;
640656 } ,
0 commit comments