Less reliance on mimemail_prepare in mimemail function

surge_martin - November 20, 2007 - 16:40
Project:Mime Mail
Version:5.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

I've been working to make the xpertmailer library work with mimemail as an external mailengine. I'd like to have xpertmailer actually construct the message, however, and the current structure of the mimemail function doesn't allow this, it always uses mimemail_prepare.

It would make things easier if mimemail determined the engine first, and then checked for a custom prepare function. For example:

<?php
function mimemail($sender, $recipient, $subject, $body, $plaintext=null, $headers=array(), $text=null, $attachments=array()) {

 
$engine_prepare = variable_get('mimemail_engine', 'mimemail') .'_prepare';
  if (
function_exists($engine_prepare)) {
   
$message = $engine_prepare($sender, $recipient, $subject, $body, $plaintext, $headers, $text, $attachments);
  }
  else {
   
$message = mimemail_prepare($sender, $recipient, $subject, $body, $plaintext, $headers, $text, $attachments);
  }

 
$engine = variable_get('mimemail_engine', 'mimemail') .'_mailengine';
 
  if (!
function_exists($engine)) {
    return
false;
  }

  return
$engine('send', $message);

  return
false;
}
?>

#1

Allie Micka - February 19, 2008 - 03:19
Status:active» fixed

I have a bit of a philosophical issue with this one. Mime Mail's main job is to create some consistency around mail messages, so diverting its message building is sure to create some drama later.

The mimemail_prepare function is where user's plaintext settings are respected. If your module, for example, does not respect these settings, we'll make a liar out of the UI. Additionally, if the message structure or user options change in some way, or certain API changes occur ( e.g. with the just-committed mailkey patch), xpertmailer and friends won't be consistent with those.

By eschewing everything that Mime Mail does, I'm not really sure what you'd get out of using it - except for a single-point-of-entry for formatted messages. Maybe that's enough.

All that said, it's your funeral :). I'm committing this to HEAD, so have fun with it!

#2

Anonymous (not verified) - March 4, 2008 - 03:21
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.