Ad Widget

Collapse

Authenticated SMTP How-To

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Authenticated SMTP How-To

    Here is a quick guide to setting up authenticated SMTP with Zabbix:

    As Zabbix doesn't natively support authenticated SMTP, you'll need to call an external SMTP client to do this for you. I use NBSMTP as a light-weight SMTP client...

    1) Download the latest version of nbsmtp

    http://nbsmtp.ferdyx.org/

    2) Compile nbsmtp with the following options (using /usr/local/nbsmtp as an example installation directory)

    ./configure --prefix=/usr/local/nbsmtp --enable-ssl
    make
    make install

    3) Create an script that can be called from Zabbix (by default, scripts are located in the zabbix/bin directory). Let's call this script smtp-auth

    smtp-auth should contain something like the following (change the variables to suit you. $1,$2,$3 are variables you set in the Zabbix PHP front end)

    #!/bin/sh

    export [email protected]
    export zabbixemailto=$1
    export zabbixsubject=$2
    export zabbixbody=$3
    export smtpdomain=mydomain.com
    export smtpserver=mail.mydomain.com
    export smtplogin=mylogin
    export smtppass=mypass

    echo "From: \"Zabbix Monitor\" <$smtpemailfrom>" > /tmp/mymailinput
    echo "To: $zabbixemailto" >> /tmp/mymailinput
    echo "Subject: $zabbixsubject" >> /tmp/mymailinput
    echo "" >> /tmp/mymailinput
    echo "This is an automated alert from Zabbix Network Monitoring. The mess
    age is $zabbixbody" >> /tmp/mymailinput

    /usr/local/bin/nbsmtp -d $smtpdomain -f $smtpemailfrom -h
    $smtpserver -U $smtplogin -P $smtppass-S < /tmp/mymailinput


    Save the smtp-auth script and make sure that it is executable. You can create a dummy /tmp/mymailinput script to test that you can successfully send email through your authenticated smtp server.

    So, the way this now works is that when an alert/action occurs in Zabbix, it should now call the smtp-auth script. Zabbix should pass in values for $1, $2, $3, the script calls nbstmp, and nbsmtp accepts the message in standard smtp format from /tmp/mymailinput.

    Mark
    Last edited by markpr; 29-03-2006, 22:34.

    #2
    Well done. Thank you!

    Comment


      #3
      Alternatively you can use sendEmail.

      1) apt-get install sendEmail

      2) Create a script "zabbix_sendemail" (chmod 755) in the AlertScriptsPath folder specified by /etc/zabbix/zabbix_server.conf
      --------------------------------------
      #!/bin/sh

      export [email protected]
      export zabbixemailto=$1
      export zabbixsubject=$2
      export zabbixbody=$3
      export smtpserver=yoursmtpserver.com
      export smtplogin=smtpuser
      export smtppass=smtppassword

      /usr/bin/sendEmail -f $smtpemailfrom -t $zabbixemailto -u $zabbixsubject -m $zabbixbody -s $smtpserver:25 -xu $smtplogin -xp $smtppass
      --------------------------------------

      3) Set the Action (Configurations / Actions in the php frontend)

      4) Set the Media Type (Administration / Media types in the php frontend) script to zabbix_sendemail

      5) Add the Media to the user (Administration / Users / user in php frontend)

      Comment


        #4
        Thanks to you both guys.

        I got a solution.
        Will this method be implemented into Zabbix in future?

        Comment


          #5
          Thanx! It works well (I use second solution with sendEmail, which I consider as simpler one).

          Best regards,
          Skygge.

          Comment


            #6
            delegate me !

            Hey guys,

            HEre is my contribution for my first post.
            I solved the same issue with "delegate" wich emulate all kinds of proxy :

            1) Download delegate on the website or from your repositories ;
            2) Compile it if you have to, it's so simple : "make" on the folder ;
            3) "mv" it from ./src/ to /usr/bin/ directory
            4) run => delegated -v SERVER="smtp://yoursmtp.com" -P25 MYAUTH=$USER:$PW
            5) Its ok, you just have to set up localhost has your smtp server in zabbix

            I can put the init.d script if someone is interested

            Comment


              #7
              the easiest and flexible solution to workaround smtp authentication ist to install a local mailer acting as smarthost. Suggestions for mailer daemon exim4 or postfix.

              Comment


                #8
                I'm agree for the flexible but not for the easiest !
                Everyone has'nt the knowledge to install an MTA.
                I've spent some night trying to install postfix and I prefere munch more to have a proxy.

                Comment


                  #9
                  your right with postfix. If you use debian/ubuntu its easiest to go with exim4.
                  You only need to configure for satellite and add credentials to the passwd.client.

                  Comment


                    #10
                    Originally posted by tekknokrat View Post
                    your right with postfix. If you use debian/ubuntu its easiest to go with exim4.
                    You only need to configure for satellite and add credentials to the passwd.client.
                    Honesly, if you can do a 6 step tutorial, for a secured and closed smtp server with the nice redirection to an authenticated server, I'll switch to exim4 and you'll help a lots of people

                    Comment


                      #11
                      thanks brow, this really helps.

                      Comment


                        #12
                        Hi, I am not sure if this is helpful, but I have found this page that talks about various kinds of email authentication and SMTP http://www.smtp.com/corporate.html -- you have to scroll down to the section called "Reputation Guard". Sorry if this is not helpful, it might be coals to Newcastle.

                        Comment


                          #13
                          Can you put the script of delegated?

                          Thanks

                          Comment


                            #14
                            sendEmail

                            Thank you for this,

                            in case it's useful to anyone, I followed the sendEmail recipe but it failed silently.

                            I had to enclose the arguments inside quotes as per http://www.zabbix.com/forum/showpost...30&postcount=6

                            also I had to refer to the script by name, not full path.

                            Comment


                              #15
                              I used dreas simple script and my zabbix audit>action logs showing that the mail is sent but I'm not receiving the mail

                              Here is my modified script:

                              #!/bin/sh

                              export [email protected]
                              export zabbixemailto=$1
                              export zabbixsubject=$2
                              export zabbixbody=$3
                              export smtpserver=localhost
                              export [email protected]
                              export smtppass=my-gmail-password

                              /usr/bin/sendEmail -f $smtpemailfrom -t $zabbixemailto -u $zabbixsubject -m $zabbixbody -s $smtpserver:25 -xu $smtplogin -xp $smtppass



                              When I manually execute the script replacing "export zabbixemailto=$1" with export zabbixemailto="[email protected]", I'm getting the following:

                              Sep 13 19:31:55 karmic9 sendEmail[14887]: Message input complete.
                              Sep 13 19:31:55 karmic9 sendEmail[14887]: NOTICE => Authentication not supported by the remote SMTP server!
                              Sep 13 19:31:56 karmic9 sendEmail[14887]: Email was sent successfully!

                              I can see mail in my inbox.

                              FYI,
                              I have postfix installed with gmail relay.
                              Plz need help

                              Comment

                              Announcement

                              Collapse
                              No announcement yet.
                              Working...
                              X