Hello,
I'm running:
drupal commons 7.x.3.2
message notify 7.x-2.3+3-dev

I create a new post to a group which I follow and have email notifications turned on.
I receive the notification email as expected.
However, I also get the error message (in the log file): Could not send message using @title to user ID 8.
and printed to the screen "Unable to send e-mail. Contact the site administrator if the problem persists."

Comments

madhattertech’s picture

Hello, I have the same issue.

8bitplateau’s picture

dont know why your're getting the error but its not very helpful messge! line 101 in abstarct.inc

      watchdog('message_notify', t('Could not send message using @title to user ID @uid.'), array('@label' => $plugin['title'], '@uid' => $message->uid), WATCHDOG_ERROR);

should be

      watchdog('message_notify', t('Could not send message using @title to user ID @uid.'), array('@title' => $plugin['title'], '@uid' => $message->uid), WATCHDOG_ERROR);

or @label @label - donesnt matter.

this should print out which element is wrong in the message you're trying to send and help you debug.
think someone just missed this in dev :)

WebSinPat’s picture

Thanks @digitisation. I assumed @title was just the title of the failed email, so wasn't worried that it wasnt printing out, but it is actually debug information.

So now the error message I get is:
Could not send message using Email to user ID 8.

Though i think we already knew it was a problem with sending messages "using Email" so i'm not sure that is terribly helpful.

WebSinPat’s picture

OK, one more piece of debug info:

When i create a post, there are actually 2 emails that are sent. When I get the error message but still receive the email, it is because I am receiving 1 of the 2 emails but not the other. When I do not get the error message, I receive both emails.

This is the email I always receive, whether or not I get the error message:

from: my_websites_email@mail.com
to: my_personal_email@mail.com
subject:  New post in group
body:  
Hello user8,

There is a new post called new test of email notification errors that belongs
to one of the groups you are subscribed to.

Below is the email i DO NOT receive when i get the error message:

From: my_websites_email@mail.com
To: my_personal_email@mail.com
Subject:  New Post in hello: test post 
Hi user8,

user8 created the Post “test post” on example.com  in the
hello [1] group on Tue, 06/04/2013 - 6:03pm:


this is the body text.

Permalink: http://example.com/node/378
Add a comment at http://example.com/node/378#comment-form

Change email notifications at
http://example.com/user/8/notification-settings


[1] http://example.com/groups/hello

Which at least means the error message is accurate, that an email is not being sent when it should be. No idea why the message sometimes fails though.

WebSinPat’s picture

Title: error message "Could not send message using @title to user ID" although email is sent » No email notification if subject exceed 46 characters: "Could not send message using Email to user ID"
Category: Support request » Bug report
Issue summary: View changes
Related issues: +#1993196: Email notifications are not sent when subject exceeds 46 characters

After further debugging:
The problem of the email notification not sending and receiving the error message in the log file "Could not send message using Email to user ID" happens for me iff the email attempting to be sent has a subject line that is longer than 46 characters. 46 sends fine, if the subject line is 47 or more characters it fails, no email is sent, and error messages to the log file.

  • My server email log file does not show any errors on sending mail, which suggests that the message is never getting from drupal/php to the mail system. So it's not a mail sending problem, but somewhere in the code that it is choking.
  • Also I have confirmed that message_notify generated emails are the only ones with this problem. Other emails with long subject lines (like via webform and rules) are sent without a problem. But anything message_notify fails based on length of subject line.
  • The confusion I reported in my OP with seeing the error message even though sometimes I received an email had to do with having enabled both a Rules-based notification as well as message_notify. the rule always succeeded in sending email, whereas message_notify most often fails.

I'm now running message_notify 7.x-2.5+0-dev as part of commons 3.3

amitaibu’s picture

> But anything message_notify fails based on length of subject line.

Does it happen also on a clean installation?

WebSinPat’s picture

@Amitaibu, I have no idea. I don't know how to do that.

I think the likeliest thing is that it's a config/conflict or something rather than an absolute failure with message_notify code, but I'm not sure how to continue debugging or how to fix. Any suggestions on this would be appreciated.

  • I will also add that when I look at the messages at admin/content/message, they are correct regardless of subject length, so it's not a problem with the message itself, but somewhere with getting it to the email.

current workaround is to make subject lines a fixed length <46 and not include the node title or other variable token-based info in the subject.

dangermonkey’s picture

May I ask, where are you editing the subject lines for a fixed length? I can't seem to figure it out.

WebSinPat’s picture

@dangermonkey:
Are you also having problems with having emails sent?

In order to edit your subject lines (or other info/text in the emails) go to
admin/structure/messages
Then you can edit the messages that are sent by email (which in Commons3.3 I think are the following). I made them fixed-length by removing the token and only including fixed text.

  • The notification sent when a user creates a node. (Machine name: commons_notify_node_created)
  • Commons Notify: Comment created (Machine name: commons_notify_comment_created)
  • The notification sent when a user creates a node that is not in any groups (Machine name: commons_notify_node_created_no_groups)
dangermonkey’s picture

That works perfectly! Thank you so much!

And yes, same issue with the emails!

WebSinPat’s picture

StatusFileSize
new28.88 KB

I've received a question from another person who gets the same problem, with a request for more clarification on how to change the subject length, so here are further instructions.
- go to admin/structure/messages
- select which message you want to modify. For this example I'll do commons_notify_comment_created
- so you can click the "edit" link next to the particular message, or for this example I wind up at:
admin/structure/messages/manage/commons_notify_comment_created
- then you can edit the View modes: Notify - Email subject
- I changed my subject to be
New Comment posted on [site:name]
(it still uses a token, but the token is a fixed length and not very long)
- the ORIGINAL subject was: New comment on [message:field-target-nodes:0:title] in [message:field-target-nodes:0:og-group-ref:0:title]: [message:field-target-nodes:0:title] which included the comment title, what group it was in, etc etc which made the length unpredictable and over 46 characters.
- Make changes for all the messages that get sent via email, which I listed in comment #9, for Commons.

