Koozali.org: home of the SME Server

Grep email receipients from a single user

Offline SchulzStefan

  • *
  • 620
  • +0/-0
Grep email receipients from a single user
« on: October 30, 2013, 10:18:40 AM »
Is there a way (or a contrib) to grep all email-adresses to the receipients from a single user? Any hint would be nice.

Thank's in advance,
stefan
And then one day you find ten years have got behind you.

Time, 1973
(Mason, Waters, Wright, Gilmour)

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Grep email receipients from a single user
« Reply #1 on: October 30, 2013, 11:07:48 AM »
please explain your problem and not your solution, thank you :-)

Offline SchulzStefan

  • *
  • 620
  • +0/-0
Re: Grep email receipients from a single user
« Reply #2 on: October 30, 2013, 11:28:43 AM »
As I described - I don't know how to grep out of the logs all email from a single user to his/her receipients. I simple do not know which log and what command could do it. I'd like to have the data in a file to check all email-adresses. Sorry for my bad english.
And then one day you find ten years have got behind you.

Time, 1973
(Mason, Waters, Wright, Gilmour)

Offline mmccarn

  • *
  • 2,651
  • +10/-0
Re: Grep email receipients from a single user
« Reply #3 on: October 30, 2013, 03:03:53 PM »
You could start with this:
Code: [Select]
grep logters.*\(queue /var/log/qpsmtpd/current and see what you get.

This will pull all 'logterse' (summary) entries from the qpsmtpd log that resulted in a successful delivery (vs a deny message).

The email sender and recipient address are in the second half of the results.

You might also try downloading qploggrep, then use
Code: [Select]
qploggrep <sender-email-address>
or
Code: [Select]
qploggrep <sender-email-address> |awk '{print $6}' |sort -u
If the user uses authenticated smtp relay, you'll need to figure out how to include /var/log/sqpsmtp/* in your searches...

However, this won't help you if the user has an email client or device that is relaying outbound email through google or another smtp server claiming to come 'from' his/her work email address -- hence the earlier question about 'what is the actual problem'...

Basically, the qpsmtpd logs will probably show you the same stuff you'd get from going to the user's 'Sent Items' folder and greping for 'To: ':
Code: [Select]
cd /home/e-smith/files/users/<username>/Maildir/.Sent\ Messages
grep ^To:\  * |awk '{print $2 $3 $4 $5 $6 $7 $8 $9 $10}' |sort -u
(repeat for ".Sent Items" and ".sent-mail"; include ".Trash", ".Deleted Items" and ".Deleted Messages" if you think s/he has been deleting things)

Offline SchulzStefan

  • *
  • 620
  • +0/-0
Re: Grep email receipients from a single user
« Reply #4 on: October 30, 2013, 07:20:27 PM »
Thank's a lot. That's exactly what I was looking for.

stefan
And then one day you find ten years have got behind you.

Time, 1973
(Mason, Waters, Wright, Gilmour)