Support Forum

Post By Email: From/Reply-To Address

30 Answers

New Answer

MP Mr Papa
Mr Papa
Member

on forum – options – email settings… the upper right hand corner section…  email address settings… option is ‘use the following email settings’…

without that, you get the wp settings (ie wordpress@yoursite.com) or that added by another plugin such as smtp plugin…

CC chris.crabtree
chris.crabtree
Member

Oh, I had that turned off thinking that was what was making PBE use the global setting and not the per-forum From address.

Turning it back on now and testing, it is using the email address specified in Email Address Settings as the From address. This is not surprising, but it’s also not what we want, right? We want the From address to be the forum-specific address.

In other words, the post I just received has this as its From header:

From: Phit-N-Phat <corinne@phit-n-phat.com>

And no Reply-To header (I removed the small code mod I had made).

And shouldn't it be the following for replies to work?
From: Phit-N-Phat <tech.support.issues@phit-n-phat.mailgun.org>

Should I blank out 'The email from name' and 'The email domain name' values so that it will pick up the forum-specific values maybe?

Thanks!

 

MP Mr Papa
Mr Papa
Member

I think I need Andy to weigh in tomorrow morning… 

looking through the code, it seems to me that the PBE plugin is missing a filter on the reply too…  or more exactly, it looks like the hook used in subscriptions changed at some point…  we extensively use the admin notifications PBE but dont personally use the subs one…

I need to run – Andy will get back with you… but if you want to try quick test, find this line in the pbe main plugin file:

add_filter('sph_email_replyto',                                        'sp_emailpost_replyto', 1, 2);

right after it, try adding this line:

add_filter('sph_email_replyto',                                        'sph_subscriptions_email_replyto', 1);

and see if that helps…  Andy will see if that is correct and enough…

CC chris.crabtree
chris.crabtree
Member

No change in behavior after applying the change. That ‘sph_subscriptions_email_replyto’ string is mysterious to me anyway, as referenced above. No other code references that filter tag, except for the sp_subscriptions_do_post_notifications() function and the code just added. And there is no function by that name.

So Reply-To here is still empty, which leaves only the sfmail options account as the From and therefore no forum-specific addresses.

It looks to me like sp-subscriptions-components.php/function sp_subscriptions_do_post_notifications() wants a real ReplyTo where it says:

# send the notification
$replyto = apply_filters(‘sph_subscriptions_email_replyto’, ”);

And so PBE should register a filter function on ‘sph_subscriptions_email_replyto’ to give it a forum-specific reply-to value. And maybe the same logic would apply for From values (not sure if filter ordering would make this tricky).

I see where you would not want to do the hack that I did to always give a forum-specific reply-to inside of the subscriptions code–this is exactly why you would want PBE to register its own filter, I think. (I have not actually gotten to filters yet in my PHP/WordPress learning, but that’s my suspicion).

Thanks!

 

MP Mr Papa
Mr Papa
Member

leave it me to type it in a rush as I had to run… what I wanted you to enter is

add_filter(‘sph_subscriptions_email_replyto’,                                        ‘sp_emailpost_replyto’, 1, 2);

but that wont be enough since it expects two args…   you would need to also edit subscriptions… find

            $replyto = apply_filters(‘sph_subscriptions_email_replyto’, ”);

and change to

            $replyto = apply_filters(‘sph_subscriptions_email_replyto’, ”, $newpost);

think that will do it…

CC chris.crabtree
chris.crabtree
Member

Ah, that makes more sense. I was already headed down that same path, in fact. :-)

Seems to do the trick! Here’s the header from and reply-to:

From: Phit-N-Phat <tech.support.issues@phit-n-phat.mailgun.org>
Reply-To: tech.support.issues@phit-n-phat.mailgun.org

I wonder whether sp_emailpost_replyto() should call sp_emailpost_newpost() to grab the forum e-mail address, or whether we can count on it being populated already in all cases? It certainly is populated in this case, so that's good definitely.

And still something is not right with the filters because the reply instructions get doubled somewhere along the line (e.g.):
[-- To reply by email insert your text above this line - instructions below --]


[-- To reply by email insert your text above this line - instructions below --]

New post on a forum or topic you are subscribed to at Phit-N-Phat:

From: The King
Group: Tech Support
Forum: Issues
Topic: Testing #5621
URL: http://www.phit-n-phat.com/forum/issues/testing-5621/#p3859

Post:
asdf


