6068 comments
2357 subscribers
6186 on Twitter
Subscribe! Feed reader E-mail

Drupal tip: Test mail sending with Devel

If you don’t want to send lots of mail to your users when you’re testing your site, change the Devel module’s SMTP Library setting to “Log Only”. Then you can check your log to see all the mail that would’ve been sent. Handy!

To enable this only on your testing server, add the following to that domain’s settings.php:

$conf['smtp_library'] = drupal_get_filename('module', 'devel');
Short URL: http://sachachua.com/blog/p/5940
  • http://2bits.com Khalid

    Or you can use the reroute email module. This way you get all the emails by rerouted to an address you specify.

    http://drupal.org/project/reroute_email

  • Chris Cohen

    Sacha, can you not just choose the SMTP library from the devel settings screen, rather than using settings.php, then turn it off on the live machine?

  • http://sachachua.com Sacha Chua

    We frequently refresh our testing database with a backup from the production server, so any configuration changes would get lost.

    I already have some custom code that enables development modules. I could add an update or replace statement there.

    On the other hand, overriding it in the settings.php allows me to use normal mail delivery in my local testing environment, log-only mail delivery in the server testing environment, and normal mail delivery on the server.

    Khalid: That might be interesting. =) I’d have to set up an account that other testers have access to, though. This one works for now! =)

  • http://rtfverterra.mathalino.com RTFVerterra

    Hi Sacha, I really like your blog specially the Drupal Category. It’s great to hear Khalid in this post. I’ve been following your blog, in fact I copied the idea of your slogan.

    Thank you for posting this, its a great help, I am now doing a test in my social site.

  • Alex

    Some update – there is no need to modify settings.php as Devel has support for this.
    just navigate to Site configuration ->Devel and set SMTP library to ‘Log only”.

    • http://sachachua.com Sacha Chua

      That’s a convenient way of setting it in the database, yes. I find it useful to set it using PHP in my settings.php as well as in my base test case class, though. That’s because I typically work with other developers using an integration server. At some point in the development, we switch the integration server settings to send real mail. I still want to use debug mail on my system, and I want test cases to be able to analyze mail logs wherever they’re run. :)

On This Day...

  • 2013: Weekly review: Week ending March 22, 2013 — Lots and lots of drawing this week. =) Sketchnoted a conference, made a print, had lots of fun. Blog [...]
  • 2012: Ice cream season and the first seeds in the garden — It’s unseasonably warm by all accounts. The historic average for the next fourteen days is a high of 7C and [...]
  • 2011: The three argumenteers — (Or arguers, more correctly? But Argumenteers is a fun little reference.) Logos, ethos, and pathos. =) W- and I would like [...]
  • 2010: Presentation kaizen: Seven everyday ways to become a better presenter — Talk given at PresentationCamp. Presentation Kaizen View more presentations from Sacha Chua You need to have something worth presenting. Shortest [...]
  • 2010: How to brain-dump what you know — Why You’re going to need it. Why solve things twice? Write things down. You can save yourself the time it [...]
  • 2009: Outsourcing processes: Wake-up call — Here’s my process for my wake-up call: Every day, at the wake-up time I specified, please: Go to start.sachachua.com and sign in. Sign [...]
  • 2009: Wake up calls — I’m beginning to rather like wake-up calls. I set up a recurring task in Timesvr to have someone call me at [...]
  • 2007: Blogging: not just for extroverts — In the middle of my enthusiastic bubbling-over about IBM’s social software offerings, Hossam Ali-Hassan asked me, “Do bloggers tend to [...]
  • 2007: The magic of connection — There are many business reasons why social bookmarking makes sense, but let me tell you a personal story to show you [...]
  • 2007: It’s spring — Now I can believe that it’s spring. The sunlight is warm against my back. The sun gazes on me and I [...]
  • 2006: When it rains, it pours — Today (Thursday) is the area-level Toastmasters international speech contest. I don’t feel prepared for it at all. Unlike the other [...]
  • 2005: Traffic — Nagje-jaywalk na suso Nakita ko sa Quiapo Kay bilis nyang tumakbo Naunahan pa ako Thanks to Clair for getting tanaga into my head (I [...]
  • 2005: Microfinancing — Read technobiography: OT: Jun-jun the Parking Man and think about the poor. I think microfinancing is a good idea, BUT it [...]
  • 2005: How to hire great people — joelonsoftware has interesting insights on hiring the best people. He pokes holes in hiring fallacies like super-selection: “We’re so good we [...]
  • 2005: Wheeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee! — Hi Sacha, I just talked to the grad office. They were waiting for me to give my approval, oops. :) An offer [...]
  • 2004: MIT application — Deleted: Lost secret key.
  • 2004: Stanford: Stream data manager — http://www-db.stanford.edu/stream/index.html In applications such as network monitoring, telecommunications data management, web personalization, manufacturing, sensor networks, and others, data takes the form of continuous [...]
  • 2004: Using tla for archives — Look! I’m being used as an example! http://tkd.kicks-ass.net/planner/GnuArch.html That’s it, I’ve got to check out this checksumming thing… My name is [...]
  • 2004: Information retrieval course — http://www.csee.umbc.edu/~ian/irS01/ ../../notebook/plans/2004.03.23
  • 2004: School Bus — It’s not much, but if I don’t force myself to write, I might never get around to it. =) She glanced at [...]
  • 2004: cal-desk-calendar support for planner-diary.el — Travis B. Hartwell wrote: Hi all, I patched what I hope is the most recent version of planner-diary.el from tla to optionally utilize [...]
  • 2003: harvey chua — My mom wants to make sure her friends find her e-mail and our website. Harvey Chua
  • 2003: custom binding — I have bound keycode 131 to ( and keycode 129 to ) on my jp106 keyboard. 131 is the muhenkan [...]
  • 2003: deleting messages after N days — tips — I was somewhat apologetic about the lack of delete-after-N-days features in Linux mail clients, since my mom relies on that to [...]

Get the highlights as a PDF!

Stories from my Twenties: Highlights from a Decade of Blogging