CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • alterMailParams -> Forward to user e-mail address
Pages: [1]

Author Topic: alterMailParams -> Forward to user e-mail address  (Read 1010 times)

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
alterMailParams -> Forward to user e-mail address
March 19, 2012, 01:13:23 pm
I have a number of users who can login and send e-mails through CiviMail. I want to track replies, but then have those replies forwarded to their user specific e-mail accounts. These mass e-mails would be sent out through our organization e-mail account.

So, lets say John Doe (john.doe@example.com) logs in and sends an e-mail to Group A. He sends it from contact@example.com, but replies should go to john.doe@example.com.

The VERP address would dictate that the reply would initially go to contact+abcdefg@example.com, but what dictates where it goes from there?

I've looked at $params inside of the alterMailParams hook, and the ones that are relevant include:
[Reply-To]
[Return-Path]
[From]

Is there a way to do this? Or does the address that replies get forwarded to the same as the from address? This would create problems, as I am using Amazon SES, and would have to authorize every single address.


Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: alterMailParams -> Forward to user e-mail address
March 19, 2012, 02:40:30 pm

There is a setting in the civimail second screen that dictates what needs to be done with replies. I think the options are:

1. ignore
2. use auto-responder
3. forward to from email address

i suspect u might need to extend the code to meet your needs

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Re: alterMailParams -> Forward to user e-mail address
March 19, 2012, 06:00:53 pm
Yeah, so I guess my question is where would I start looking to change it from Forwarding to the From address, to Forwarding to the User Contact address.

I`m happy to extend it, I just don`t know how CiviMail goes about forwarding replies to the From address when the box on the second settings screen is selected.

Brian

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: alterMailParams -> Forward to user e-mail address
March 19, 2012, 06:10:56 pm

check:


CRM/Utils/Mail/EmailProcessor.php, search for 'r' (with the single quotes)
api/v3/Mailing.php, function civicrm_api3_mailing_event_reply
CRM/Mailing/Event/BAO/Reply.php, function &reply

ping us on IRC if u need help

lobo

A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Re: alterMailParams -> Forward to user e-mail address
March 23, 2012, 02:11:26 am
So I've been playing around with this, and I'm almost there - but not quite.

I'm using alterMailParams to change the replyto_email in the civicrm_mailing table in the database for the mailing ID being drafted. alterMailParams is called after the 3rd step of using CiviMail ('Mailing Content').

I'm using this to change the record in the db:
Code: [Select]
$sql = "UPDATE civicrm_mailing SET replyto_email='email' WHERE id = {$dao -> id}";
$dao = CRM_Core_DAO::executeQuery( $sql);

I can check the database, and see that the replyto_email has in fact been changed correctly. However, now when the actual mailing goes out, the reply to email has indeed been changed, but is no longer a VERP e-mail and is actually the one I changed it to in alterMailParams. This means I can't track replies in Civi.

However, if I disable my SQL Update statement, send the bulk e-mail then manually change the database entry to the new email address, then everything works fine. The reply address is the VERP address, and the e-mail is correctly forwarded to the new email address.

What is it about changing the replyto_email in the db after step 3 that messes up the VERP replyto email address?

Brian


bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Re: alterMailParams -> Forward to user e-mail address
March 23, 2012, 02:23:10 am
Found it

In CRM/Mailing/BAO/Mailing.php on Line 1024, we have:

Code: [Select]
        if ( $replyToEmail && ( $fromEmail != $replyToEmail ) ) {
            $headers['Reply-To'] = "{$replyToEmail}";
        }

So if the Reply-To e-mail is different to the fromEmail, then it overrides the VERP replyto_email, which is my case.

So it is easy to disable, I am just wondering if someone knows why this is the case? I don't want to override something that is integral to some other function that I don't know about.

Brian

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • alterMailParams -> Forward to user e-mail address

This forum was archived on 2017-11-26.