Sometimes when I'm working on a website I just to redirect all email messages generated by the site to my personal email address so I can check them for formatting, spelling, etc. Rather than redirecting to a domain, I'd like to be able to enter a full email address and have that substituted for whatever is in $message['to'].

Comments

KeyboardCowboy’s picture

Status: Active » Needs review
StatusFileSize
new9.52 KB

Here's a patch to add the feature to redirect all mail to a single address.

achton’s picture

The patch above adds some whitespace cleanup and CVS stuff, and doesn't apply to 7.x-1.0. It does apply to the master branch though (there's no 7.x-1.x branch in the Git repo for this project).

Here's a patch that leaves out the whitespace fixing and CVS cleanup and applies to 1.0. No functional changes.

Pedro Lozano’s picture

StatusFileSize
new8.07 KB

Reroll against lates dev version and fixed indentation issues.

Pedro Lozano’s picture

Title: Email testing mode » Redirect to single email address

Fixing title.

rooby’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
StatusFileSize
new8.17 KB

Here is an updated version of the patch that changes:
* Some more indenting fixes.
* Some minor comment tweaks.
* Added #states support to settings so that the fields how and hide based on the mothod of redirecting.
* Rmoved redundenat code from mail_redirect_mail_alter() where it called mail_redirect_recipients() and then had the same code that was already in mail_redirect_recipients().
* Removed the $form['#validate'][] part of the form function because it is not required.
* Changes the update hook to be 7101 to follow naming convention. 7100 would be for upgrading from major version 7.x-0.x to 7.x-1.x

Still required (I didn't have time sorry):
* Update the mail_redirect_requirements() function so it works properly with the new settings.

liquidcms’s picture

seems like a reasonable addition to this module - thanks for the submission; a couple comments:

- i just fixed up a few things and released a 7.x-1.3 rel prior to seeing this patch; so patch likely won't apply as is anymore; but my changes were minor so likely it is close

- it doesn't look like your "to single address" is within the skip (which is mostly the area i made bug fixes to) - it needs to be covered by the "skip" option

- i don't really like the idea of adding text to the address body; but i guess when going to a single address it is the only way to see where it was headed. but then by that logic we should be doing that for the domain redirect as well since it only lets you see partially where it was originally intended. anyway; i would really prefer not to modify the email body - how about simply adding [@to] after the original subject?

liquidcms’s picture

Status: Needs review » Needs work
tomb-2’s picture

Re-rolled rooby's patch in #5 for latest version.
Modified it to append the subject instead of the body.

Edit: Named the patch wrong sorry, should be 1392248-8.

rooby’s picture

Status: Needs work » Needs review

Fixing status.

anybody’s picture

Status: Needs review » Reviewed & tested by the community

The patch works great! Tested on several websites.

Thank you so much! Can we get this into the next .dev or even stable?

liquidcms’s picture

Status: Reviewed & tested by the community » Needs review

setting to needs review should have triggered patch tester.. not sure why it didn't. when i run patch locally it fails.

setting back to needs review to try to trigger autotester

anybody’s picture

Are you sure that automated tests are enabled in the project settings (for the issues)? I think that may be required to run the test automatically here.

anybody’s picture

But again I can confirm that the patch works correctly in manual tests. I've just re-tried the whole process and everything works fine. :)

KeyboardCowboy’s picture

Status: Needs review » Reviewed & tested by the community

Updating status.

liquidcms’s picture

thanks. i enabled the autotester.

i have a very low tolerance for GiT. can you just attach a zip/tar of your entire version of folder and i can check it out and then just commit the entire thing.

sheldon rampton’s picture

@liquidcms: Improving your git tolerance will make life as developer easier. I speak as someone who struggled for awhile myself with git, but now I use it all the time and have come to appreciate it.

You might also want to check out dreditor:

https://drupal.org/project/dreditor

It's a web browser extension that makes it really easy to review and test patches without needing to use git directly. With a single click from within your web browser, you can spin up a test instance of Drupal using simplytest.me, including your module the patch already applied. I just tested it that way myself, and the patch applied cleanly and seemed to work. (I didn't test it fully, since other people have already done so.)

anybody’s picture

StatusFileSize
new12.72 KB

You can find attached the latest .dev Version of this module, patched with the latest patch above.

rooby’s picture

@liquidcms:

I would say patches would make things easier.

You can just do:

git clone --branch master http://git.drupal.org/project/mail_redirect.git
cd mail_redirect
wget https://drupal.org/files/mail_redirect-single_address-7397034-8.patch
patch -p1 < mail_redirect-single_address-7397034-8.patch
rm mail_redirect-single_address-7397034-8.patch
git add .
git commit --author="KeyboardCowboy <KeyboardCowboy@176328.no-reply.drupal.org>" -m "Issue #1392248 by KeyboardCowboy, rooby, tomb, achton, Pedro Lozano | Sheldon Rampton: Added Redirect to single email address."

You can also use git apply -v mail_redirect-single_address-7397034-8.patch instead of patch -p1 if you prefer.

There are actually more steps to commit the changes from a zip file than a patch.

liquidcms’s picture

thanks to everyone that is contributing to this; I especially like the #states support which i have not used before (but certainly will in the future).

a couple issues remaining as i am testing the zip included in #17 above:

1. many places in the code/docs that do not match the new changes: install, uninstall, requirements hook for status report entry, .info file, readme, etc - i think i have made all these changes to match the new feature - and tested.. :).

2. bigger issue is you did not do the part i mentioned in #6 about falling within the SKIP feature nor are you handling the case where a "To address" could actually be an address list (see comment in code about various email formats that drupal mail deals with).

i just have that fix to make and then will commit a new release.

@Anybody re: #10 - it is a pretty common thing to state "have tested" but testing is a pita for sure and only as good as the list of test cases. i would guess this works well for the 2 or 3 test cases you ran it on; but there are another 5-10 test cases i think you may have missed.

liquidcms’s picture

Status: Reviewed & tested by the community » Closed (fixed)

more changes required to support this than i originally thought; but should all be done now. please retest with published 7.x-2.0 rel.

one slight downside to how this was done was that existing site settings.php configs are no longer valid (and as a result a site upgrading to 2.0 rel with settings.php set will no longer have their mail redirected). for those who don't use this on larger sites that have live QA servers you may not see the significance of this - but it is an issue. i could have coded to be backward compatible; but didn't bother - although i made some BOLD comments concerning this on the project page.

kenorb’s picture