How to use _user_mail_notify with a defined language as the title say, I would like to know how to use _user_mail_notify with a specified language.

According to the documentation the third parameter should be the one that override user_preferred_language() but when I specify it the language used is always the one returned by language_default().

My code is pretty simple:

_user_mail_notify($op, $account, $mail_lang);


Where:

$op is 'register_admin_created' as the account is created programmatically.
$account is the return value of user_save
$mail_lang is an object selected from the array returned by language_list('enabled') (as I understood it should be).

I don't know if I'm using it wrong or there is a bug in the function, anyone used it with a custom language and can help me understand?

Thanks you.
I finally understood and overcome the issue, in order to send emails in a different (enabled) language multilingual features must be enabled for the emails.

To enable the multilingual features there are just few steps:


The module "User mail translation" has to be enabled
From the Variable configuration (admin/config/regional/i18n/variable) you have to select the tab "User emails" and then check the email types you want available in a different language
From the account setting page (admin/config/people/accounts) then you select the language (in the very first box of the page) and add the translation for the related email templates (just scroll down)


After this 3 steps you will be able to send emails in all the enabled (and translated) languages in your site.