Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

how can I see the emails sent by my web server ?

They are actually sent through a php script. Is there a way to keep track of them ?

thanks

ps. I'm using Ubuntu 10 (and 9) and Lighttpd

share|improve this question
    
Edit your question to tell us what OS you're using, and what web server. Otherwise, I can't tell you why your car's cigarette lighter isn't working. Maybe the fuse blew? –  mfinni Jan 25 '11 at 19:47

5 Answers 5

up vote 4 down vote accepted

There are many possibilities, all very much dependent on the architecture of your system:

  • Possibly easiest way: Let the script send (B)CC'ed mails to you or a special collection address. This should be configurable somewhere in the script.
  • If not, maybe the script logs it activities somewhere or could be configured to do this.
  • Surely the mail server which gets the mail does log something. This server could be configured to send copies to you as well.

As I said, it all depends on your system, and you don't tell us anything about it.

share|improve this answer
2  
/var/log/mail. Unless it's Windows. Or VMS. Or OS/400. Or Netware. –  mfinni Jan 25 '11 at 19:46
    
@mfinni I've checked var/log/mail.log but in this file are not registered the emails sent by (for example) drupal. They are sent with php and I don't have any mail server installed. –  Patrick Jan 26 '11 at 7:34
    
Patrick, so you have a Drupal installation and want to log the mails sent by it, yes? Do you use other PHP programs except Drupal where you want the mails logged? If yes, which? Please add this info to your question so other people who know Drupal can tell you what to configure there to make this possible. –  Sven Jan 26 '11 at 8:56

If you are looking for something to help you manage your emails and have some reports as to the status of those emails, take a look at PostageApp.

It's essentially a layer in between your app and SMTP and gives you a better idea of where emails are going, if and why they have been rejected, and you can even create templates to customize your content.

We have some documentation on sample PHP projects, so definitely check it out and let me know if it works out for you.

(Full Disclosure: I am the Product Manager for PostageApp.)

share|improve this answer

Did you see Amazon's announcment today about Simple Email Service?

Excerpt: "Amazon SES provides useful statistics about your sending activities. With a simple query, you can quickly obtain vital statistics such as volume sent, bounces and complaints."

Cheers

share|improve this answer
    
This isn't a very good answer to the question. It would be better as a comment to @JonLim's answer. –  mfinni Jan 25 '11 at 19:49
    
@mfinni, I removed the reference to another answer –  HTTP500 Jan 25 '11 at 19:51
    
You missed my point entirely. Unless Patrick is running on Amazon, this won't help him one bit. –  mfinni Jan 25 '11 at 20:14
2  
@mfinni, Where do you see that you have to be running your infrastructure on Amazon? See aws.amazon.com/ses/faqs/#1 Excerpt: "Amazon Simple Email Service (Amazon SES) is a highly scalable and cost-effective bulk and transactional email sending service for businesses and developers. Amazon SES eliminates the complexity and expense of building an in-house email solution or licensing, installing, and operating a third-party email service for this type of email communication. In addition, the service integrates with other AWS services..." –  HTTP500 Jan 25 '11 at 21:53
    
You're right, and I flagged this for the mods to remove my downvote. Of course, this doesn't help the guy for mails already sent. From his question, it doesn't say if he wants a new feature or is trying to figure out what already happened. –  mfinni Jan 26 '11 at 13:30

No matter how the emails are sent, the must use a MTA (Mail Transfer Agent) service. To keep track of the emails sent, go to the logs!

If it's a Linux server, you can use mailq or check the postfix queue. Same thing if you're using Sendmail.

Cheers.

share|improve this answer

Another thing to watch out is the "lovely" perl scripts that often get uploaded to out of date third party CMS installs. These often have their own SMTP engines which avoid the local mail log. Fortunately this is relatively easy to stop with iptables:

# Allow the root user to initiate outbound connections to port 25
iptables -A OUTPUT -m owner --uid-owner root -p tcp --dport 25 -j ACCEPT
# Allow the mail user to initiate outbound connections to port 25
# This presumes your mail server is running as mail
iptables -A OUTPUT -m owner --uid-owner mail -p tcp --dport 25 -j ACCEPT
# Allow anyone to connect to port 25 on localhost
iptables -A OUTPUT -p tcp -d 127.0.0.1 --dport 25 -j ACCEPT
# Allow anyone to connect to local relay server
iptables -A OUTPUT -p tcp -d relay.example.com --dport 25 -j ACCEPT
# Block all other outbound connections to port 25
iptables -A OUTPUT -p tcp --dport 25 -j REJECT

This will force all email to be sent through localhost or a local relay, and only the mail user and root user will be able to send mail outbound. This presumes you are running Linux, and that the ipt_owner module is avilable.

Also, there is the mail header patch for php here which will put the name of the script sending the mail in the headers. As far as I'm concerned it should be part of the core PHP, but unfortunately, it's not.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.