Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#7 | notifications-1067198-7.patch | 571 bytes | Dane Powell |
#2 | sender_name.patch | 1.02 KB | drumm |
Comments
Comment #1
pandroid CreditAttribution: pandroid commentedSorry, the line is from messaging.mail.inc
Comment #2
drummI'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.
Comment #3
gregglesBetter status and subscribe.
Comment #4
greggles#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.
Comment #5
nevosa CreditAttribution: nevosa commentedI applied the patch, and it resolved sender the issue.
Thank you.
Comment #6
gregglesWhat is blocking this patch?
Tagging, as well.
Comment #7
Dane Powell CreditAttribution: Dane Powell commentedI 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...
Comment #8
gandhiano CreditAttribution: gandhiano commentedNone of the patches above worked for me.
Comment #9
msielskiPatch #7 worked for me. Thanks for the fix. I agree this seems like the correct place to patch.
Comment #10
drummI'm not actively working on this issue.