I am using the following code to send emails, but it doesn't work. What is wrong with it?
function yukerja_view_contact_import_form_submit($form, &$form_state){
global $user;
$c_user = user_load_by_name($user->name);
$uid = $c_user->uid;
$profile = profile2_load_by_user($uid, 'recruiter');
$field = $profile->field_recruiter_company;
$tid = $field['und'][0]['tid'];
$term = taxonomy_term_load($tid);
$company = $term->name;
$query = db_select('import_contact');
$query->fields('import_contact', array('name', 'email', 'company', 'operator_insert', 'status', 'matches'))
->condition('company', $company,'=')
->orderBy('name', 'ASC');
$table = $query->execute();
$a;
$b;
$email_user = array();
foreach ($table as $key => $values) {
$email_user[$key + 1] = array(
'name' => $values->name,
'email' => $values->email,
'company' => $values->company,
'operator_insert' => $values->operator_insert,
'matches' => $values->matches,
);
}
$params = array();
foreach ($form_state['values']['table_user'] as $key => $value) {
if(!$value == 0) {
$email = $email_user[$key]['email'];
$params = array(
'name' => $email_user[$key]['name'],
'email' => $email,
'company' => $email_user[$key]['company'],
'operator_insert' => $email_user[$key]['operator_insert'],
'matches' => $email_user[$key]['matches'],
'link_jobklik' => 'http://dev.yukerja.gotpantheon.com',
'subject' => 'Invitation',
'body' => 'body tes',
'from' => 'as'
);
$module = 'yukerja_view_contact';
$key = 'key';
$language = language_default();
$from = $params['operator_insert'] . "@jobklik.com";
$send = FALSE;
$message = drupal_mail($module, $key, $email, $language, $params, $from, $send);
$message['subject'] = $params['subject'];
$message['body'] = array();
$message['body'][] = "Invitation";
$message['body'][] = $params['link_jobklik'];
// Retrieve the responsible implementation for this message.
$system = drupal_mail_system($module, $key);
// Format the message body.
$message = $system->format($message);
// Send e-mail.
$message['result'] = $system->mail($message);
// drupal_mail('yukerja_view_contact', 'invitation', $email, language_default(), $params, $params['from'], TRUE);
}
}
}