Ad Widget

Collapse

Authenticated SMTP How-To

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MisterVertigo
    Junior Member
    • Nov 2014
    • 3

    #31
    Since my post I've made it one step closer! I was able to resolve my "certificate verify failed" by running the following:

    Code:
    zypper install ca-certificates ca-certificates-cacert
    zypper install ca-certificates-mozilla
    Now when I run the script manually as root, the e-mail gets delivered! Yay!

    Now, I can't seem to get the triggers to send the e-mail. Here is what I've done:

    1. My script is called "zabbix_sendmail". I have it located in /etc/zabbix

    2. I did the following commands to my script file:

    Code:
    chown root:zabbixs /etc/zabbix_sendmail
    chmod 4710 /etc/zabbix_sendmail
    I had to do the same thing with /usr/sbin/fping & /usr/sbin/fping6 to make the simple checks work, so I thought I may have to do it with this too. Here is what the output of ls -al is on the file:
    Code:
    -rws--x---  1 root zabbixs
    3. I edited my /etc/zabbix/zabbix-server.conf file with the following:
    Code:
    AlertScriptsPath=/etc/zabbix
    ExternalScripts=/etc/zabbix
    I'm pretty sure only the first one is what i need, but I changed them both just in case.

    4. I created a Media type called "Email via Google". For the type I chose "Script", and in the "Script Name" box I entered "zabbix_sendmail"

    5. I have a simple ping trigger that I can change that will set off the trigger. When I do so, the trigger goes off, and on the dashboard under "Last 20 issues" I see the alert. In the "Actions" column there is a green "1". When I mouse over it all is says under "Status" is "Sent". The name has my name in it as expected.

    However, I do not receive the e-mail. I'm relaying through Google. If I log in to the Google account that I'm relaying through I can see in my Sent Mail the test messages from when I was testing the script. However, the messages from Zabbix are not there.

    I feel like I'm so close I can taste it! Anyone have any suggestions as to what I may be missing? Thank you!

    Comment

    • MisterVertigo
      Junior Member
      • Nov 2014
      • 3

      #32
      Hopefully this will be my final post in this thread! I got the notifications to work. I changed the permissions on the script to chmod 777 and it works, so it was definitely a permission issue. If anyone has any advice as to what the proper permissions SHOULD be I'd love to know instead of leaving it at 777.

      Thanks!

      Comment

      • natcon93
        Junior Member
        • Apr 2015
        • 1

        #33
        I used the sendEmail solution for some time however t appears to have come unstuck.
        when I execute the script manually there are no issues however when zabbix attempts to run I get the following error in the log:
        sh: /usr/lib/zabbix/alertscripts/zabbix_sendemail.sh: /bin/bash: bad interpreter: permission denied.

        any I deas?

        Comment

        • shumik
          Junior Member
          • Aug 2014
          • 4

          #34
          Originally posted by natcon93
          I used the sendEmail solution for some time however t appears to have come unstuck.
          when I execute the script manually there are no issues however when zabbix attempts to run I get the following error in the log:
          sh: /usr/lib/zabbix/alertscripts/zabbix_sendemail.sh: /bin/bash: bad interpreter: permission denied.

          any I deas?
          I believe when you say "I execute the script manually" you run script as root user. Zabbix server run scripts as zabbix user. That must be the reason of your problem.

          Comment

          • DeamonMV
            Junior Member
            • Apr 2014
            • 13

            #35
            Hi all.

            I have a problem with own media in zabbix.
            I install sendemail and create scrip :

            Code:
             Zabbix server v2.2.7 (revision 50148) (24 October 2014)
            /home/zabbix/bin/emailsend
            Code:
            #!/bin/sh
            
            export [email protected]
            export zabbixemailto=$1
            export zabbixsubject=$2
            export zabbixbody=$3
            export smtpserver=smtp.yandex.ru
            export [email protected]
            export smtppass=kjZnPCax
            
            /usr/bin/sendEmail -vvvv -f $smtpemailfrom -t $zabbixemailto -u $zabbixsubject -m $zabbixbody -s $smtpserver -xu $smtplogin -xp $smtppass >> /tmp/log-sendemail.log
            edit zabbix_server.conf

            Code:
            AlertScriptsPath=/home/zabbix/bin
            owner of directories zabbix and zabbix/bin is zabbix.zabbix
            owner of /home/zabbix/bin/emailsend is zabbix.zabbix
            Code:
            -rwxr-xr-x 1 zabbix zabbix 377 гру  1 18:08 /home/zabbix/bin/emailsend*
            if i manual send email, like this:
            ./emailsend [email protected] test test

            I got an email.

            In zabbix I create another media type, with type "script"; in script name put "emailsend"
            Then create Action
            For user add only one media with this new media type.


            after trigger and action done in log of zabbix_server i got
            Code:
            /home/zabbix/bin/emailsend: 5: export: linux-pc: bad variable name
            /home/zabbix/bin/emailsend: 5: export: linux-pc: bad variable name
            where linux-pc - the host for which I tested trigger
            And no email I don't got
            And any information in /tmp/log-sendemail.log

            What it can be? how to resolve this issues
            Last edited by DeamonMV; 02-12-2015, 12:54.

            Comment

            • DeamonMV
              Junior Member
              • Apr 2014
              • 13

              #36
              Resolve problem there

              Ответили на вопрос 2 человека. Оцените лучшие ответы! И подпишитесь на вопрос, чтобы узнавать о появлении новых ответов.


              Code:
              #!/bin/sh
              
              export MAILTO="$1"
              export SUBJECT="$2"
              export TEXT="$3"
              
              export FROM="Zabbix Server <[email protected]>"
              
              export SMTP_SERVER=mail.domain.ru
              export SMTP_LOGIN=zbx
              export SMTP_PASSWORD=zbxPassword
              
              # -o message-charset=UTF8 чтобы приходили по русски
              /usr/bin/sendEmail -f "$FROM" -t "$MAILTO" -u "$SUBJECT" -m "$TEXT" -o message-charset=UTF8 -s $SMTP_SERVER:25 -xu $SMTP_LOGIN -xp $SMTP_PASSWORD

              Comment

              • dimir
                Zabbix developer
                • Apr 2011
                • 1080

                #37
                Support for SMTP authentication added in 3.0:



                Comment

                Working...