Email Alert and Mail Server Commands

Use these M4500 CLI commands to send log messages by email, configure the mail server and email alert settings, and display email alert statistics.

Email Alert is an extension of the logging system. This feature can immediately send urgent log messages to a specified mail address by email. It also can send non-urgent log messages created in a specified interval to a specified address. If there is no buffer to keep non-urgent log messages in the specified interval, the log messages will be sent and cleared.

show logging email config

This command displays the configurations of email alert.

Default None
Format show logging email config
Mode Privileged Exec

Example:

CODE
(M4500-32C) #show logging email config
Email Alert Logging............................ enabled
Email Alert From Address....................... switch@netgear.com
Email Alert Urgent Severity Level.............. alert
Email Alert Non Urgent Severity Level.......... warning
Email Alert Trap Severity Level................ info
Email Alert Notification Period................ 30 min

Email Alert To Address Table:
For Msg Type ................................ urgent
Address1 .....................................test01@email.com
For Msg Type ................................ non-urgent
Address1 .................................... test02@email.com

Email Alert Subject Table:
For Msg Type urgent, subject is.............. Urgent Log Messages
For Msg Type non-urgent, subject is.......... Non Urgent Log Messages
(M4500-32C) #

show logging email statistics

This command displays the statistics of email alert.

Default None
Format show logging email statistics
Mode Privileged Exec

Example:

CODE
(M4500-32C) (Config)#show logging email statistics
Email Alert operation status................... enabled
Email Alert Statistics:
No of email Failures so far.................... 1
No of email sent so far........................ 3
Time since last email Sent..................... 00 days 00 hours 00 mins 29 secs
(M4500-32C) (Config)#

show mail-server config

This command displays information about email server configuration.

Default None
Format show mail-server {<ip-address | hostname> | all} config
Mode Privileged Exec

Example:

CODE
(M4500-32C) #show mail-server all config
Mail Servers Configuration:
No of mail servers configured.................. 1

Email Alert Mail Server Address................ smtp.gmail.com
Email Alert Mail Server Port................... 465
Email Alert Security Protocol.................. tlsv1
Email Alert Username........................... mailServerUser01
M4500-32C) (Config)#

logging email

This command enables or disables email alerting function.

Default Disabled
Format [no] logging email
Mode Global Config

logging email urgent and non-urgent

This command sets the lowest serverity level for which log messages are emailed. If you specify a severity level, log messages at or above this severity level, but below the urgent severity level, are emailed in a non-urgent manner by collecting them together until the log time expires. You can specify the severitylevel value as either an integer from 0 to 7 or symbolically through one of the following keywords: emergency(0), alert(1), critical(2), error(3), warning(4), notice(5), info(6), or debug(7).

Default

Urgent severity level is alert(1)

Non-Urgent severity level is warning (4)

Format

logging email {urgent | non-urgent} {<severity> | none}

no logging email {urgent | non-urgent}

Mode Global Config

Example: Set severity level of urgent mail to critical(2), and set severity level of non-urgent mail to notice(5).

CODE
(M4500-32C) #configure
(M4500-32C) (Config)#logging email urgent 2
(M4500-32C) (Config)# logging email non-urgent 5

logging email logtime

This command is used to configure how frequently non-urgent email messages are sent. Non-urgent messages are collected and sent in a batch email at the specified interval.

The parameter “<interval>“ uses to Specify how frequently non-urgent email messages are sent. The valid interval is 30 to 1440 minutes.

Default 30
Format

logging email logtime <interval>

no logging email logtime

Mode Global Config

logging email message-type and subject

This command is used to configure the subject line of the email for the specified type.

The parameter “<subject>“ sets the subject line of the email.

Default

type urgent is “Urgent Log Messages”

type non-urgent is “Non Urgent Log Messages”

Format

logging email message-type {both | urgent | non-urgent} subject <subject>

no logging email message-type {both | urgent | non-urgent} subject

Mode Global Config

logging email message-type and to-addr

