If you choose the option 'Send Email', the Email Message Subject and body become required fields, which I cannot 'leave blank to use the default message'.

...?
eR

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

endless_wander’s picture

I am having this issue as well.

Instructions say "Leave blank to use default message." But if I leave it blank, and have "Send Email" option checked, then I'm told "If Send Email has been enabled then an email subject line must set." and "If Send Email has been enabled then an email message must set."

pandersb’s picture

Version: 7.x-1.0-beta6 » 7.x-2.1

I get the same error when I check "Send Email" and leave the Message fields blank. And, I still haven't received the email in my inbox when I fill out the Message fields.

groston’s picture

Issue summary: View changes

Version 7.x-2.2 - same problem here

pauljaymes’s picture

Happens to me too, Version 7.x-2.2

I tried hacking user.inc, commenting out:
'#element_validate' => array('user_import_send_email_subject_validate'
and
'#element_validate' => array('user_import_send_email_message_validate'

If you do that it will use the default template, but it's useless as none of the default template tokens return anything.

What I had to do in the end was copy my default template onto the import page and change the tokens to the ones specified in the module.
For example:

[user:name] becomes !username
[site:name] becomes !site
[user:one-time-login-url] becomes !login_url
neerajskydiver’s picture

Status: Active » Needs review
FileSize
2.61 KB

Adding up new patch. This will add additional option of "Use drupal default mail to send email"
under "Send mail options" while importing users using csv file.

neerajskydiver’s picture

peter.moravek’s picture

I have version 7.x-2.2. I tried the patch, but there seems to be some bug in function _user_import_edit_settings_fields()

'#description' => t("Set each user's personal contact form to 'allowed'."),

The error displayed: "Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) ..."

veskimees’s picture

Same problem here (7-2.2).
Thanks for pauljaymes, its useful workaround (in custom welcome message):
[user:name] becomes !username
[site:name] becomes !site
[user:one-time-login-url] becomes !login_url

tassos’s picture

Hi,
I have this problem too in 7.x-2.2. The patch proposed in #5 goes around the problem. The intended behaviour is that if a user does not fill in a subject or body then the default will be used. The message reads "Leave blank to use the default message".

The patch bellow can be used to solve the problem. If the strings are left blank then sends the message with default. You can even override just one or the other. For example you can override the default subject with including it at the user_import form and leave subject blank for default message.

pepe631’s picture

Thank you tassos.

It works great! I had the same problem, but this fixed it. RTBC in 7.x-2.2

tassos’s picture

Status: Needs review » Reviewed & tested by the community

As per pepe631.

NaX’s picture

This patch worked for me but only after saving the account settings page "admin/config/people/accounts" because the variables don't exist yet in the variable table, and we not providing a default. I think their is a difference between variable_get() returning an empty string or null, but I don't think this should hold up this patch.

NaX’s picture

Status: Reviewed & tested by the community » Needs work

After some more testing I see this patch tries to fix issues with the sending of the email. Unfortunately the email still comes through but with lots of tokens missing.

The problem seems to be that _user_import_send_email() is still building the params list using the D6 method EG: !uid when token_replace is expecting the user object.

So I changed the params array to:

  $params = array(
    'user'         => $account,
    'subject'      => $subject,
    'body'         => $body,
    'email_format' => $format,
    'css'          => $css,
  );

and changed user_import_mail() to:

      $message['subject'] = (empty($params['subject'])) ? _user_mail_text('register_admin_created_subject', $message['language'], array('user' => $params['user'])) : strtr($params['subject'], $params);
      $body               = (empty($params['body'])) ? _user_mail_text('register_admin_created_body', $message['language'], array('user' => $params['user'])) : strtr($params['body'], $params);

And then everything worked without any notices and the email tokens were all correct. This could be looked at as a separate issue or part of a general sending email issue.

tassos’s picture

The module uses D6 string substitution. I think that this needs to be addressed in a different issue for the whole module. The idea behind the patch is that if a user chooses to fill in a subject or body in the import settings then he/she should be able to do so by following the instructions there (eg admin/people/user_import/add/1). These instructions have the D6 strings in them. In case the user leaves these empty then the default should be used as they are set in admin/config/people/accounts.

The defaults are set (within the default profile at least). Those used are on the tab named 'Welcome (new user created by the administrator)'. Could you please check your installation why this did not work in the first place? Do you need to visit the page to have the variables set? If so it sounds to me as a bug on the Account settings.

Thanks for you contribution.

myDrupal2014_846824658246’s picture

Same problem here (7-2.3)

davidraijmakers’s picture

I made a change which made it compatible with the 7.x-3 version

davidraijmakers’s picture

Status: Needs work » Needs review
davidraijmakers’s picture

I removed the user_load and send the user with the original parameters

Jamesap’s picture

I dont see why it should only work if the user has changed the default admin email.
I think we should only check if both or them are set, or none of them are set.
BR

Jamesap’s picture

Updating file

gisle’s picture

Version: 7.x-2.1 » 7.x-3.x-dev
Status: Needs review » Reviewed & tested by the community

Patch in #20 applies cleanly against most recent version of the 7.x-3.x branch and solves the problem.

Default welcome email with text for account created by an admin is sent, and token replacement works as expected.

Changing status to RTBC. Thank you Jamesap, for nailing this!

  • gisle committed 22446d4 on 7.x-3.x authored by Jamesap
    Issue #1962394 by Jamesap: Default Welcome Mail cannot be used
    
gisle’s picture

Status: Reviewed & tested by the community » Fixed

Committed to latest snapshot of 7.x-3.x-dev branch.

Status: Fixed » Closed (fixed)

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