如何给后缀中的电子邮件地址指定一个特定名称。?

how to give a specific name to an email address in postfix.?

我在我的系统上安装了 Nagios 核心,如果某些服务进入 Critical/warning 阶段,它会向我发送一封电子邮件。一切正常。 我配置了 post-fix 来发送电子邮件,并在“sasl_passwd”文件中配置了一个电子邮件地址,类似于“[smtp.gmail.com]:587 <email-id>:<password>”。 当我收到一封关于服务阶段的邮件时,它以 "Alert from <email-id>" 的形式出现,现在我想更改为我希望电子邮件以 "Nagios alert" 或类似邮件主题的形式出现,而不仅仅是 <email-id>显示。 我该怎么做?

更改您的命令 notify-host-by-emailnotify-service-by-email。这些命令是发送电子邮件通知的命令。默认情况下,它通过管道将消息字符串传递给 /bin/mail。它已经包含指示主题的 -s 标志。所以为了覆盖发件人,我们检查man mail并确定标志是-r [from-addr]。因此,您可以更改命令:

# 'notify-host-by-email' command definition
define command{
    command_name    notify-host-by-email
    command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
    }

# 'notify-service-by-email' command definition
define command{
    command_name    notify-service-by-email
    command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
    }

收件人:

# 'notify-host-by-email' command definition
define command{
    command_name    notify-host-by-email
    command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -r "someemail@somewhere.com" -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
    }

# 'notify-service-by-email' command definition
define command{
    command_name    notify-service-by-email
    command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -r "someemail@somewhere.com" -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
    }

其中 someemail@somewhere.com 是您的电子邮件地址。

希望对您有所帮助。