My server sends out emails via sendmail or SMTP, depending on the situation. I am trying to find logs for SMTP. Sources indicate that I should look at /var/log/maillog (https://serverfault.com/questions/59602/where-to-check-log-of-sendmail, https://www.centos.org/forums/viewtopic.php?t=8700)

That does indeed contain logs of everything sent over sendmail, but the SMTP messages are conspicuously absent.

When sendmail is used, it is done in a php script which just drops to shell and pipes message content to sendmail. Unfortunately, the SMTP is handled using a php class wrapper, which might account for the discrepency in logging.

Might they be being logged somewhere else? How can I determine that? Might logging for SMTP be turned off? How can I determine that, and if so turn logging on?

Using Centos 6.6 Final

closed as too broad by Jeff Schaller, Stephen Rauch, Anthon, GAD3R, Rui F Ribeiro Aug 28 '17 at 18:59

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • You say you did find some logs in /var/log/maillog. SMTP logs were never expected to store the actual contents of each email sent out ; is that what you're trying to get? – John WH Smith Feb 26 '15 at 20:36
  • @JohnWHSmith No, just the send timestamp. The sendmail logs just shows the addressees, and a timestamp of when it was sent. I am using it to determine if the system sent something. SMTP messages I know have been sent do not show up there at all. – chiliNUT Feb 26 '15 at 21:16
  • What do you mean with SMTP messages, as distinct to sendmail messages? You mean messages that some process directly sends out using a connection to another SMTP server on the network? Then that application should log this, your system doesn't log all outgoing network connections including layer 7 data... – wurtel Feb 27 '15 at 10:53
  • It seems to me that the PHP code would have specified an SMTP server, and you would need to look at that to find the answer. The answers to the bolded questions would all rely on that PHP code. – Jeff Schaller Aug 28 '17 at 0:31

If your PHP script is making direct SMTP connections, it is opening a socket (typically port 25 - but it could be any port). Unfortunately, you won't find a catch-all mail log because your server is never going to be aware this is a mail connection, and hence can't really log it (without special trickery or awareness, of course).

One thing you can do, however, is send all your mail through an MTA (like sendmail, qmail, exim etc.). Configure the MTA to use SMTP. Then the MTA will catch all outgoing mail and log it - as you expect.

Another trick would be to modify your PHP script to manually log the email - but I'm sure you considered this.

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