Why doesn't my code send emails? 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, &amp;$form_state){
  global $user;
  $c_user = user_load_by_name($user-&gt;name);
  $uid = $c_user-&gt;uid;
  $profile = profile2_load_by_user($uid, 'recruiter');
  $field = $profile-&gt;field_recruiter_company;
  $tid = $field['und'][0]['tid'];
  $term = taxonomy_term_load($tid);
  $company = $term-&gt;name;
  $query = db_select('import_contact');
  $query-&gt;fields('import_contact', array('name', 'email', 'company', 'operator_insert', 'status', 'matches'))
    -&gt;condition('company', $company,'=')
    -&gt;orderBy('name', 'ASC');
  $table = $query-&gt;execute();
  $a;
  $b;
  $email_user = array();
  foreach ($table as $key =&gt; $values) {
    $email_user[$key + 1] = array( 
      'name' =&gt; $values-&gt;name,
      'email' =&gt; $values-&gt;email,
      'company' =&gt; $values-&gt;company,
      'operator_insert' =&gt; $values-&gt;operator_insert,
      'matches' =&gt; $values-&gt;matches,
    );
  }

  $params = array();
  foreach ($form_state['values']['table_user'] as $key =&gt; $value) {
    if(!$value == 0) {
      $email = $email_user[$key]['email'];
      $params = array(
        'name'            =&gt; $email_user[$key]['name'],
        'email'           =&gt; $email,
        'company'         =&gt; $email_user[$key]['company'],
        'operator_insert' =&gt; $email_user[$key]['operator_insert'],
        'matches'         =&gt; $email_user[$key]['matches'],
        'link_jobklik'    =&gt; 'http://dev.yukerja.gotpantheon.com',
        'subject'         =&gt; 'Invitation',
        'body'            =&gt; 'body tes',
        'from'            =&gt; '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-&gt;format($message);

      // Send e-mail.
      $message['result'] = $system-&gt;mail($message);
      // drupal_mail('yukerja_view_contact', 'invitation', $email, language_default(), $params, $params['from'], TRUE);

    }   
  }
}
I think your code is good enough to send email, but you need SMTP server to send the mail (which you has not specified), in case you have a mail server , the easy solution is install SMTP module which needs the SMTP server address and your are good to send email.


  This module allows Drupal to bypass the PHP mail() function and send email directly to an SMTP server. The module supports SMTP authentication and can even connect to servers using SSL if supported by PHP.