I set up, with a Gmail account (smtp.gmail.com:465).

I'm using the [SMTP module](https://drupal.org/project/smtp), and after setup, I **can** (i.e. have no problem with Gmail) send the "test e-mail" it offers in the admin page.

However, trying to call this function:

```
drupal_mail('casabaca_s3s', FORM_ALIAS_CONTACTO, 'luisfmasuelli@gmail.com', language_default(), array());

```

which is implemented here (hook impl.):

```
function casabaca_s3s_mail($key, &$message, $params)
{
    $data = array();
    foreach($params as $k => $v)
    {
        $data['${'.$k.'}'] = $v;
    }

    $messages = array(
        FORM_ALIAS_CONTACTO => array(
            'subject' => '',
            'html.message' => <<<MESSAGE
MESSAGE
        ),
        FORM_ALIAS_COTIZAR => array(
            'subject' => '',
            'html.message' => <<<MESSAGE
MESSAGE
        ),
        FORM_ALIAS_TALLERES => array(
            'subject' => '',
            'html.message' => <<<MESSAGE
MESSAGE
        ),
        FORM_ALIAS_EXONERADOS => array(
            'subject' => '',
            'html.message' => <<<MESSAGE
MESSAGE
        ),
        FORM_ALIAS_AVALUO => array(
            'subject' => '',
            'html.message' => <<<MESSAGE
MESSAGE
        ),
        FORM_ALIAS_MANTENIMIENTO => array(
            'subject' => '',
            'html.message' => <<<MESSAGE
MESSAGE
        ),
    );
    $base_message = $messages[$key];
    $message['body']['plain'] = '<html><body>HTML version of "test message"</body></html>'; //drupal_wrap_mail(drupal_html_to_text(strtr($base_message['html.message'], $data)));
    $message['body']['html'] = 'text version of "test messages"'; //drupal_wrap_mail(strtr($base_message['html.message'], $data));
    $message['subject'] = 'test subject';//$base_message['subject'];
    $headers = array(
        'MIME-Version' => '1.0',
        'Content-Type' => 'multipart/alternative; charset=UTF-8;',
        'Content-Transfer-Encoding' => '8Bit',
        'X-Mailer' => 'Drupal'
    );
    foreach ($headers as $key => $value) {
        $message['headers'][$key] = $value;
    }
}

```

**doesn't work**. The returned message comes as follows:

> 
> No se pudo enviar el correo electrónico. Contacte con la administración del sitio si persiste el problema.
> 
> 
> 

(message in Spanish. possible English message could be - I don't know since I'm a total n00b and just using a Spanish Drupal 7 version -: E-mail couldn't be sent. Contact with site administration if the problem persists).

**Q: What am I screwing?**
*Hypothesis: I think it's in my code, but I copied most of it and try to understand it*

*Goal*: send a *multiple alternatives* email (**please note, currently the options are just a stub, and not implemented**), depending on six possibilities (each responding to a different form, a different feature, but currently they have dummy body and subject).

Preconditions: Drupal 7, PHP 5.4.16, SMTP module 7.x-1.0.

**Edit**: For those not being sure what the "test e-mail" is, see [Here](http://www.symphonythemes.com/drupal-blog/configure-drupal-smtp-gmail) for a detailed example.