Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Security
User Name
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.


  Search this Thread
Old 11-08-2012, 05:01 AM   #1
Registered: Sep 2007
Posts: 119

Rep: Reputation: 17
Question Trying to find out what is sending mail on my server

For the past few months, I noticed my mail queue has been increasing in size to an average of about 50 undelivered mails. When I look at my mailqueue, I see entries like these:

E20C4229A7     1493 Tue Nov  6 09:58:13  www-data@<servername>
                    (connect to[]: Connection timed out)
Apparently, these emails are being sent locally and not through relaying. Besides I've tested the server many times and it's not an open relay.

I have a few websites running on this server, each has a forum running. So at first I thought these were spam signups but if I look at the forums' log files, I don't see the emails found in the queue. So it looks like it's not coming from the forums.

The fact that postqueue only lists email that it fails to deliver to, I believe this is only a small percentage of the true number of email this server sends out.

Is there a way to find out where these emails come from? Which process/program is sending them?
Old 11-08-2012, 09:05 AM   #2
Senior Member
Registered: Jul 2007
Distribution: Ubuntu 10.10, Slackware 64-current
Posts: 2,124

Rep: Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779Reputation: 779
The fact that the logs are showing it coming from ww-data@<servername> suggests that it could be coming from your web server, or at least the web server user which could mean someone hijacking a process owned by that user. As you mention a forum, it is also possible that you have content that contains the code to send messages. This is a common trick. The first thing to check would be to see if the versions of software your running on your system have known vulnerabilities that could explain this.

Following that, your idea to try to track down the process is the way to go. However, this can be a little bit tricky, especially if your log files are not showing the process / user. Part of the problem will be to capture it happening as almost all of the tools used will give you static snapshots. You could try something like the following (borrowing from one of unSpawns posts):
( \ps axfwwwe 2>&1; lsof -Pwln 2>&1; \ls -al /var/spool/cron 2>&1; netstat -anpe 2>&1; lastlog 2>&1; last 2>&1; who -a 2>&1 ) > /path/to/data.txt
This will concatenate the process tree into a file called data.txt and should show if you have any rogue processes running.

The next level up the difficulty chain would be to try to use a program like iftop, tcpdump to capture traffic on your local loopback interface and see what you can find making use of port 25. You could also try shutting down a service, like your web server, to see if it stops.

However, given that your logs are showing the user being www-data and that you are running a user content forum system, I would start looking through the post content.
Old 11-08-2012, 01:57 PM   #3
Registered: Sep 2007
Posts: 119

Original Poster
Rep: Reputation: 17
Yes, www-data is the user apache runs as. So I know it's coming from one of the forums but I don't know which one. The largest is running on forum software I wrote myself and although I can never be 100% sure of course, I'm pretty sure I didn't leave some glaring holes open through which mail can be relayed.

Then there are a few smaller forums that run on phpBB. I don't know anything about that.

Simplistically thinking, couldn't I just rename postfix (sendmail) to postfix2 and then write my own little script and call that postfix? That way intercept all outgoing email and log which process is calling postfix?
Old 11-08-2012, 02:54 PM   #4
Registered: Sep 2007
Posts: 119

Original Poster
Rep: Reputation: 17
Ah, never mind. I found out what was sending the emails. It's actually my honeypot forum sending out confirmation emails to fake email addresses used by the spammers. This forum was actually the first forum I checked but I was looking at the wrong database when I cross-referenced the email addresses...


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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Slowing the mail sending queue at mail server level Luna-tic Linux - Server 1 02-29-2012 10:04 AM
Mail server not sending mail to location defined in MX record modulaaron Linux - Software 3 12-19-2010 07:57 PM
sending mail from win xp to linux imap mail server cvdsamy Red Hat 2 05-30-2009 12:37 AM
Perl/Web (www) server needs to use mail server for sending forms. dskv Linux - Server 4 04-08-2008 12:34 PM
Cron mail sending using outside SMTP mail server Utah Linux - Software 6 08-24-2005 07:44 PM > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 08:15 PM.

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