• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Michele Neylon :: Pensieri

Technology, Marketing, Domains, Thoughts

Logging Email From PHP Scripts

April 27, 2009 by Michele Neylon 2 Comments

This is more a note for myself than anything else ...

By default a lot of php scripts will send emails that appear as coming from the Apache user, which makes tracking down a rogue script really annoying and time-consuming.

You end up with entries in the mail logs similar to this one:

Apr 27 18:22:29 servername postfix/qmgr[23581]: 0F53421C1FA: from=<www-data@servername.com>, size=929, nrcpt=1 (queue active)

Which isn't particularly helpful if you have more than one site (vhost) on a particular server.

Making it a bit saner can be done via a simple addition to the Apache vhost config:

php_admin_value sendmail_path '/usr/sbin/sendmail -t -i -f address@domain.tld'

So now any emails sent from that vhost will reference the email specified instead of the Apache user:

Apr 27 19:40:34 servername postfix/qmgr[2469]: 16A8F21C1FA: from=<address@domain.tld>, size=358, nrcpt=1 (queue active)

There are other additions to Php that can log the path to the script itself, though until such time as someone makes it available for Debian / Ubuntu I don't really fancy having to compile it in manually

Related Posts:

  • Debugging a Broken WebsiteDebugging a Broken Website
  • Lazy Bad Marketing on SteroidsLazy Bad Marketing on Steroids
  • OSX Essential Apps - 2018 EditionOSX Essential Apps - 2018 Edition
  • Amazon UK and Brexit is a MessAmazon UK and Brexit is a Mess
  • Updating Your DPD Parcel Wizard Delivery AddressUpdating Your DPD Parcel Wizard Delivery Address
  • Even Big Companies Screw Up EmailsEven Big Companies Screw Up Emails

Filed Under: apache, Debian, Linux, Open Source, Spam Filtering, Techie :: Techno ::, Ubuntu Tagged With: apache, email, logging, mail, php, vhost

Michele is founder and CEO of Irish hosting provider and domain name registrar Blacknight. Read More…

Previous Post: « Cool Mugs Are Addictive
Next Post: Swine Flu Remedy »

Reader Interactions

Comments

  1. Steve Burke says

    April 27, 2009 at 11:29 pm

    On http://www.skynet.ie we use the following method for tracking emails sent via php and mail(). (After we admins previously spent hours tracking down rogue php scripts)
    It involves setting the sendmail path in php.ini to a sendmailwrapper.sh which logs the php script and hands off the mail to the real sendmail path.
    Full details on http://wiki.kartbuilding.net/index.php/Mail_-_mutt_etc#Log_PHP_and_mail.28.29

  2. Michele Neylon says

    April 28, 2009 at 12:03 pm

    Steve
    Thanks for sharing that tip – I might have a look into it as well
    Michele

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Primary Sidebar

dotblog founder

Most Recent Posts

Adjusting the Coffee Grind

Free Speech & Tech

Which Cookbooks?

How Many Books Should I Read?

Some Goals and Promises to Myself

Archives

  • Instagram
  • Twitter

Pages

  • About Me
  • About This Site
  • Archives
  • Comments Policy
  • Contact Me
  • Privacy

Footer

Site hosted in Ireland by Blacknight - Content copyright Michele Neylon

Copyright © 2021 · Magazine Pro on Genesis Framework · WordPress · Log in