Here is a screenshot of the message management page:
screenshot of message management page

Hope this helps.

arellani’s picture

I did exactly what you suggested but the error is still the same.

It is necessary to change something else in "Manage field" in the message type or maybe at "OG new content notification (With Message)" on Rules? I did exactly what you sugested but the error still continue.

It is necesary to change something else at Rules?

arellani’s picture

WebSinPat thank you for all your support!

It is necesary to change what you sugested before and in message-body (type of message) has to be with some value (not empty)

The problem was that the "message-body" was empty :s

bjlewis2’s picture

I'm getting this error on a basic site only using Message 7.x-1.9 & Notify 7.x-2.x-dev (not Commons).

I get two errors when trying to send an email:
1. Mail Error - Error sending e-mail (from user@example.com to admin). (I removed my actual email address)
2. Message Notify Error - Could not send message using @title to user ID 1.

These are supposed to be sent when a comment is posted. The comment does get posted, and the message is created successfully (I can view it at admin/content/message). But no email...

WebSinPat’s picture

EDIT: Actually I can confirm this is happening on a clean Commons 3.5 installation.
DC 3.5
Message 7.x-1.9
Message Notify 7.x-2.5
Message Subscribe 7.x-1.0-rc1
Message Subscribe Email 7.x-1.0-rc1

@bjlewis2, sounds like your setup might be the likeliest to be able to have the maintainers reproduce so we can get this debugged.
Can you reproduce on a clean install? and/or how much customization and contrib modules have you added?

WebSinPat’s picture

Version: 7.x-2.x-dev » 7.x-2.5
bjlewis2’s picture

Yes, this was a clean install from yesterday. I'll write up some exact steps to reproduce in just a bit. Here are all of the modules I have installed and enabled:

Administration:
Admin Menu (7.x-3.0-rc4)
Admin Menu Toolbar Style (7.x-3.0-rc4)
Hide the Toolbar (toolbar_admin_menu) (7.x-1.0)
Module filter (7.x-2.0-alpha2)

Chaos tool suite:
Chaos tools (7.x-1.3)

Development:
Devel generate (7.x-1.3)
Devel (7.x-1.3)

Fields:
Entity Reference (7.x-1.1)

Message:
Message notify (7.x-2.5+1-dev)
Message notify UI (7.x-1.4)
Message (7.x-1.9)
Message UI (7.x-1.4)

Other:
Entity API (7.x-1.2)
Entity Tokens (7.x-1.2)
Token (7.x-1.5)

Rules:
Rules (7.x-2.6)
Rules UI (7.x-2.6)

Views:
Views (7.x-3.7)
Views UI (7.x-3.7)

ezra-g’s picture

Issue tags: +commons 7.x-3.9 radar

Let's fix this problem in Commons 3.9.

ezra-g’s picture

Project: Message Notify » Drupal Commons
Version: 7.x-2.5 » 7.x-3.x-dev
Component: Code » Email Notifications

Moving into the Commons queue for triage until we confirm this is a Message Subscribe/Notify issue.

ezra-g’s picture

Assigned: Unassigned » ezra-g
ezra-g’s picture

Status: Active » Postponed (maintainer needs more info)

The only way I'm able to reproduce the symptom in this issue is when testing with the demo users that ship with Commons, and this is expected behavior. The demo users all have @example.com email addresses, and in commons_misc.module, we do:

/**
 * Implements hook_mail_alter();
 */
function commons_misc_mail_alter(&$message) {
  if (strstr($message['to'], '@') == '@example.com') {
    $message['send'] = FALSE;
  }
}

This will cause drupal_mail() to return a $message['return'] value that is NULL, which in turn causes postSend() to interpret the message sending as a failure. In my dblog, I'm seeing the errors from message_notify, but no Core, "Error sending e-mail" messages.

It does appear that the Message Notify error message has an incorrect token for the text in its error message, " t('Could not send message using @label" should be " t('Could not send message using @title" in order to match the replacement values we pass to t(). However, that's not part of the symptom here.

Regardless of whether we have a bug here, I think it's reasonable to shorten the subjects for our email notifications in some cases.

Marking as "needs more info" for the error that's the subject of the issue (No email notification if subject exceed 46 characters). It would be great if someone could post steps or scenarios to reproduce outside of users with @example.com email addresses so that we can investigate further.

WebSinPat’s picture

Thanks for looking into it @ezra-g.

It seems likely that it's a server config issue...since it happens reliably for some of us and not at all for others.

In another issue @lightsurge suggested this might be the likely culprit: #300387: drupal_mail_send with long UTF-8 subject puts \n to subject line, the mail() function won't send it then.

I have not yet had a chance to try any of those suggestions in that issue... it's all a bit beyond my scope.
I'm not sure how pervasive this is amongst the general commons userbase? Or if there's a commons-based workaround for it.

Also, I kind of wound up opening two issues on this topic before I realized they were the same cause. this issue and also #1993196: Email notifications are not sent when subject exceeds 46 characters. Don't know if we should close one or the other as a dupe, or close both as a dupe of the known UTF issue?

ezra-g’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

I admit that I didn't realize I was participating across two separate issues here.Marking as a duplicate of #1993196: Email notifications are not sent when subject exceeds 46 characters.