This guide explains how to configure email confirmation functionality for Campus Bridge LMS.
After a user successfully logs in, an email confirmation is automatically sent to their registered email address. This helps users know that their login was successful and provides an additional security measure.
-
Environment Variables: The email configuration is stored in the
.envfile in the root directory. -
Required Settings:
EMAIL_SERVICE: The email service provider (default: gmail)EMAIL_USER: Your email addressEMAIL_PASS: Your email password or app passwordEMAIL_FROM: The email address that will appear as the sender
For Gmail users, you need to generate an App Password:
- Go to your Google Account settings
- Navigate to Security
- Enable 2-Factor Authentication if not already enabled
- Generate an App Password:
- Go to "App passwords"
- Select "Mail" and your device
- Copy the generated password
- Use this App Password in the
EMAIL_PASSfield
To test the email confirmation:
- Start the server:
npm start - Navigate to the login page
- Log in with valid credentials
- Check the user's email inbox for a confirmation message
You can customize the email template by modifying the sendEmailConfirmation function in server.js. The current template includes:
- User's name
- Login timestamp
- Security warning for unauthorized access
If emails are not being sent:
- Check that all environment variables are correctly set
- Verify that your email credentials are correct
- Ensure that your email provider allows SMTP access
- Check the server console for error messages
- Never commit your
.envfile to version control - Use App Passwords instead of your regular email password
- Regularly rotate your App Passwords for security