Ad Widget

Collapse

Sending a notification through Gmail SMTP server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dvoracekp
    Junior Member
    • Jan 2010
    • 7

    #1

    Sending a notification through Gmail SMTP server

    Is there any way how to send notifications through Google's SMTP server?

    Thank you,
    Peter
  • untergeek
    Senior Member
    Zabbix Certified Specialist
    • Jun 2009
    • 512

    #2
    That's a good question. I presume you'd set it up like any other SMTP mail setup, but with the appropriate GMAIL account information.

    Comment

    • dvoracekp
      Junior Member
      • Jan 2010
      • 7

      #3
      Yes, but I do not want to install an SMTP server just for zabbix.

      Comment

      • untergeek
        Senior Member
        Zabbix Certified Specialist
        • Jun 2009
        • 512

        #4
        You misunderstand me, I think.

        Administration -> Media types

        Email Email SMTP server: "localhost", SMTP helo: "example.com", SMTP email: "[email protected]"

        Couldn't you change these values to point to the Gmail SMTP server?

        Comment

        • dvoracekp
          Junior Member
          • Jan 2010
          • 7

          #5
          No, this does not work. Google's SMTP server requires authentication, SSL and port 465 or 587.

          Look here:
          Zprávy z Gmailu můžete otevírat také v jiných poštovních klientech, které podporují protokol POP, jako je Microsoft Outlook. 1. krok: Ověřte, že je protokol POP ve vašem pÅ™ípadÄ› nejvho

          Comment

          • untergeek
            Senior Member
            Zabbix Certified Specialist
            • Jun 2009
            • 512

            #6
            You will either have to create a "forwarding" SMTP server then, which forwards to gmail, or a script (media type) which parses the data you send, then emails it via gmail.

            Comment

            • dvoracekp
              Junior Member
              • Jan 2010
              • 7

              #7
              And so I just to avoid this :-(

              Comment

              • JBo
                Senior Member
                • Jan 2011
                • 310

                #8
                Hi,

                Originally posted by dvoracekp
                And so I just to avoid this :-(
                As untergeek said, there are only 2 solutions: set a forwarding SMTP server or use a custom media type.
                If you want to use a custom media type, I have described how to use a Gmail account here.

                Hope this helps,
                JBo

                Comment

                • untergeek
                  Senior Member
                  Zabbix Certified Specialist
                  • Jun 2009
                  • 512

                  #9
                  JBo,

                  That is excellent! We may need to use something like that in the future, so thank you for the link!

                  Comment

                  • alledm
                    Member
                    • May 2012
                    • 84

                    #10
                    See the answer I gave to a similar problem here



                    all you need to do is to use stunnel as a client for the GMail server.

                    example conf file:
                    Code:
                    Code:
                    ; Use it for client mode
                    
                    client = yes
                    
                    ; Service-level configuration
                    
                    [ssmtp]
                    accept  = 25
                    connect = smtp.gmail.com:465
                    once properly configured, just set zabbix to send an email to your port 25

                    Comment

                    • fallwor
                      Junior Member
                      • Mar 2013
                      • 19

                      #11
                      JBo,

                      I tried your method. I'm facing the following problem:
                      When Zabbix executes the script I get the following error in zabbix-server.log:
                      Code:
                      /etc/zabbix/alert.d/zext_msmtp.sh: line 72: msmtp: command not found
                      sed: couldn't flush stdout: Broken pipe

                      When I execute the following code a mail sends to my e-mail address without issues.
                      Code:
                      sed 's/$/\r/' <<EOF | msmtp --account zabbix [email protected]
                      From: [email protected]
                      To: [email protected]
                      EOF
                      The chmod of zext_msmtp.sh is 777.
                      What do I do wrong?

                      ---
                      edit
                      ---
                      I also had to remove the tls support. doesn't find the key. There probably isn't any.
                      Last edited by fallwor; 22-03-2013, 16:51. Reason: additional info

                      Comment

                      • JBo
                        Senior Member
                        • Jan 2011
                        • 310

                        #12
                        Hi,

                        From your logs:

                        /etc/zabbix/alert.d/zext_msmtp.sh: line 72: msmtp: command not found

                        Have you installed msmtp utility ?
                        Regards,
                        JBo

                        Comment

                        • fallwor
                          Junior Member
                          • Mar 2013
                          • 19

                          #13
                          JBo,

                          Thanks fopr your quick reply.
                          Yeah, I installed msmtp from source. I'm using centos.
                          It works. I ran the command sed .... msmtp --account .... from command line and I receive the e-mail in my inbox.
                          the only issue is the script that makes sed not recognise msmtp ...

                          Comment

                          • JBo
                            Senior Member
                            • Jan 2011
                            • 310

                            #14
                            Code:
                            msmtp: command not found
                            means that the script cannot find msmtp command.
                            It is just a PATH problem.
                            If you have installed it from source, have you put it in one of the standard directories ?
                            On my server, I have:
                            Code:
                            # echo $PATH
                            /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
                            and msmtp is in /usr/bin

                            Comment

                            • fallwor
                              Junior Member
                              • Mar 2013
                              • 19

                              #15
                              I have this:
                              >echo $PATH
                              /usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

                              >whereis msmtp
                              msmtp: /usr/local/bin/msmtp
                              Besides I tried this:
                              ./zext_msmtp.sh e-mail test01 this is a message
                              I got the message which means something must go wrong in zabbix.

                              Comment

                              Working...