Description
A simple and safe way to test and debug outgoing emails without having to worry that all your users will get unwanted emails.
Mail Safety provides a dashboard which catches and logs all outgoing mails.

Especially handy for development and staging environments. Can also be useful to enable the dashboard on a production website to debug e-mails in case there is a problem.

Similar modules
This module is similar to some existing mail modules but more focused on being a safety net and more precise debugging and testing.

Project
https://drupal.org/project/mail_safety

Git
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/barthje/1836812.git mail_safety

Reviews of other projects
http://drupal.org/node/1993640#comment-7411844 - Subfolder_Domain
http://drupal.org/node/1993640#comment-7425646 - Subfolder_domain
http://drupal.org/node/1971880#comment-7411974 - Profile2 XMLSitemap
http://drupal.org/node/1997706#comment-7425660 - LAKELET Qrigo
Three more reviews of other projects
https://drupal.org/comment/8227825#comment-8227825 - D7 Varnish All
https://drupal.org/comment/8227837#comment-8227837 - MediaCore Chooser
https://drupal.org/comment/8227849#comment-8227849 - Page2Images Websites Thumbnail

Comments

bennetteson’s picture

Status: Needs review » Needs work

Your branch name should be : 7.x-1.x.

Branch 7.x-1.0 (should be 7.x-1.x)
It appears you are working in the "7.x-1.0" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.

You should set a default branch http://drupal.org/node/1659588

  // Let other modules change the table structure to add or remove
  // information to be shown. e.g. attachments that need to be downloaded.
  $modules = module_implements('mail_safety_pre_view');

  foreach ($modules as $module) {
    $table_structure = module_invoke($module, 'mail_safety_pre_view', $table_structure);
  }

So you should use drupal_alter().

barthje’s picture

Thank you for your reply!

I made the necessary changes following your advise.

barthje’s picture

Issue summary: View changes

Edited git link

barthje’s picture

Status: Needs work » Needs review
PA robot’s picture

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

michielnugter’s picture

Status: Needs review » Reviewed & tested by the community

I have used the sandbox version in a project that heavily relied on sending emails. It's a very useful module that does everything that you need when debugging or just generally watching which emails are sent.

I have done a code review and other than the already fixed problems I can't find anything, as far as I'm concerned, it's reviewed and tested by the community and can be published as a full project.

bennetteson’s picture

Agree with michielnugter.
look RTBC for me.

bennetteson’s picture

Issue summary: View changes

Made changes to the branch.

barthje’s picture

Issue tags: +PAreview: review bonus

Added PAReview: review bonus

klausi’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -PAreview: review bonus +PAreview: security

manual review:

  1. mail_safety.api.php: the function bodies should have better examples.
  2. mail_safety_permission(): Both permissions need to have the 'restrict access' => TRUE flag enabled, because you can easily take over a site if you have access to all mails (password reset mails for admins and such). This is a security blocker, sorry. And please don't remove the security tag, we keep that for statistics and to show examples of security problems.
  3. theme_mail_safety_mail(): There are different opinions whether mail content should be escaped against XSS or not, but I think you should still add the appropriate sanitization functions here just to be safe (since you are displaying the mail in a HTML context). See also http://drupal.org/node/28984 Same for theme_mail_safety_details().
  4. mail_safety_enable(): don't juggle with module weights, that is unreliable and prone to errors. Use hook_module_implements_alter() instead if you want to influence the order of a specific hook.

Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

PA robot’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. Feel free to reopen if you are still working on this application.

I'm a robot and this is an automated message from Project Applications Scraper.

barthje’s picture

Status: Closed (won't fix) » Needs work

Still working on it! The summer kept me away from the project :)

Thanks klausie for the review! I'll fix your points and hope that will help.

barthje’s picture

Issue summary: View changes

Added review of other projects

barthje’s picture

Issue summary: View changes
Status: Needs work » Needs review

Hello klausi,

I've fixed all your issues/suggestions. I'm still not too sure about point number 3 though, but I'll use check_markup for now until I find something better.

Thanks!

PA robot’s picture

Status: Needs review » Needs work

There are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxbarthje1836812git

I'm a robot and this is an automated message from Project Applications Scraper.

barthje’s picture

Status: Needs work » Needs review

sigh... fixed that one.

kscheirer’s picture

Status: Needs review » Reviewed & tested by the community

I couple more similar modules - https://drupal.org/project/null_mailer and http://drupal.org/project/maillog.

  • In mail_safety_load() this code could be more efficient: foreach ($mails as $key => $mail) { foreach ($modules as $module) {...}}. It's unlikely to be a real problem unless there's tons of mails and more than 1 module implementing the hook, just something to be aware of.
  • There seems to be a fair amount of code duplication between mail_safety_admin_send_original_form_submit() and mail_safety_admin_send_default_form_submit(), you could probably abstract out the common portions.
  • I think you could use a confirm_form in mail_safety_admin_delete_form().

Those are not blocking issues though, the module looks nice!

----
Top Shelf Modules - Crafted, Curated, Contributed.

barthje’s picture

Thanks for the review!

I'll see if I can improve my code based on your points.

barthje’s picture

Issue summary: View changes
Issue tags: +PAreview: review bonus

Added PAReview: review bonus

klausi’s picture

Status: Reviewed & tested by the community » Needs work

manual review:

  1. hook_mail_safety_table_structure_alter(): do not call theme() here, just return a render array in the table. Drupal will render the whole thing later for you. Same in mail_safety_admin_dashboard_form().
  2. "'empty' => 'No mails found',": all user facing text must run through t() for translation. Please check all your strings.
  3. "t('Are you sure you want to send "!subject" to !to?', array('!subject' => $mail['mail']['subject'], '!to' => $mail['mail']['to']))": this looks a bit vulnerable to XSS exploits. The subject could be user provided text, so it should be sanitized before printing. Use the "@" or "%" placeholder with t() to perform sanitization. Please read https://drupal.org/node/28984 again. Also elsewhere.
  4. mail_safety_insert_mail(): This looks like an alter hook, so you should use drupal_alter(), right?
  5. mail_safety_admin_delete_form(): you could use confirm_form() here.

So not sanitizing the subject is a blocker right now, but otherwise this looks almost ready.

barthje’s picture

Status: Needs work » Needs review

Thank you for the review once again klausie! I fixed your list.
Also found some other sanitizing problems and checked all my t() functions. Plus I changed the send & delete forms to confirm forms.

klausi’s picture

Status: Needs review » Fixed

Looks good to me now and since this was RTBC already:

Thanks for your contribution, barthje!

I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

barthje’s picture

Issue summary: View changes
barthje’s picture

Thanks for all the help! Learned a lot from the reviews :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.