Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 09-27-2013, 06:32 PM   #1
LQ Newbie
Registered: Jan 2011
Posts: 5

Rep: Reputation: 0
Unhappy postfix setup to work with email script.


Last edited by Mark382717; 09-30-2013 at 09:23 PM.
Old 10-05-2013, 09:08 AM   #2
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,898
Blog Entries: 27

Rep: Reputation: 2185Reputation: 2185Reputation: 2185Reputation: 2185Reputation: 2185Reputation: 2185Reputation: 2185Reputation: 2185Reputation: 2185Reputation: 2185Reputation: 2185
Moderator Response

Please do not edit content to remove the original content unless the changes correct the thread. Here at LQ we try to help everyone. New threads that are issues that may/will help you and other members are valuable to us at LQ. Please be patient for LQ members to respond thus hopefully helping you and other LQ members.

Original Post content with vbcode tags added for clarity;
I have cobbled together a small script that emails my username when an SSH connection is made by one of the people who I have given access too (Script listed below). The script works great, but I'd like to have it email a non local email address rather than just the local user.

I did some reading and according to the articles I found made the following changes. The email just still just sits in mailq. Any help getting this working would be greatly appreciated. Thanks in advance.

1) Added these lines to
relayhost =
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes
* is a the smtp server for the hosting company where I have my domain hosted.

2) Added this line to
-------------- : password

3) I then ran
postmap /etc/postfix/sasl_passwd

4) Then:
cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | tee -a /etc/postfix/cacert.pem

5) Finally, I restarted postfix:
/etc/init.d/postfix reload

The email script is as follows and resides in
# send email when any ssh login is successful
## set IP variable
ip=`echo $SSH_CONNECTION | cut -d " " -f 1`

# email subject
SUBJECT="SSH login just occurred."

# Email To ?

# Email text/message
echo "  -- Alert -- "> $EMAILMESSAGE
echo "SSH Login was successful">> $EMAILMESSAGE
echo "User $USER just logged in from $ip">> $EMAILMESSAGE
echo `date`>> $EMAILMESSAGE
echo "  -- End alert --" >>$EMAILMESSAGE
# send an email using /bin/mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
# clear contents of tmp file
echo "Blank File"> $EMAILMESSAGE
Thread now reopened!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to setup an email server easily with the postfix and dovecot commands baronobeefdip Linux - Server 4 02-08-2013 01:35 AM
postfix and email setup claybv Linux - Software 2 04-08-2008 05:01 PM
EMail server setup: FC6+Postfix+Dovecot+Squirrelmail rdnewman Linux - Networking 5 08-04-2007 07:59 PM
setup multi domains email in postfix importboy03 Linux - Software 1 04-29-2003 05:06 PM
How to setup Postfix to send email via POP dwynter Linux - Software 2 07-02-2002 12:21 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:41 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration