Koozali.org: home of the SME Server

Monitoring Mail

Offline Bud

  • *
  • 487
  • +0/-0
Monitoring Mail
« on: October 19, 2016, 05:11:10 PM »
guys please can you help

i need to find the following information regarding email for a user

messages from company z was sent to user1@domain.com ( sme 9.1 mail server )

user1 is complaining that 30 messages from company z was sent however user1 only received 4 messages

1. how to i check to see where the other messages went for user1?

2. how do i monitor what mail was sent to all users individually and from where the mail originated from for all the users on the sme 9.1 server

any help greatly appreciated  :D

« Last Edit: October 20, 2016, 05:29:23 AM by Bud »

Offline brianr

  • *
  • 990
  • +2/-0
Re: Monitoring Mail
« Reply #1 on: October 19, 2016, 06:31:24 PM »
all the information you'll need to understand this is held in the qpsmtpd logs:

/var/log/qpsmtpd/

and

/var/log/sqpsmtpd/

However you'll need to have some idea of times when the problems arose, and use tai64nlocal to decode the time stamp of the log entries.

I suggest something like this (untested)

cat /var/log/qpsmtpd/*.s | tai64nlocal | grep "time when the problem occurred"

(assuming your logs have rotated since it happened)

else:

cat /var/log/qpsmtpd/current | tai64nlocal | grep "time when the problem occurred"

Pulling out the "logterse" entries (which are summaries) is also a good trick, so add | grep "logterse" to the above. Beware the logterse lines are long!


Brian j Read
(retired, for a second time, still got 2 installations though)
The instrument I am playing is my favourite Melodeon.
.........

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Monitoring Mail
« Reply #2 on: October 20, 2016, 02:10:58 AM »
messages from company z was sent to user1@domain.com

The IT administrators of company z would be in the best position to investigate what happened to those messages.

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Monitoring Mail
« Reply #3 on: October 20, 2016, 02:12:40 AM »
all the information you'll need to understand this is held in the qpsmtpd logs:

Not necessarily. That depends on whether company z's mail server even made an attempt to connect to the relevant SME server (it's safe for us to conclude that "domain.com" is not actually the domain name of the server).

Offline Bud

  • *
  • 487
  • +0/-0
Re: Monitoring Mail
« Reply #4 on: October 20, 2016, 05:37:20 AM »
brianr and CharlieBrady, thanks for your help guys, really appreciated.

questions:
1. can you recommend what are the best contrib(s) for mail stats for per user and possibly the headers of mail per user? ( date received )
2. i need to send the user a log of what emails the user1 received per day/week or month. any ideas on how to compile the log to send to user1 or users?
3. how do i show what was junk mail for user1 or users?
4. what contrib(s) do you recommend to backup all mail messages for each user on the sme 9.1 server?
5. is there a way to use tai64nlocal for showing what email a single user has received/sent per day/week/month?

thanks again
« Last Edit: October 20, 2016, 05:45:08 AM by Bud »

Offline brianr

  • *
  • 990
  • +2/-0
Re: Monitoring Mail
« Reply #5 on: October 20, 2016, 08:36:07 AM »
There are no contribs that I know of will fulfill the logging requirements that you mention however the smeserver-mailstats contrib is well worth installing (I would say that wouldn't I - I wrote it?) to get an idea about email, spam, etc.

There is a newer version than the one in the contribs repo, but it needs the updated qpsmtpd as well. which should come with version 9.2 (which is in beta).

Email backup is handled by any of the backup systems (e.g. dar or Affa).
« Last Edit: October 20, 2016, 01:04:58 PM by brianr »
Brian j Read
(retired, for a second time, still got 2 installations though)
The instrument I am playing is my favourite Melodeon.
.........

Offline mmccarn

  • *
  • 2,653
  • +10/-0
Re: Monitoring Mail
« Reply #6 on: October 20, 2016, 12:50:08 PM »
Here are some notes on analyzing the existing mail log files:
https://wiki.contribs.org/Mail_log_file_analysis

Here are some notes on getting various stats on how your email is performing:
https://wiki.contribs.org/Email_Statistics

From the second link, this command can be used to list all emails received (or blocked) from a given email address or domain:
Code: [Select]
echo -n "TLD to review: "; read TLD; qploggrep $TLD\> |tai64nlocal |awk '{print $1 " "  $2 "\t" $4 "\t" $5 "\t" $6 "\t" $7}'
Note that if the emails are being blocked by one of the early qpsmtpd plugins (dnsbl, check_earlytalker, require_resolvable_fromhost) your log files will not contain the sending email address, only the sending IP address.

If you know the IP address of the sending mail server, you could use this command to easily figure out if the recipients are deleting or moving the messages after they are received:
Code: [Select]
DAYS=1; echo -n "Days of email to scan [$DAYS]: "; read NEWDAYS; \
find /home/e-smith/files/users -name *$(config get SystemName):* -ctime -$DAYS -exec egrep -H "^Received:\ from\ " "{}" \; |\
grep -v "$(config get LocalIP)" |\
egrep "HELO|EHLO" |\
awk -F"[():]" '{ print $1 "\t" $7}'

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Monitoring Mail
« Reply #7 on: October 20, 2016, 05:10:00 PM »
5. is there a way to use tai64nlocal for showing what email a single user has received/sent per day/week/month?

tai64nlocal does nothing but convert from one timestamp format to another (from tai64 time format to human readable local time).

Offline Jean-Philippe Pialasse

  • *
  • 2,912
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Monitoring Mail
« Reply #8 on: October 22, 2016, 03:44:40 PM »
Smeserver-isoqlog might partly answer your needs.
https://wiki.contribs.org/Isoqlog

Offline Bud

  • *
  • 487
  • +0/-0
Re: Monitoring Mail
« Reply #9 on: October 24, 2016, 12:50:01 PM »
guys thank you for your help

i have installed the SMEOptimizer Contrib and are getting good stats from that

i have done a signal-event post-upgrade; signal-event post-reboot

however now i am not receiving any mail for my users  :shock:

how do i check where the issue is for not receiving any email from a remote catchall pop3 mailbox

any help greatly appreciated

Offline Bud

  • *
  • 487
  • +0/-0
Re: Monitoring Mail [ SOLVED ]
« Reply #10 on: November 01, 2016, 08:57:21 PM »
guys what can i say.

it works!!

thank you to all that helped me, much appreciated  :)

Offline Bud

  • *
  • 487
  • +0/-0
Re: Monitoring Mail
« Reply #11 on: November 29, 2016, 06:36:50 AM »
some more questions

i seem to have a lot of issues with being blacklisted ( http://mxtoolbox.com/blacklists.aspx )

using sme 9.1 server

client has a static ip address

the mail for the client is collected via a catchall account on a hetzner server

i think the blacklisting is due to the following:

1. spam being sent out from a pc(s) / server(s) ?
2. to much mail being sent out via smtp from the sme 9.1 server. ie: more than 300 messages per hour
3. ???

questions:
1. how do i limit outgoing mail from the sme 9.1 server to no more than 290 messages per hour?
2. how do i determine what pc(s) / servers(s) on the lan are sending out spam?
3. how can i get a report emailed to me?
4. should i use a different smtp service provider?
5. how do i limit being blacklisted?
6. is there a way to monitor blacklisting and in the event thereof being sent a report via email?

any help greatly appreciated  :)

Offline zatnikatel

  • *****
  • 190
  • +0/-0
Re: Monitoring Mail
« Reply #12 on: November 29, 2016, 09:57:28 AM »
how you tried Wireshark on you network to see where all the email is going by ip address run on a PC Linux or windows pc and set it to scan port 25 and it will list the IP address that using port 25

Offline Bud

  • *
  • 487
  • +0/-0
Re: Monitoring Mail
« Reply #13 on: June 08, 2017, 06:28:49 AM »
Server sensing Email Out Issue

Huge amount of mail being sent out to three email addresses from sme 9.2  :shock:

presse@filmportal.de
jvcyr2002@yahoo.com
davidjones@live.com


they do not stop being sent out with the result all user mail being sent from users are not being delivered

how do i stop the three email addresses on the server

any help greatly appreciated
 

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Monitoring Mail
« Reply #14 on: June 08, 2017, 10:11:30 AM »
first of all, check your clients have no virus/malware

if your SME hosts some web sites, check they are ok

Offline mmccarn

  • *
  • 2,653
  • +10/-0
Re: Monitoring Mail
« Reply #15 on: June 08, 2017, 12:38:46 PM »
If you don't normally talk to any of these domains, or to stop all email to these domains while you debug the problem, you could create 'filmportal.de', 'yahoo.com' and 'live.com' as local domains on your SME server, find and fix the source of the problem, then delete the local domains.

Offline mmccarn

  • *
  • 2,653
  • +10/-0
Re: Monitoring Mail
« Reply #16 on: June 08, 2017, 12:42:45 PM »
It's possible that email to these specific addresses would be dropped if you create qmail's 'badmailto' control file and restart qmail:

Code: [Select]
echo 'presse@filmportal.de
jvcyr2002@yahoo.com
davidjones@live.com' > /var/qmail/control/badmailto
sv t qmail

If that causes problems, or when you're done debugging, remove the file and restart qmail again:
Code: [Select]
rm -f /var/qmail/control/badmailto
sv t qmail

[edit]
No - this doesn't seem to work... (I attempted to block a test email, but could still send to it through my SME server).
« Last Edit: June 08, 2017, 12:47:58 PM by mmccarn »

Offline Bud

  • *
  • 487
  • +0/-0
Re: Monitoring Mail
« Reply #17 on: June 12, 2017, 02:56:55 PM »
Stefano

thank you for your help

i am getting tons of the following in my qmail

----------------------------------------

Qmail message queue, viewed at:
Mon Jun 12 14:42:55 2017
2259620 (8, 8/2259620)
  Return-path: davidjones@live.com
  From: "Mr.David Jones" 'davidjones@live.com'
  To: Recipients 'davidjones@live.com'
  Subject: YOUR IMMEDIATE ATTENTION IS REQUIRED
  Date: Mon, 12 Jun 2017 07:54:15 +0000
  Size: 1008 bytes

2254748 (12, 12/2254748)
  Return-path: davidjones@live.com
  From: "Mr.David Jones" 'davidjones@live.com'
  To: Recipients 'davidjones@live.com'
  Subject: YOUR IMMEDIATE ATTENTION IS REQUIRED
  Date: Mon, 12 Jun 2017 06:47:00 +0000
  Size: 1008 bytes

2257480 (7, 7/2257480)
  Return-path: davidjones@live.com
  From: "Mr.David Jones" 'davidjones@live.com'
  To: Recipients 'davidjones@live.com'
  Subject: YOUR IMMEDIATE ATTENTION IS REQUIRED
  Date: Mon, 12 Jun 2017 07:24:32 +0000
  Size: 1008 bytes

2255955 (0, 0/2255955)
  Return-path: davidjones@live.com
  From: "Mr.David Jones" 'davidjones@live.com'
  To: Recipients 'davidjones@live.com'
  Subject: YOUR IMMEDIATE ATTENTION IS REQUIRED
  Date: Mon, 12 Jun 2017 07:03:42 +0000
  Size: 1008 bytes

2256608 (9, 9/2256608)
  Return-path: davidjones@live.com
  From: "Mr.David Jones" 'davidjones@live.com'
  To: Recipients 'davidjones@live.com'
  Subject: YOUR IMMEDIATE ATTENTION IS REQUIRED
  Date: Mon, 12 Jun 2017 07:12:47 +0000
  Size: 1008 bytes

2254519 (13, 13/2254519)
  Return-path: davidjones@live.com
  From: "Mr.David Jones" 'davidjones@live.com'
  To: Recipients 'davidjones@live.com'
  Subject: YOUR IMMEDIATE ATTENTION IS REQUIRED
  Date: Mon, 12 Jun 2017 06:43:56 +0000
  Size: 1008 bytes

2254026 (3, 3/2254026)
  Return-path: davidjones@live.com
  From: "Mr.David Jones" 'davidjones@live.com'
  To: Recipients 'davidjones@live.com'
  Subject: YOUR IMMEDIATE ATTENTION IS REQUIRED
  Date: Mon, 12 Jun 2017 06:36:45 +0000
  Size: 1008 bytes

------------------------------------------------------

with the result no mail is going out as the isp is blocking any delivery of mail

how do i find out where the message originates from? what pc, hostname, user, ip on the lan ?

any ideas  :(




Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Monitoring Mail
« Reply #18 on: June 12, 2017, 05:09:41 PM »
Check qpsmtpd log to see who is injecting those emails

Offline Daniel B.

  • *
  • 1,700
  • +0/-0
    • Firewall Services, la sécurité des réseaux
Re: Monitoring Mail
« Reply #19 on: June 12, 2017, 05:49:45 PM »
Check qpsmtpd log to see who is injecting those emails
It could be injected in qmail directly by eg, a compromised web application
C'est la fin du monde !!! :lol:

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Monitoring Mail
« Reply #20 on: June 12, 2017, 05:55:36 PM »
Indeed, my bad (I'm on the phone..)
So, Bud, check both qmail and qpsmtpd logs

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Monitoring Mail
« Reply #21 on: June 12, 2017, 08:01:02 PM »
Indeed, my bad (I'm on the phone..)
So, Bud, check both qmail and qpsmtpd logs

IMO it will be quicker and more useful to find one such message in the queue and look at its Received: headers.

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Monitoring Mail
« Reply #22 on: June 12, 2017, 08:03:13 PM »
with the result no mail is going out as the isp is blocking any delivery of mail

how do i find out where the message originates from? what pc, hostname, user, ip on the lan ?

You need to:

1. stop qmail and qpsmtpd
2. identify the source of the problem and then fix it.
3. clean your mail queue of all the bad messages
4. restart qmail and qpsmtpd

You may need to interact with your ISP and/or with some email blacklists before you will then be able to send email via your ISP.

Offline Bud

  • *
  • 487
  • +0/-0
Re: Monitoring Mail
« Reply #23 on: June 13, 2017, 05:27:25 AM »
thank you everyone for your input and support

CharlieBrady

2. identify the source of the problem and then fix it. - that is exactly what i am trying to do. what do you recommend i do to identify the source(s) ?
3. clean your mail queue of all the bad messages - how do i determine where in my mail queue all the bad messages are or do you recommend i do the following ?

sv d /service/qmail
mv /var/qmail/queue /var/qmail/queue.spam
yum -y reinstall qmail
signal-event email-update

any help appreciated  :-)

Offline Daniel B.

  • *
  • 1,700
  • +0/-0
    • Firewall Services, la sécurité des réseaux
Re: Monitoring Mail
« Reply #24 on: June 13, 2017, 06:25:50 PM »
Look at your logs (/var/log/qmail/current and /var/log/qpsmtpd/current), you should be able to identify where those emails are comming from. You can also check the raw message. Eg, identify one of those spam in qmail queue:

Code: [Select]
grep -r 'IMMEDIATE ATTENTION' /var/qmail/queue/mess

Then, open one of the result

Code: [Select]
less /var/qmail/queue/mess/22/2097530

And look especially at the headers. You should either see the client IP if it was submitted through qpsmtpd, or the uid of the user if injected directly in qmail. Depending on that, you can investigate further.
« Last Edit: June 13, 2017, 06:44:44 PM by Daniel B. »
C'est la fin du monde !!! :lol:

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Monitoring Mail
« Reply #25 on: June 13, 2017, 09:47:17 PM »
sv d /service/qmail
mv /var/qmail/queue /var/qmail/queue.spam
yum -y reinstall qmail

This will give a new clean qmail queue, but you will be left with some valid messages stuck in the old queue. I would recommend you be more selective on deleting messages from the existing queue. But it's up to you...
 

Offline Jean-Philippe Pialasse

  • *
  • 2,912
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Monitoring Mail
« Reply #26 on: June 13, 2017, 10:18:54 PM »
using qmHandle (https://wiki.contribs.org/Qmhandle_mail_queue_manager)


Code: [Select]
qmHandle -h'davidjones@live.com'
will delete all the emails in the queue with the email davidjones@live.com in headers

Offline Bud

  • *
  • 487
  • +0/-0
Re: Monitoring Mail
« Reply #27 on: June 21, 2017, 06:17:22 AM »
guys thank you for all your help, much appreciated

ok so i get this problem every day regarding davidjones@live.com

i check the queue and logs
i do a " grep -r 'YOUR IMMEDIATE ATTENTION IS REQUIRED' /var/qmail/queue/mess "
i get over 9k of mail messages from " davidjones@live.com "
with the result i have to keep deleting the emails as per Jean-Philippe Pialasee: qmHandle -h'davidjones@live.com' every day

an example of the " /var/log/qpsmtpd/current "

2260492 (6, 6/2260492)
  Return-path: davidjones@live.com
  From: "Barr.David Jones" 'davidjones@live.com'
  To: Recipients 'davidjones@live.com'
  Subject: YOUR IMMEDIATE ATTENTION IS REQUIRED
  Date: Tue, 20 Jun 2017 16:28:57 +0000
  Size: 1008 bytes

an example of " less /var/qmail/queue/mess/6/2260492 "

Received: (qmail 15347 invoked by uid 453); 20 Jun 2017 16:08:18 -0000
Authentication-Results: mysmeserver.com; auth=pass (login) smtp.auth=theresa
Received: from Unknown (HELO [104.192.4.19]) (104.192.4.19)
 by mysmeserver.com (qpsmtpd/0.96) with ESMTPSA (DHE-RSA-AES256-SHA encrypted); Tue, 20 Jun 2017 18:08:18 +0200
Content-Type: text/plain; charset="iso-8859-1"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Description: Mail message body
Subject: YOUR IMMEDIATE ATTENTION IS REQUIRED
To: Recipients <davidjones@live.com>
From: "Barr.David Jones" <davidjones@live.com>
Date: Tue, 20 Jun 2017 16:07:57 +0000
Reply-To: davidwhite_chambers@yahoo.com

Attention:

I am David Jones Attorney to the late Engr.Steve Moore who died with his wi=
fe and their three kids in a car accident.

Before his death he had funds valued at $27 Million deposited in a bank

I need your assistance to retrieve the money left behind by my client.

Get back to me for more details.

Thanks

Barr David Jones

please guys i need help on how do i get rid of this problem  :?

« Last Edit: June 21, 2017, 06:24:59 AM by Bud »

Offline Daniel B.

  • *
  • 1,700
  • +0/-0
    • Firewall Services, la sécurité des réseaux
Re: Monitoring Mail
« Reply #28 on: June 21, 2017, 06:29:44 AM »
The theresa account on your server is compromised. Change its password ASAP, and then cleanup the qmail queue
C'est la fin du monde !!! :lol:

Offline Bud

  • *
  • 487
  • +0/-0
Re: Monitoring Mail
« Reply #29 on: June 21, 2017, 06:46:11 AM »
Daniel B. thank you for your quick reply

you mentioned " cleanup the qmail queue "

how do i do that?

i have done so, i will monitor and reply

thank you  :)
« Last Edit: June 21, 2017, 06:52:45 AM by Bud »