2

I have some troubles with D7 migrate module and sending emails.

I made a migrate class to import users via CSV files. The import works well, all my users are created. But I need to send emails when the new user is created.

So I have implemented the migrate complete() function in my class like this:

public function complete($entity, stdClass $row) {

    // some stuff here

    // Operation.
    $op = 'register_admin_created';

    // Send an email.
    _user_mail_notify($op, $user);
  }

It's here were troubles comes, I use the _user_mail_notify() function to shoot the mail to the new created user.

The process looks good, the mail logger module shows me the mail result, but in fact the user don't receive the mail.

I already try to create a user via the administration people menu and when a check the "Notify user of new account", I do receive the mail notification.

In Fact, the process that I have implemented in my migrate class looks like the process when you create a user manually via the admin interface and when you check "Notify user of new account".

I have to tell you that I also implement a mail interface, to be able to shoot emails with HTML / CSS. In this case, I just add a header and footer to the mail. All emails sending via my custom mail interface are sent and render properly. Only the emails sending during migration process are not send.

If you have some ideas about that problem, or if you need more information don't hesitate :)

Thank's,

Vali.

  • The user isn't blocked, it's a newly created, activated user account. – Valigar Jun 30 '15 at 9:23
2

Ok found it, the migrate module have a custom Mail Class that blocked all emails send during migration process.

The migrate Mail Class is

MigrateMailIgnore

To bypass that migrate mail class you can simply do that :

public function complete($entity, stdClass $row) {

    // some stuff here

    // Bypass migrate MigrateMailIgnore Class
    global $conf;

    $conf['mail_system']['default-system'] = 'MyOwnMailClass';

    // Operation.
    $op = 'register_admin_created';

    // Send an email.
    _user_mail_notify($op, $user);
  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.