Author Topic: best way to redirect email on test server  (Read 274 times)

Offline Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 951
  • Karma: 42
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
best way to redirect email on test server
« on: June 18, 2012, 02:35:29 am »
Hey there,

We have a test server that we don't really always want emails to be sent from.  I'm wondering what the best way to do this on a global level is.  We have access to postfix config so I am thinking we could probably write a rewrite rule that just sends them all a google apps address so that email from info@client.org.uk to supporter@gmail.com gets directed to test+supporter+gmail.com@thirdsectordesign.org or something similar.

And we could maybe set up specific rules for particular clients so if they want, so that email from info@sophisticated-client.org.uk to supporter@gmail.com gets directed to test+supporter+gmail.com@sophisticated-client.org.uk

The advantage of this is that we don't have to worry about the multitude of different ways that email can get sent out from the system: drupal civicrm, etc. and since we always use a local mail server it would work.

Appreciate that this might be more of a postfix question than an civicrm question and maybe i'll just need to read http://www.postfix.org/ADDRESS_REWRITING_README.html but experience, ideas, etc. appreciated.

Michael

Offline Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 14740
  • Karma: 440
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: best way to redirect email on test server
« Reply #1 on: June 18, 2012, 07:50:45 am »

1. drupal has a mail redirect module

2. You can probably extend that module and also implement the civicrm hook alterMailParams

3. CiviCRM has a defined constant where u can redirect all mail to a file system (or /dev/null)

lobo
Found this reply helpful? Contribute NOW and help improve CiviCRM with the Make it Happen! initiative.

Offline Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 951
  • Karma: 42
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: best way to redirect email on test server
« Reply #2 on: June 18, 2012, 12:37:20 pm »
hey lobo,

thanks for the input.  i did think about those options but but IMO  the problem with them is that they introduce lots of steps that you have to remember with each site that you set up, install the modules, edit your civicrm settings files. plus there is always the chance that some random module doesn't obey the rules that you have set up.

It seemed to me that since I can control the test server, I could just add the config to postfix and then no emails would get sent out ever.

Having said that, if I did do 2, it would only be one step to remember for each site. but still that is one step more than none.

PS. it seems like the best way to implement mail redirect would be to be redirect all mail by default and then turn off mail_redirect in the production environment, so that whenever you make another environment, email is redirected by default.  That is what mr felton's (very cool and useful) http://drupal.org/project/environment_indicator module does.