Inline documentation says 'Drupal sends emails whenever new users register on your site, and optionally, may also notify users after other account actions.', but it's not optional - e-mails are sent unconditionally. It'd be nice to have a checkbox per e-mail template to allow/disallow this e-mail sending : i'm going to import a batch of users, keeping their login/pass, i don't want each of them to receive a "your account has been created" mail.

In the meantime, i'm just going to comment drupal_mail calls in ldapprov.module, but it's a ugly hack.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

landry’s picture

Any news on that issue ?

What about adding a checkbox for each e-mail to conditionally send it, or if it's too complicated maybe send it only if the subject is not empty.. that'd be nice to avoid flooding users with e-mails when doing batch imports on them.

landry’s picture

So, more on this, i started hacking on that..

For the 5 email to send, only send if if subject is not empty, with something like :

if (drupal_strlen(variable_get('ldapprov_mail_create_subject', ''))) {
//code to send 'account creating notification email'
}

It works fine.. but the caveat is that if you set the subject for a given mail to an empty string, and save, it is correctly saved :

ldapprov_mail_create_subject | s:0:"";

but if you reload the configuration form, the default value is set back by the _ldapprov_mail_text() call.. as it is an empty string the following test at line 334 fails :

if ($admin_setting = variable_get('ldapprov_mail_'. $key, '')) 

So.. i'm not really sure the 'send only if subject is not null' is the better way to go.

Miglius, what do you think about it ? Are you interested in a full patch ? I'll see if i can make a proof-of-concept with an enable/disable checkbox for each e-mail..

landry’s picture

Status: Active » Needs review
FileSize
16.41 KB

So it wasn't that hard.. here's a new working patch, at least for me :

- add 5 boolean variables ldapprov_mail_$key_enable defaulting to TRUE
- add a checkbox for each variable on the admin interface
- only send the e-mail if the corresponding variable is TRUE (corresponding code is reindented)
- remove the variables upon uninstall

Moving status to 'needs review' accordingly..

landry’s picture

FileSize
17.88 KB

Whoops.. attached wrong patch. Here's the correct one.