This command is used to configure the destination email address to which messages are sent. The message types supported are urgent, non-urgent, and both. For each supported severity level, multiple email addresses can be configured.

The parameter “<to-addr>“ specifies a standard email address to be the destination address of urgent or non-urgent message.

Default None
Format [no] logging email message-type {both | urgent | non-urgent} to-addr <to-addr>
Mode Global Config

Example: Add an email address “toAddr01@email.com” to the destination address of urgent message, and add another email address “toAddr02@email.com” to the destination address of both urgent and non-urgent message.

CODE
(M4500-32C) #configure
(M4500-32C) (Config)# logging email message-type urgent to-addr toAddr01@email.com
(M4500-32C) (Config)# logging email message-type both to-addr toAddr02@email.com

logging email from-addr

This command is used to configure the email source address (the address of the sender, i.e., switch) to which messages are sent.

The parameter “<from-addr>“ specifies a standard email address to be the source address of both urgent and non-urgent message.

Default switch@netgear.com
Format

logging email from-addr <from-address>

no logging email from-addr

Mode Global Config

Example: Set an email address “fromAddr@email.com” to the source address of both urgent and non-urgent message.

CODE
(M4500-32C) #configure
(M4500-32C) (Config)# logging email from-addr fromAddr@email.com

mail-server configuration

This command configures the parameters of SMTP server which is used to send email alert messages. This command changes CLI mode from Global Config Mode to Mail Server Config mode.

Default None
Format [no] mail-server <ipaddress|ipv6address|host-name>
Mode Global Config

Example: Set mail server address to hostname “smtp.gmail.com” and change to Mail Server Config mode.

CODE
(M4500-32C) #configure
(M4500-32C) (Config)#mail-server smtp.gmail.com
(M4500-32C) (Mail-Server)#

mail-server security

This command sets the email alerting security protocol by enabling the switch to use TLSv1/STARTTLS authentication with the SMTP Server. If the TLSv1/STARTTLS mode is enabled on the switch but the SMTP sever does not support TLSv1/STARTTLS mode, no email is sent to the SMTP server.

The parameter “none” means email server doesn’t use security protocol.

The parameter “starttls” means to use STARTTLS security protocol.

The parameter “tlsv1” means to use TLSv1 security protocol.

Default none
Format security {none | starttls | tlsv1}
Mode Mail Server Config

mail-server port

This command configures the TCP port to use for communication with the SMTP server. The recommended port for TLSv1 is 465, STARTTLS is 587, and for no security (i.e. none) is 25. However, any nonstandard port in the range 1 to 65535 is also allowed.

Default 25
Format [no] port <465 | 25 | 1 to 65535>
Mode Mail Server Config

mail-server username

This command configures the username (or login ID) which is used to authenticate with the SMTP server.

Default None
Format [no] username <username>
Mode Mail Server Config

mail-server password

This command configures the password that is used to authenticate with the SMTP server.

You can set the password using one of the following options:

  • Type the password keyword to configure the password in plain text. The password is displayed with * for each character that you type. The password must be in alphanumeric characters with a maximum length of 64 characters.
  • Type the password 7 keyword to configure the password in encrypted form. The password must be in hexadecimal digits with a length of 128 characters.
Default None
Format [no] password [7 <password>]
Mode Mail Server Config

In the following examples, the first example sets the password of mail server to plain text “testPassword”, and the second one sets the password to an encrypted string that is fixed at 128 hexadecimal digits.

CODE
(M4500-32C) #configure
(M4500-32C) (Config)# mail-server smtp.gmail.com
Enter new password:************
Confirm new password: ************
(M4500-32C) (Mail-Server)#
(M4500-32C) (Mail-Server)# password 7
0fdd841c8a524979e5ba47893efcf48b12a08619953e1b6e42cde0931198ca717cb5ff8b49795a3497e
283990827c5ba1ce32855ced76a505726dfb1ee222c4b

clear logging email statistics

This command is used to clear the statistics of logging email.

Default None
Format clear logging email statistics
Mode Privilege EXEC