This project is read-only.

How to send email from my own module (that depends on Orchard.Email)?

Topics: Writing modules
Apr 5, 2011 at 2:38 AM

When I enable the Orchard.Email module, I get to setup the smpt settings in configuration settings. I want my module (that depend on Orchard.Email) to use that settings and to send email. How to accomplish that?

Can I inject a service provider that will expose this feature to me? I really couldn't find any documentation regarding this.


I would really appreciate your help here.

Thank you in advance.

Apr 5, 2011 at 8:05 AM

Inject an   IMessageManager messenger;

Call send:  void Send(ContentItemRecord recipient, string type, string service, Dictionary<string, string> properties = null);

Write a class that inherits from IMessageEventHandler  ...

Write a method void Sending(MessageContext context)

It checks for the service string and if it recognizes the message handles formatting it into the Subject and Body of the message.

Search for these in the source code and you'll see how they are used.

Apr 5, 2011 at 6:40 PM

Thank you very much. I've got it ;)