To unsubscribe, please visit your profile: http://www.phit-n-phat.com/forum/profile/?ptab=subscriptions&pmenu=topic-subscriptions




* To post a reply by email * - please remove all old text from ABOVE the insert line at the top and enter your plain text reply above it. Do not remove ANY of this email text. Please remember that your reply may not appear immediately in the forum

* To start a new topic in this forum * - send your email to  mailto:tech.support.issues@phit-n-phat.mailgun.org. The subject name will become the new topic title

[--id=#testing-5621#--]



* To post a reply by email * - please remove all old text from ABOVE the insert line at the top and enter your plain text reply above it. Do not remove ANY of this email text. Please remember that your reply may not appear immediately in the forum

* To start a new topic in this forum * - send your email to  mailto:tech.support.issues@phit-n-phat.mailgun.org. The subject name will become the new topic title

[--id=#testing-5621#--]

CC chris.crabtree
chris.crabtree
Member

I think I see why it’s doubling.

In sp-email-post-plugin.php, it has ‘sp_emailpost_add_email_link’ being called on two different filter tags:

add_filter(‘sph_admin_email’, ‘sp_emailpost_add_email_link’, 10, 3);
add_filter(‘sph_subscriptions_notification_email’, ‘sp_emailpost_add_email_link’, 10, 3);

So if you’re subscribed and an admin, you get the double “To reply by email insert your text above this line – instructions below” message.

Thinking it would be more foolproof to teach sp_emailpost_do_add_email_link() to test that it hasn’t already done its job before adding the top and bottom text again than to troubleshoot multiple paths through multiple filters for users in multiple roles.

Maybe it’s as easy as testing the top of the message for the exact match? Not sure.

thanks!

MP Mr Papa
Mr Papa
Member

if you are an admin receiving new post notifications, why would you subscribe to topics?? sorry, dont understand that logic.. ;)

if you just want to watch a topic and not subscribe, then use the watches plugin and watch it…

CC chris.crabtree
chris.crabtree
Member

As an admin, I actually only subscribe to the tech support forum and so I don’t get admin new post notifications. But because I am an admin and a subscriber, the filter is doubling the insertion points in the message (even though I don’t actually get admin notifications of new posts).

In any case, I would think it would be a good safeguard to have just in case a user ever ended up in a dual role where he might receive a notification in either role and will see this same doubling behavior.

But I suppose I can live with it if you guys don’t think it worth fixing. Thanks!

YS Yellow Swordfish
Yellow Swordfish
Member

OH my… that’s an awful lot to read through and make sense of before the caffeine kicks in!

Can I recap? As far as I can see there seem to be two issues. A filter in the subscriptions plugin that seems to have been knocked off course recently is that correct? You and Steve appear to have a fix in place for that so we need to investigate why it changed here and correct it for the next update.

And multiple ‘headers’ in the email because you are an ‘Admin’, a ‘Moderator’ and a ‘Subscriber’. Yes? Well Steve is right in asking why would you subscribe if you also get Admin notifications. And I actually DO think this is a hole worth plugging and believe the is actually a ticket opened in our system for this. If not I will open one.

It is the ‘Moderator’ part that I am curious about. Does this mean that you, as a forum ‘Admin’ have become a member of a ‘moderators’ user group? If we allow that then again – I suspect something has been knocked we need to fix as well.

CC chris.crabtree
chris.crabtree
Member

Yes, I think this recap is accurate.

To clarify the roles of my test account that is getting the double headers, here is the situation. I muddied the waters on this for sure, as I was confused as well.

The user is a WP Admin and a SP Moderator. The user is NOT a SPF Admin.

I made that user a SP Moderator so that I could test Moderators-only being able to Reply via email as part of testing PBE. Eventually it won’t matter, as every user will have PBE capabilities, but I didn’t want to turn it on for them until I had it all working.

So I’m not sure that part of it is really an issue or not. The main thing seems to be that a check for pre-existing PBE tags is in order before inserting more of them.

Thanks!

YS Yellow Swordfish
Yellow Swordfish
Member

So can we double check on that last point. Has the moderator user account turned on admin email notifications (Your Admin Options)? I would assume yes but need to check please.

CC chris.crabtree
chris.crabtree
Member

Under Your Admin Options, I only have one option checked: Receive notification (within forum – not email) on topic/post edits.

Does that answer the question?

Thanks!

YS Yellow Swordfish
Yellow Swordfish
Member

Ok so even more confused now! So were there multiple headers in the email because you, as an admin, had also subscribed to that topic? Is that all we are talking about?