Sandbox installation, how to stop all mail from being sent?

Just added a “rubber cell”-site via multitenant setup. We now knock ourselves out experimenting on a fresh copy of the production db.

In order to not accidentally send out mail one must disable that in settings each time fresh data is copied over.

Question: Is there a way to disable outgoing mail other than in settings?

(i.e. bench --site [site] disable-outgoing-mail :slight_smile: )

I think you’ll need to use the API to script the create/modify the doctype controlling either the default sending account/active email account or use a testing environment that blocks outbound email ports using firewall rules.

If time/production requirements allow, you can disable the account prior to making the backup, and then enable it when the backup finishes.

Alternatively, you can find the setting within the text based SQL dump and manually edit the .SQL file to change the value of the sending email account, prior to the restore.

very good points volkswagner (and good name, too;) SQL might be the way to go, maybe even a cron job that disables the mail account every other hour or so. A firewall setting on the mta seems even more elegant though

HI @kombi:

After restoring your bd on “rubber-cell” site … have restored site_config.json or encryption_key value? AFAIK, and without encryption_key, stored passwords can’t be decrypted, so email shouldn’t work. Just curiosity …

Anyway, for testing purposes, I use to switch mail configuration to mailtrap account. It’s a fantastic tool. You can test any email behavior without sending out real emails.

Hope this helps.