Comments

Status: Needs review » Needs work

The last submitted patch, comment_notify-outbound-mail.diff, failed testing.

mavimo’s picture

StatusFileSize
new1.74 KB

Repatched

mavimo’s picture

Status: Needs work » Needs review
StatusFileSize
new2.02 KB

Fixed sender information into header.

mavimo’s picture

StatusFileSize
new1.92 KB

Removed debug info (sorry for multiple submission)

greggles’s picture

Title: Outbound mail address » Allow admin to specify the outbound mail address

See #545044: allow admin to set a "from" address - there wasn't a ton of discussion in that issue which made me think nobody wanted it. I'd like to see some +1/-1 suggestions from other people about whether or not this belongs in comment notify.

Thanks for your idea and especially for the patch!

mavimo’s picture

@greggles: this feature is usefull to separate comment mail from site mail (reduce mail into inbox); for example use info@mysite.tdl as main site mail and comment-no-reply@mysite.tdl for comment submission.

If user don't set any other mail default mail is used as failback.

greggles’s picture

Project: Comment Notify » Mail Editor

I'm moving this to the mail editor module, which has the general purpose of altering different attributes of e-mails sent from a site.

I think it makes more sense to handle this over there.

salvis’s picture

Status: Needs review » Active

Not sure whether litwol would be willing to accept this new functionality.

chuckbar77’s picture

+1 subscribing

danepowell’s picture

Wow, old issue. But I'd really like to see this, for the purposes of setting the 'from' address to the node author in Subscriptions: #1724456: Using the node author as the "from" in subscription notifications

danepowell’s picture

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

Also, I'm guessing features are more likely to make it into 7.x first...

salvis’s picture

Assigned: mavimo » Unassigned

Yes, this makes sense. Anyone wants to provide a patch?

mrded’s picture

By my opinion, it's really hard to make changes for this module because of architecture of module.

Every time when we need to add any additional fields we have to change 'mail_edit' schema. And no one can guarantee what the schema will stay same on final version of patch.

I made similar patch already #2076827: Add plaintext field, but it stacked by the reason above. And I worry to do another one, I think it's better to go "around".

salvis’s picture

Issue summary: View changes

@mrded:
I realize that the coupling with Subscriptions makes some things difficult to change, but this issue here is not affected.

schifazl’s picture

Status: Active » Needs work
StatusFileSize
new2.35 KB

I've tried to add another field in template (mail_edit table) without success. The fields gets saved and loaded correctly, and the sender is correctly used, but it messes with the Mail templates page: templates with the "Purge" link now have "Purge all", and templates without the "Purge" link now have it. Even after reverting the modifications this won't return back to the normal situation, so try this only on a test installation and after doing a backup of the site.

Also, since I've did this in the mail's template, if you modify the default's mail sender address, it will use it in all the other mail templates too (I'm testing this with Subscriptions).

To try this patch you have to manually create a column "sender" in the mail_edit table, because I don't know (yet) how to do this by code.

It needs some work, but I think that this should be a template's field. In this way you can define sender addresses for each language and content type, it's more flexible.

Some help would be welcome :)

salvis’s picture

Let's clarify what we're trying to do here. You can set the site's outgoing address on admin/config/system/site-information, right?

Subscriptions allows setting the outgoing address and name on its options page (applicable to its half a dozen templates), admin/config/system/subscriptions.

This issue came up in the Comment Notify queue, which (I assume) offers one template.

I don't think we can force the user to maintain the sender information separately for maybe 10 templates times 5 languages. IOW, this definitely needs to be optional. OTOH, if we do this, we need to support not only the sender address but also the sender name, for each template and each language. There's no way around that, I guess.

@schifazl: If you've messed up your site, we can't really help from here. You know best what you changed, and if you really undo that, the site's old behavior will come back.

Dane Powell revived this issue in #10, requesting support for Subscriptions tokens in the From field, which means we need a hook for the client module to provide default values and token replacement. The scope of this issue is much bigger...

kyleheney’s picture

I am looking for a solution exactly like the one mentioned in #15. I tried the patch, but it didn't work for me. Has anyone looked at this since or been able to accomplish something similar?

All I want to do is modify the "From" (or reply-to) address in one of my Mail Templates. It needs to be different from the site admin email address.

Thanks

jerry’s picture

I had a more limited need to include a Reply-To address in Subscriptions E-mail, and accomplished it via hook_mail_alter(). You may be able to modify this for your own requirements. It's certainly not proposed as a general (or especially convenient) solution to the original problem, but it's worked fine for this purpose.

/**
 * Implements hook_mail_alter().
 *
 * Add author E-mail as Reply-To address for Subscriptions notifications unless
 * they're in digest form.  Also remove any line breaks from the subject field,
 * in the event that it wrapped, because they're annoying.  Sorry, RFC822.
 *
 */
function xxxxx_mail_alter(&$message)
{
  if (isset($message['module']) && ($message['module'] == 'subscriptions_mail') &&
      isset($message['params']['data']['subs']['object'])) {
    if (isset($message['params']['data']['subs']['digest']) &&
        ($message['params']['data']['subs']['digest'] == 0)) {
      if ($message['params']['data']['subs']['object']->cid == 0) {
        $account = user_load($message['params']['data']['subs']['object']->uid);
        $mail = $account->mail;
        if (!is_null($mail)) {
          $message['headers']['Reply-To'] = $mail;
        }
      }
      else if (isset($message['params']['data']['subs']['object']->_subscriptions_comments)) {
        $comments = $message['params']['data']['subs']['object']->_subscriptions_comments;
        if (is_array($comments) && (count($comments) > 0)) {
          $last = array_pop($comments);
          $account = user_load($last->uid);
          $mail = $account->mail;
          if (!is_null($mail)) {
            $message['headers']['Reply-To'] = $mail;
          }
        }
      }
    }
    if (isset($message['subject'])) {
      $strip = array("\r\n", "\n", "\r", "  ");
      $replace = array("", "", "", " ");
      $message['subject'] = str_replace($strip, $replace, $message['subject']);
    }
  }
}