This project is read-only.

IMessageManager assistance

Topics: Writing modules
Aug 1, 2011 at 7:30 PM
Edited Aug 1, 2011 at 7:39 PM

Could use a little assistance if someone can help really quick. I wrote a class file that ties into IBackgroundTask and IMessageManager so that every day at 1am, a method runs that checks the database for certain values and then sends out an email to certain users on my system. All of this works perfectly when sending to my own account which is configured for the Admin user on the system, however, every other user takes this error in the log files.



2011-07-31 02:05:20,163 [5] Orchard.Email.Services.EmailMessagingChannel - An unexpected error while sending a message to Reminder
System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was:  No such user here
   at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
   at System.Net.Mail.SmtpClient.Send(MailMessage message)
   at Orchard.Email.Services.EmailMessagingChannel.SendMessage(MessageContext context) in e:\CloudSites\\webroot\Modules\Orchard.Email\Services\EmailMessagingChannel.cs:line 59


which makes me think that it's trying to find every user on the local domain's mail server instead of sending out to Gmail or Yahoo or wherever the user's email account is located. Here is how I'm generating the email


                                var recipient = cm.Query<UserPart, UserPartRecord>().Where(ur => ur.Id == member.User.Id).List().FirstOrDefault();
                                _messageManager.Send(recipient.ContentItem.Record, "Reminder", "Email", new Dictionary<String, String> {
				                { "Subject", "subject of message" },
					            { "Body", "body of message." }


The Reminder context type is defined in MessageEventHandler in my Handlers folder


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.Messaging.Events;
using Orchard.ContentManagement;
using Orchard.Messaging.Models;

namespace Raptor.MyRealityPicks.Handlers
    public class MessageEventHandler : IMessageEventHandler
        public void Sending(MessageContext context)
            if (context.Type == "Reminder")
                context.MailMessage.Subject = context.Properties["Subject"];
                context.MailMessage.IsBodyHtml = true;
                context.MailMessage.Body = context.Properties["Body"];
                context.MessagePrepared = true;

        public void Sent(MessageContext context)


I'm thinking I'm missing something from one of these two calls that instructs the Orchard Messaging agent to send the emails externally instead of just to the local email server. Is that correct? And if so, can someone let me know what needs to be added to either one to get that to work?


Thanks so much!

Aug 1, 2011 at 7:44 PM

How did you configure messaging?

Aug 1, 2011 at 7:49 PM

The Sender email address is set to the same one my Admin user uses: which is a real account on the mail server

Host Name:

Port: 25

Require Credentials is checked, but Enable SSL is not since I don't have an SSL on this domain.

And obviously I put the credentials for the Admin user in (credentials for the email server, not Orchard)

Aug 1, 2011 at 7:50 PM

On the mail server, this user is set to Enable outgoing SMTP access

Aug 1, 2011 at 7:51 PM

How is configured?

Aug 1, 2011 at 7:52 PM

Look through the whole configuration, there may be a restriction you missed. Does it send *any* mail to the outside?

Aug 1, 2011 at 8:04 PM

You were was "sort" of in the mail server configuration. I have to authorize using the full email address, not just the username. So I had to use as the username, not just admin. I wish my mail server had sent back a more descriptive error message. Had it simply said username invalid, I would have known to go straight there and check that setting. Note to self: next time test with an external email address. Thanks Bertrand!