Skip to content

Instantly share code, notes, and snippets.

@ramsey
Created June 23, 2009 19:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramsey/134784 to your computer and use it in GitHub Desktop.
Save ramsey/134784 to your computer and use it in GitHub Desktop.
Script to redirect mail in a staging environment
#!/bin/sh
################################################################################
# Script to redirect mail in a staging environment
#
# Set this script to executable (chmod 755), and modify php.ini in the staging
# environment to use this script instead of sendmail:
#
# sendmail_path = /path/to/trapmail.sh
#
################################################################################
perl -pe 's/subject: ([^ ]*)/Subject: [Staging] \1/i' \
| formail -f \
-R cc X-Original-Cc \
-R to X-Original-To \
-R bcc X-Original-Bcc \
-A"To: <user1@example.org>, <user2@example.org>" \
| /usr/sbin/sendmail -t -i
@cswilliams
Copy link

just what i was looking for, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment