I am sending e-mail to specific roles using Rules. I was using the SMTP Authentication Support module but my new server no longer requires it. With that module I was able to specify the Sender's name. I am not longer able to do that with just Mime Mail.

e.g. sender's e-mail = dave@testsite.com so Rules automatically makes the Sender's name "dave@testsite.com". I would like to modify that. Any suggestions?

Comments

sgabe’s picture

Version: 6.x-1.0-alpha3 » 7.x-1.x-dev

At the moment Mime Mail doesn't specify the sender information but uses your sites default settings and Drupal uses only the e-mail address to set the sender in drupal_mail(). If the sender is empty Mime Mail will set it using the site's default name and e-mail address in mimemail_prepare().

drupal_mail() core default:

  $default_from = variable_get('site_mail', ini_get('sendmail_from'));

  // Bundle up the variables into a structured array for altering.
  $message = array(
    'id'       => $module .'_'. $key,
    'to'       => $to,
    'from'     => isset($from) ? $from : $default_from,
    'language' => $language,
    'params'   => $params,
    'subject'  => '',
    'body'     => array()
  );

  [...]

mimemail_prepare() default:

  if (is_null($sender)) { // use site default for sender
    $sender = array(
        'name' => variable_get('site_name', 'Drupal'),
        'mail' => variable_get('site_mail', ini_get('sendmail_from')),
    );
  }

  [...]

Changing version to HEAD.

sgabe’s picture

Status: Active » Needs review
StatusFileSize
new3.63 KB

I am attaching a patch against current HEAD.

interestingaftermath’s picture

Oh nice! So this patch should print the Site name as Name and the primary site e-mail as from email? Man, you're good! I will test it out and report back this evening.

sgabe’s picture

No, this patch will allow you to specify the sender information on the module settings page.

interestingaftermath’s picture

That's even better!

interestingaftermath’s picture

Works like a charm! Thank you for your awesome support for this module. I've never seen a maintainer so active!

interestingaftermath’s picture

Status: Needs review » Fixed
sgabe’s picture

Status: Fixed » Needs review

It's not fixed until it's committed. Still needs some review.

interestingaftermath’s picture

Oops. Sorry about that.

sgabe’s picture

StatusFileSize
new3.74 KB

Small fix to use Mime Mail setting for default sender if sender is null, like the original behavior.

sgabe’s picture

StatusFileSize
new4.25 KB
+++ mimemail.inc	6 Sep 2010 15:42:52 -0000
@@ -51,8 +51,9 @@
-  // allow a mail to overwrite standard headers.
-  $headers = array_merge(array('Return-Path' => "<$from_email>", 'Errors-To' => $from, 'From' => $from, 'Content-Type' => 'text/plain; charset=utf-8; format=flowed'), $headers);

Note that this patch fixes a bug for this issue. The array_merge() here doesn't allow to overwrite the headers, since the later value overwrites the previous one. So after all we pass the $sender to mimemail_headers() for nothing, the default headers added by drupal_mail() will overwrite these.

In the attached patch (in the previous ones too) the parameters of array_merge() are reversed and mimemail_headers() tries to overwrite these headers only if the $from parameter is set.

sgabe’s picture

Title: Specify Sender's Name » Specify sender's name
Status: Needs review » Fixed
StatusFileSize
new4.4 KB

Committed to HEAD.

Status: Fixed » Closed (fixed)

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

sgabe’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev

Changing version.