ZABBIX Forums  
  #1  
Old 06-09-2005, 21:16
markpr markpr is offline
Junior Member
 
Join Date: Sep 2005
Posts: 29
Default 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 smtpemailfrom=myemail@mydomain.com
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 at 22:34.
Reply With Quote
  #2  
Old 06-07-2006, 15:51
nick5000 nick5000 is offline
Junior Member
 
Join Date: Jun 2006
Posts: 12
Default

Well done. Thank you!
Reply With Quote
  #3  
Old 01-09-2007, 14:04
dreas dreas is offline
Member
 
Join Date: Aug 2007
Posts: 79
Default

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 smtpemailfrom=zabbix@yourdomain.com
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)
Reply With Quote
  #4  
Old 02-07-2009, 16:39
raghaven.kumar raghaven.kumar is offline
Member
 
Join Date: Mar 2008
Location: Bangalore
Posts: 33
Default

Thanks to you both guys.

I got a solution.
Will this method be implemented into Zabbix in future?
Reply With Quote
  #5  
Old 05-07-2009, 14:55
skygge skygge is offline
Junior Member
 
Join Date: Jun 2009
Posts: 12
Default

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

Best regards,
Skygge.
Reply With Quote
  #6  
Old 09-07-2009, 09:15
simtris simtris is offline
Junior Member
 
Join Date: Jul 2009
Posts: 4
Default 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
Reply With Quote
  #7  
Old 10-07-2009, 13:55
tekknokrat tekknokrat is offline
Senior Member
 
Join Date: Sep 2008
Posts: 137
Default

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.
Reply With Quote
  #8  
Old 10-07-2009, 14:20
simtris simtris is offline
Junior Member
 
Join Date: Jul 2009
Posts: 4
Default

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.
Reply With Quote
  #9  
Old 10-07-2009, 14:29
tekknokrat tekknokrat is offline
Senior Member
 
Join Date: Sep 2008
Posts: 137
Default

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.
Reply With Quote
  #10  
Old 10-07-2009, 14:44
simtris simtris is offline
Junior Member
 
Join Date: Jul 2009
Posts: 4
Default

Quote:
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
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 16:32.