SMTP & Password Recovery
SMTP & Password Recovery
The HCG AI application uses Nodemailer to handle email notifications, primarily for the "Forgot Password" and account recovery workflows. By default, the system is configured to work with Hostinger's SMTP services.
1. Configuration
To enable email features, you must provide your SMTP credentials in the .env file. Without these, the password recovery system will fail to send outgoing mail.
# .env
SMTP_PASS=your_smtp_password_here
2. SMTP Provider Setup
The application's email transporter is defined in simple-app-server.js. Depending on your environment, you can use the default configuration or point to a different provider.
Option A: Default Configuration (Hostinger)
The current setup is pre-configured for hello@in.hcgai.com using the following parameters:
- Host:
smtp.hostinger.com - Port:
465(Secure) - Encryption: TLS v1.2
Option B: Using a Custom SMTP Provider
If you wish to use Gmail, SendGrid, or another provider, update the createEmailTransporter function in simple-app-server.js (typically found around lines 151–169):
const config = {
host: 'your.smtp.host.com',
port: 587, // or 465 for SSL
secure: false, // true for 465, false for other ports
auth: {
user: 'your-email@domain.com',
pass: process.env.SMTP_PASS
}
};
3. Password Recovery API
The application exposes a public endpoint to trigger the recovery process. This generates a secure token and sends a reset link to the user's registered email address.
Endpoint: POST /api/forgot-password
Request Body:
{
"email": "user@example.com"
}
Responses:
200 OK: "Recovery email sent successfully."400 Bad Request: "Email is required."404 Not Found: "No account associated with this email."500 Internal Server Error: "Failed to send email."
4. Local Testing & Troubleshooting
Disabling Email Features
If you are developing locally and do not wish to set up an SMTP server, you can comment out the email-related routes in the server files or simply ignore the "Forgot Password" link on the login page.
Connection Issues
If emails are not sending, ensure that:
- Your firewall allows outgoing traffic on port 465 or 587.
- Your
SMTP_PASSdoes not contain special characters that require escaping in your.envfile environment. - If using Gmail, you have generated an App Password, as standard account passwords are blocked for SMTP.
Debugging
The transporter is configured with debug: true and logger: true by default. Check your server console logs to see the full SMTP handshake and identify where a connection might be failing.