Ad Widget

Collapse

Troubleshooting MSMTP\GMail Set-Up

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • grey
    Junior Member
    • Apr 2015
    • 2

    #1

    Troubleshooting MSMTP\GMail Set-Up

    I'm trying to set up alerts through MSMTP and the GMail.com SMTP server on an Ubuntu 14.04 server.

    I have MSMTP functioning to the point where command line entry sends me a test email:

    sudo echo -e "Subject: Test Mail\r\n\r\nThis is a test mail" |msmtp --debug --from=zabbix -t [email protected]

    I've enabled a Media type called "GMail SMTP" of type "Script" pointing to "zext_msmtp.sh".

    "zext_msmtp.sh" is in "/etc/zabbix/alert.d" per this line in the Zabbix config:

    AlertScriptsPath=/etc/zabbix/alert.d

    Under Administration/Users/Media tab, I've added and enable the "GMail SMTP" media type.

    Under Configuration/Actions, default action, Operations, this is the only active step:

    Send message to user groups: Zabbix administrators via GMail SMTP
    Immediately Default

    I've been testing this by stopping the Zabbix service on one of the monitored servers, and waiting 5 minutes. I can then monitor the progress of the alert by viewing the server log. This is the output I get:

    3585:20150419:100112.836 Zabbix agent item "vfs.fs.inode[/,pfree]" on host "theserver" failed: first network error, wait for 15 seconds
    3586:20150419:100127.511 Zabbix agent item "vfs.fs.inode[/,pfree]" on host "theserver" failed: another network error, wait for 15 seconds
    3586:20150419:100142.550 Zabbix agent item "vfs.fs.size[/mnt/filesvr,total]" on host "theserver" failed: another network error, wait for 15 seconds
    3586:20150419:100158.668 temporarily disabling Zabbix agent checks on host "theserver": host unavailable
    3604:20150419:112215.446 executing housekeeper
    3604:20150419:112229.617 housekeeper [deleted 11693 hist/trends, 0 items, 0 events, 0 sessions, 0 alarms, 0 audit items in 14.170411 sec, idle 1 hour(s)]

    ... and sometimes, but not always ...

    sh: 1: /etc/zabbix/alert.d/zext_msmtp.sh: not found

    More on that later.

    On the monitor page, I will see, under "Last 20 Issues", that the issue was caught and that 1 action was triggered. It'll start read, then after a few seconds, cycle to green. If I hover over it, it'll say:

    User: Admin
    Details: GMail SMTP
    Status: Sent

    ... but I never get the email. I can check the sending account and confirm it never went out, as well.

    My msmtp.log file will have no entry for the attempt, so it doesn't appear to actually call the script.

    The fact that it doesn't always complain about not being able to find the script makes this twice as much fun. It's unquestionably where it's supposed to be, and I've set the access to 777 on that file.

    Presumably, there must be something wrong with my "zext_msmtp.sh", or possibly "msmprc". But I'm not getting any useful error messages to help me track this down.

    Anyone have any other ideas on where else I can look?
  • jluvs2ride
    Member
    • Jul 2015
    • 85

    #2
    Were you ever able to resolve this? I am having similar issues and email notifications are a critical item for me.

    Comment

    • grey
      Junior Member
      • Apr 2015
      • 2

      #3
      I'm reaching, here

      Yeah, I eventually got it working. TBH, I don't really remember what the problem was, but I can see that my "zext_msmtp.sh" & "msmtprc" were both changed a week after I posted that.

      If I had to guess the fix, I think I gave up on trying to use my personal mail server and just went with Gmail.

      Here's my msmtprc:

      ***

      # Default settings that all others account inherit
      defaults
      auth on
      tls on
      tls_starttls on
      tls_trust_file /etc/ssl/certs/ca-certificates.crt

      # Logging
      logfile /var/log/msmtp/msmtp.log

      keepbcc on

      # Gmail app
      account gmail
      host smtp.gmail.com
      port 587
      from ********@gmail.com
      user ********@gmail.com
      password ********

      # Gandi.net
      account gandi
      host mail.gandi.net
      port 465
      from noreply@********.org
      user noreply@********.org
      password ********

      # Default account to use
      account default : gmail

      Comment

      Working...