I am trying to use mimemail at the moment. I am not really getting how it is used, if there is an example somewhere that would be great. I have set mimemail as the default for the system and have created a hook_mail function in my module. When I send emails, most of the formatting is stripped out. The link is still working, however the div and p tags are not there so all of the text just appears in one big block. I would prefer to have the default mail set in the system settings and use something like this in my module to use mimemail for this function:
mailsystem_set(array(
'mymodule' => 'MimeMailSystem',
));

The body is set to '

For full details click here.

.$node_body'

This is the call to drupal mail:
drupal_mail(
'mymodule',
'message',
$cur_user->mail,
user_preferred_language($cur_user),
$params,
$manager->mail,
TRUE
);

My function is here:
function mymodule_mail($key, &$message, $params) {
if (isset($params['subject'])) {
$message['subject'] = $params['subject'];
}
if (isset($params['body'])) {
$message['body'][] = $params['body'];
}
if (isset($params['headers']) && is_array($params['headers'])) {
$message['headers'] += $params['headers'];
}
}

I would also like to be able to send an html and plain text version as a fall back?

Thanks.

Comments

kurtfoster’s picture

OK, I am not sure why but when I changed the site-wide default mail settings to Default and the setting for my module to mimemail, the emails I was sending started to come out correctly. A multipart message is being sent, how do I change the plain text version to a specific message, not just the plain text conversion of my html message.
ie I want the html body to say 'click here' and have here as a link, and i want the plain text version to say 'go to this url'.

sgabe’s picture

Use the plaintext parameter.

$params['plaintext'] = "Go to this url...";

drupal_mail(
  'mymodule',
  'message',
  $cur_user->mail,
  user_preferred_language($cur_user),
  $params,
  $manager->mail,
  TRUE
);

sgabe’s picture

Status: Active » Closed (fixed)

Closing due to inactivity.