File tree Expand file tree Collapse file tree 5 files changed +34
-7
lines changed
Expand file tree Collapse file tree 5 files changed +34
-7
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,9 @@ PORT=3000
33FRONTEND_URL=http://localhost:3000
44
55DATABASE_URL=postgresql://admin_pg:password@postgres:5432/express-hybrid-auth-api-local-prod-db
6+ # Use the Docker service name 'postgres' as the host because the app runs inside a container.
7+ # Port 5432 is the default PostgreSQL port inside the container.
8+ # From the host machine (local Node.js), you would connect to localhost:5433 because of the port mapping in docker-compose.yml.
69
710GOOGLE_CLIENT_ID=
811GOOGLE_CLIENT_SECRET=
@@ -14,11 +17,13 @@ GITHUB_CALLBACK_URL=http://localhost:3000/auth/github/callback
1417
1518NODE_ENV=development
1619
17- REDIS_PORT=6379
18- REDIS_HOST=redis # using redis service name because the app will run in a container so localhost is not correct
20+ REDIS_PORT=6379
21+ REDIS_HOST=redis # Use the Docker service name 'redis' because the app runs inside a container.
22+ # 'localhost' would point to the container itself, not the Redis container.
1923
20- SMTP_HOST=smtp4dev
21- SMTP_PORT=2525
24+ SMTP_HOST=smtp4dev # Docker service name for smtp4dev container
25+ SMTP_PORT=25 # Container's SMTP port (25).
26+ # Use port 25 here because inside the container, Docker networking connects directly to smtp4dev's internal port.
2227
2328SESSION_SECRET="QeWMItONAv+x6AmdOJ2D5O1h/d//DjO5bpmjz6O0AOnxfc7Q4OlHYeXxX2HE6l0N2zEMZTAYmmRc8Z50UAFPHA=="
2429ACCESS_TOKEN_SECRET="F9HHTuGGzVhbzB6rMoTLRVlZu7RhsicD6iF00xDn5K4UIlHtkcecz1bMyDRaewfjTUqmoTH6UWN22Bf7qymGBg=="
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ services:
4343 image : rnwood/smtp4dev
4444 ports :
4545 - ' 5000:80' # Web UI
46- - ' 2525:2525 ' # SMTP server
46+ - ' 2525:25 ' # SMTP server (Host 2525 -> Container 25 (SMTP))
4747 restart : unless-stopped
4848 environment :
4949 - Logging__LogLevel__Default=Information
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ services:
6464 image : rnwood/smtp4dev
6565 ports :
6666 - ' 5000:80'
67- - ' 2525:2525 '
67+ - ' 2525:25 ' # SMTP server (Host 2525 -> Container 25 (SMTP))
6868 restart : unless-stopped
6969 environment :
7070 - Logging__LogLevel__Default=Information
Original file line number Diff line number Diff line change @@ -11,3 +11,16 @@ export const transporter = nodemailer.createTransport({
1111 // pass: '',
1212 // },
1313} ) ;
14+
15+ transporter . sendMail (
16+ {
17+ from : 'test@example.com' ,
18+ to : 'user@example.com' ,
19+ subject : 'SMTP test' ,
20+ text : 'Hello from smtp4dev!' ,
21+ } ,
22+ ( err , info ) => {
23+ if ( err ) console . error ( 'Error:' , err ) ;
24+ else console . log ( 'Sent:' , info ) ;
25+ }
26+ ) ;
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import TwoFactorDisabledEmail from '../../emails/templates/2fa-disabled-email.js
77import PasswordResetEmail from '../../emails/templates/password-reset-email.js' ;
88import GlobalConfig from '../config.js' ;
99import { transporter } from './mail-transporter.js' ;
10+ import logger from './logger/logger.js' ;
1011
1112export async function sendVerificationEmail ( {
1213 token,
@@ -19,6 +20,7 @@ export async function sendVerificationEmail({
1920 expiresInMinutes : number ;
2021 t : ( key : string , options ?: any ) => string ;
2122} ) {
23+ console . log ( 'I am here' ) ;
2224 const emailHtml = await render (
2325 < VerificationEmail
2426 verificationUrl = { `${ GlobalConfig . EMAIL_FRONTEND_BASE_URL } /verify?token=${ token } ` }
@@ -36,7 +38,14 @@ export async function sendVerificationEmail({
3638 html : emailHtml ,
3739 } ;
3840
39- await transporter . sendMail ( options ) ;
41+ try {
42+ console . log ( 'I am here' ) ;
43+ await transporter . sendMail ( options ) ;
44+ } catch ( error ) {
45+ console . log ( 'error' , error ) ;
46+ logger . error ( 'Failed to send verification email' , { error, userEmail } ) ;
47+ throw error ;
48+ }
4049}
4150
4251export async function sendAccountActivationEmail ( {
You can’t perform that action at this time.
0 commit comments