Skip to Content
Niagara 4How to setup an Email Service in a Niagara Station (Gmail)

How to setup an Email Service in a Niagara Station (Gmail)

Configuring Gmail as an email service in Niagara 4 allows your Station to send email notifications, alarms, reports, and other automated communications. This guide provides comprehensive instructions for setting up Gmail integration with Niagara 4.

Overview

Niagara 4 includes an Email Service that can be configured to use Gmail's SMTP servers. This service enables automated email notifications for alarms, system events, scheduled reports, and custom applications.

Prerequisites

Before beginning, ensure you have:

  • A Gmail account with access credentials
  • A Gmail App Password (required for two-factor authentication)
  • Administrative access to the Niagara Station
  • Network connectivity to Gmail's SMTP servers (smtp.gmail.com)

Gmail Configuration Requirements

App Password Setup

Gmail requires an App Password for third-party applications like Niagara:

  1. Enable Two-Factor Authentication: Your Gmail account must have 2FA enabled
  2. Generate App Password: Create a dedicated app password for Niagara
  3. Save Credentials: Securely store the app password for use in Niagara

SMTP Server Details

Gmail SMTP configuration:

  • SMTP Server: smtp.gmail.com
  • Port: 587 (TLS) or 465 (SSL)
  • Security: TLS/SSL encryption required
  • Authentication: Required (username and app password)

Step-by-Step Configuration

Step 1: Generate Gmail App Password

  1. Log in to your Google Account
  2. Navigate to Google AccountSecurity
  3. Under Signing in to Google, ensure 2-Step Verification is enabled
  4. Scroll to App passwords
  5. Click App passwords (you may need to verify your password)
  6. Select Mail as the app
  7. Select Other (Custom name) as the device
  8. Enter "Niagara 4" as the custom name
  9. Click Generate
  10. Copy the 16-character app password (you'll need this for Niagara)

Step 2: Access Station Services

  1. Open Niagara Workbench
  2. Connect to your target Station
  3. In the Station tree, expand the Services folder
  4. Locate or create the Email Service

Step 3: Create Email Service (if not exists)

If an Email Service doesn't exist:

  1. Right-click on Services
  2. Select NewServiceEmail Service
  3. Enter a name (e.g., "Gmail Service")
  4. Click OK

Step 4: Configure SMTP Settings

  1. Right-click on the Email Service
  2. Select Properties
  3. Navigate to the SMTP tab or Configuration section

Step 5: Enter SMTP Server Details

Configure the SMTP server settings:

  • SMTP Host: smtp.gmail.com
  • SMTP Port: 587 (for TLS) or 465 (for SSL)
  • Use TLS: Enable this checkbox (for port 587)
  • Use SSL: Enable this checkbox (for port 465, use instead of TLS)
  • Require Authentication: Enable this checkbox

Step 6: Configure Authentication

Enter Gmail credentials:

  • Username: Your full Gmail address (e.g., yourname@gmail.com)
  • Password: The 16-character App Password generated in Step 1
  • From Address: Your Gmail address (e.g., yourname@gmail.com)
  • From Name: Display name for sent emails (e.g., "Niagara Station")

Step 7: Configure Advanced Settings (Optional)

Set additional email service parameters:

  • Connection Timeout: 30 seconds (default)
  • Command Timeout: 30 seconds (default)
  • Maximum Retries: 3 (default)
  • Retry Interval: 5 seconds (default)

Step 8: Test Email Configuration

  1. In the Email Service properties, locate the Test button
  2. Click Test to send a test email
  3. Enter a test recipient email address
  4. Click Send Test Email
  5. Check the recipient inbox for the test email
  6. Review any error messages if the test fails

Step 9: Enable the Email Service

  1. Ensure the Email Service is Enabled (check the Enabled checkbox)
  2. Click OK to save configuration
  3. The service will start automatically

Step 10: Verify Service Status

  1. Check the Email Service status in the Station tree
  2. Status should show as Running or Online
  3. Review the service log for any errors

Configuration Examples

Basic Gmail Configuration

SMTP Host: smtp.gmail.com
SMTP Port: 587
Use TLS: Enabled
Require Authentication: Enabled
Username: yourname@gmail.com
Password: [16-character App Password]
From Address: yourname@gmail.com
From Name: Niagara Station

SSL Configuration Alternative

SMTP Host: smtp.gmail.com
SMTP Port: 465
Use SSL: Enabled
Require Authentication: Enabled
Username: yourname@gmail.com
Password: [16-character App Password]
From Address: yourname@gmail.com

Using the Email Service

Sending Emails from Applications

Once configured, you can send emails from Niagara applications:

// Example: Send email notification
emailService.sendEmail({
  to: 'recipient@example.com',
  subject: 'System Alert',
  body: 'This is a test email from Niagara Station'
});

Configuring Alarm Email Notifications

  1. Navigate to Alarm Service in the Station
  2. Configure alarm email recipients
  3. Set email notification rules
  4. Test alarm email delivery

Scheduled Email Reports

  1. Configure report generation schedules
  2. Set email delivery for reports
  3. Configure report recipients
  4. Test report email delivery

Troubleshooting

Authentication Failures

If authentication fails:

  1. Verify App Password: Ensure you're using the App Password, not your regular Gmail password
  2. Check 2FA: Verify two-factor authentication is enabled on your Gmail account
  3. Username Format: Ensure username is the full email address
  4. Password Format: Verify the 16-character App Password is entered correctly (no spaces)

Connection Timeouts

If experiencing connection timeouts:

  1. Check Network: Verify network connectivity to smtp.gmail.com
  2. Firewall Settings: Ensure port 587 or 465 is not blocked
  3. Port Selection: Try port 465 (SSL) if 587 (TLS) fails
  4. Timeout Values: Increase connection timeout values

Emails Not Sending

If emails are not being sent:

  1. Service Status: Verify Email Service is enabled and running
  2. Check Logs: Review Email Service logs for error messages
  3. Test Configuration: Use the test email function to verify settings
  4. Recipient Validation: Verify recipient email addresses are valid

Gmail Security Warnings

If Gmail blocks emails:

  1. Review Gmail Security: Check Gmail account security settings
  2. App Password: Ensure App Password is correctly configured
  3. Less Secure Apps: Note that Gmail no longer supports "Less Secure Apps"
  4. Account Review: Review Gmail account for security alerts

Security Best Practices

Credential Management

  • Use App Passwords: Always use App Passwords, never regular passwords
  • Secure Storage: Store credentials securely
  • Regular Rotation: Periodically rotate App Passwords
  • Access Control: Limit access to Email Service configuration

Network Security

  • Use TLS/SSL: Always enable encryption (TLS or SSL)
  • Firewall Rules: Configure firewall rules appropriately
  • Network Monitoring: Monitor email service network activity

Email Content

  • Sensitive Data: Avoid sending sensitive data via email
  • Email Validation: Validate email addresses before sending
  • Rate Limiting: Configure appropriate sending rates

Additional Resources

  • Gmail App Passwords Documentation
  • Niagara 4 Email Service Guide
  • SMTP Configuration Best Practices