Users name defaults when used with mailhandler/mailcomment. All messages appear to have come from 'webmaster'

Our fix is to replace line 34 ($from = token_replace('[user]', 'user', $message->sender_account) . ' <'.$default_from.'>';)
with:
$from = token_replace('[user]', 'user', user_load(array('name' => $message->sender_name))) . ' <'.$default_from.'>';

This was default behaviour until v6.x-2.3

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pandroid’s picture

Sorry, the line is from messaging.mail.inc

drumm’s picture

Title: Users name not inserted in Email From box » sender_name should be used when preparing mail
Version: 6.x-2.4 » 6.x-2.x-dev
Assigned: Unassigned » drumm
Priority: Normal » Major
FileSize
1.02 KB

I've determined this is the cause for a bug with groups.drupal.org, #1379362: Emails coming from Anonymous

It appears not a problem on the 4.x branch. It would be good to get this on 2.x since it is the only one with a recommended release.

Attached is a patch which bypasses the whole token system since there is not a user account, or the user account should not be used.

greggles’s picture

Status: Active » Needs review

Better status and subscribe.

greggles’s picture

Status: Needs review » Reviewed & tested by the community

#2 is Now deployed on g.d.o and working there. Setting to rtbc since it fixes the bug I care about, but it could be this isn't the "right" way to fix it.

nevosa’s picture

I applied the patch, and it resolved sender the issue.

Thank you.

greggles’s picture

Issue tags: +gdolove, +commonslove

What is blocking this patch?

Tagging, as well.

Dane Powell’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
571 bytes

I am experiencing the same problem, but in a slightly different use-case, and #2 didn't work because it didn't address the root cause.

I am using Mailhandler (like the OP) to post nodes, and notifications get sent out when nodes are posted. Mailhandler 6.x-1.x worked fine, but I started getting this error with Mailhandler 6.x-2.x. Here's why:

Mailhandler 6.x-1.x would 'forge' the global $user on import to be the message sender. Then when notifications_event() was called, it would insert $user->uid into the event.

Mailhandler 6.x-2.x no longer forges the global $user, so notifications events get created with the anonymous user account.

The solution is to patch notifications_content to explicitly add a uid to the event before calling notifications_event().

I think this is a more correct patch than #2, but I have no idea if it will solve everyone else's problems...

gandhiano’s picture

Status: Needs review » Needs work

None of the patches above worked for me.

msielski’s picture

Patch #7 worked for me. Thanks for the fix. I agree this seems like the correct place to patch.

drumm’s picture

Assigned: drumm » Unassigned
Issue summary: View changes

I'm not actively working on this issue.