Skip to main content

Overview

DevAurva uses Nodemailer to send email notifications for contact form submissions, custom plan requests, and card plan selections. The application is configured to work with Gmail’s SMTP service.

Email Dependencies

The application uses nodemailer (v6.10.0) for email functionality.

Nodemailer Configuration

The email transporter is configured in server.js:27-34:
import nodemailer from 'nodemailer';

// Create email transporter
const transporter = nodemailer.createTransport({
    service: 'gmail',
    auth: {
        user: process.env.EMAIL_USER,
        pass: process.env.EMAIL_PASS
    }
});

Gmail Setup for Nodemailer

1
Enable 2-Factor Authentication
2
  • Go to your Google Account
  • Navigate to Security
  • Enable 2-Step Verification
  • Follow the setup process to secure your account
  • 3
    App passwords are only available when 2-Step Verification is enabled. You cannot use your regular Gmail password with Nodemailer.
    4
    Generate App Password
    5
  • Go to your Google Account
  • Navigate to Security2-Step Verification
  • Scroll down to App passwords
  • Click App passwords
  • Select Mail as the app
  • Select Other (Custom name) as the device
  • Enter “DevAurva” or any descriptive name
  • Click Generate
  • Copy the 16-character password (remove spaces)
  • 6
    Configure environment variables
    7
    Add your Gmail credentials to the .env file:
    8
    EMAIL_USER=[email protected]
    EMAIL_PASS=your-16-char-app-password
    EMAIL_RECIPIENT=[email protected]
    
    9
  • EMAIL_USER: Your Gmail address
  • EMAIL_PASS: The 16-character app password (not your regular password)
  • EMAIL_RECIPIENT: Email address to receive notifications (optional, defaults to EMAIL_USER)
  • Email Notification Types

    DevAurva sends three types of email notifications:

    Contact Form Emails

    Sent when users submit the contact form (server.js:37-74):
    const mailOptions = {
        from: process.env.EMAIL_USER,
        to: process.env.EMAIL_RECIPIENT || process.env.EMAIL_USER,
        subject: `New Contact Form Message from ${firstName}`,
        text: `
    Name: ${firstName}
    Email: ${email}
    Message: ${message}
        `,
        html: `
    <h2>New Contact Form Submission</h2>
    <p><strong>Name:</strong> ${firstName}</p>
    <p><strong>Email:</strong> ${email}</p>
    <p><strong>Message:</strong></p>
    <p>${message}</p>
        `
    };
    
    Includes:
    • Sender’s name and email
    • Message content
    • Both plain text and HTML formats

    Custom Plan Request Emails

    Sent when users submit custom plan requests with selected features (server.js:98-124): Includes:
    • Client contact information
    • Company name and website type
    • Selected features with pricing
    • Total price calculation
    • Additional notes

    Card Plan Request Emails

    Sent when users select predefined pricing plans (server.js:155-169): Includes:
    • Client contact information
    • Selected plan type (Starter/Professional/Enterprise)
    • Website type
    • Plan price and budget information

    Email Recipient Configuration

    The recipient email uses a fallback pattern (server.js:44,100):
    to: process.env.EMAIL_RECIPIENT || process.env.EMAIL_USER
    
    • If EMAIL_RECIPIENT is set, notifications go to that address
    • If not set, notifications are sent to EMAIL_USER (yourself)

    Testing Email Setup

    1
    Verify environment variables
    2
    Ensure your .env file contains:
    3
    EMAIL_USER=[email protected]
    EMAIL_PASS=xxxx xxxx xxxx xxxx
    EMAIL_RECIPIENT=[email protected]
    
    4
    Start the server
    5
    node server.js
    
    6
    Send a test email
    7
    Submit a contact form through your application:
    8
  • Navigate to the contact page
  • Fill in the form fields
  • Submit the form
  • Check server console for “Email sent successfully”
  • Check the recipient inbox for the email
  • 9
    Verify email delivery
    10
    Successful email delivery shows in the console:
    11
    Email sent successfully
    
    12
    The API responds with:
    13
    {
      "code": 200,
      "message": "Message sent successfully"
    }
    

    Troubleshooting

    Authentication Failed

    If you see authentication errors:
    • Verify 2-Step Verification is enabled on your Google account
    • Ensure you’re using an app password, not your regular Gmail password
    • Check that EMAIL_USER matches the Gmail account that generated the app password
    • Remove any spaces from the app password

    Emails Not Sending

    If emails aren’t being sent:
    • Check the server console for error messages
    • Verify your Gmail account isn’t blocked or suspended
    • Ensure you haven’t exceeded Gmail’s sending limits (500 emails/day for free accounts)
    • Check spam/junk folders in the recipient’s inbox

    Invalid Credentials Error

    Error: Invalid login: 535-5.7.8 Username and Password not accepted
    
    Solutions:
    • Regenerate your app password
    • Ensure 2FA is enabled
    • Verify the email address is correct

    Connection Timeout

    If emails timeout:
    • Check your network connectivity
    • Verify firewall isn’t blocking SMTP connections
    • Ensure port 587 or 465 is accessible
    Security Best Practices:
    • Never commit your app password to version control
    • Use app-specific passwords, never your main Gmail password
    • Rotate app passwords periodically
    • Revoke unused app passwords from your Google Account settings
    • For production, consider using dedicated email services like SendGrid or AWS SES
    • Monitor email sending activity for unusual patterns

    Gmail Sending Limits

    Be aware of Gmail’s sending limits:
    • Free Gmail accounts: 500 emails per day
    • Google Workspace: 2,000 emails per day
    For high-volume applications, consider using:
    • SendGrid
    • AWS SES
    • Mailgun
    • Postmark

    Production Considerations

    For production deployments:
    1. Use a dedicated email service - Gmail is suitable for development but not ideal for production
    2. Implement rate limiting - Prevent email spam and abuse
    3. Add email queuing - Handle bulk emails asynchronously
    4. Monitor deliverability - Track bounce rates and spam reports
    5. Set up SPF/DKIM - Improve email deliverability and prevent spoofing

    Next Steps

    • Test all email notification types (contact, custom plans, card plans)
    • Configure email templates for better formatting
    • Set up email monitoring and logging
    • Consider migrating to a production email service
    • Implement email retry logic for failed sends

    Build docs developers (and LLMs) love