I am writing a Redmine plugin. I already have the model, view and controller in place.
Whenever someone creates, updates or deletes my model I want to send an email to people in a certain group. (Similar to emails sent out by Redmine when someone creates or updates an Issue) Could someone please let me know what would be the best way to go about it?
Thanks!
I know it's been 2 years since you asked but I had the same issue and I figured out how to send an email with my plugin.
What you have to do for a plugin named my_plugin is :
1. Create a Model which inherits from Mailer.
So if I want a mailer named MyPluginMailer :
I create redmine_folder/plugins/my_plugin/app/models/my_plugin_mailer.rb
I create the MyPluginMailer class which inherits from the redmine Mailer
Like that:
class MyPluginMailer < Mailer
end
2. Create a method to call on the mailer.
Say I am writing a news plugin for redmine.
I want to send an email which summarizes the article I submitted so that users do not have to poll the plugin each time they want to know if there is something new.
I create a method in my mailer class :
class MyPluginMailer < Mailer
def on_new_article(user_to_warn, article)
mail to: user_to_warn.email, subject: "New article: #{article.title}"
#article = article #So that #article will be available in the views.
end
end
You can call this method in your Article class in an after_create callback for example.
3. Create some views for the method.
I have to create 2 differents files :
my_method.html.erb
my_method.text.erb
or else redmine is going to crash with a "template not found" exception.
So in my redmine_folder/plugins/my_plugin/app/views/my_plugin_mailer/ I create
on_new_article.html.erb
on_new_article.text.erb
In my on_new_article.html.erb I write something like :
<h1><%= #article.title %></h1>
<p><%= #article.summary %></p>
Related
I have configured my email collector to display the body in french and I sent survey invite through Survey Monkey. It worked well. Default template is used if this is not specified String in Survey Monkey API. Is there a way to get already configured email collector setup message to be sent? I want the emails to be in the language I had chosen in SM UI
The best way to create a new message based on a template right now is to copy a previous message.
To do this, you'll want to include the collector/message to use as a template when creating a new message like this:
POST /v3/collectors/{collector_id}/messages
{
"from_collector_id": "<collector_to_use_as_template>",
"from_message_id": "<message_to_use_as_template>"
}
Note that the message ID in the body needs to belong to the collector ID in the body.
Is there a way to make a Jire email handler ignore the From field in an email and go for a custom tag instead? I know I could work with the API instead but that's in the pipe. this is a temporary solution that will be used until a more robust system is built.
To clarify what we have today:
Email is sent to inbox, (hr#company.com)
Jira picks is up and creates an issue.
Jira looks at the From field and creates a uses if none exist.
What we're trying to achieve:
Form is filled out, and an area is chosen (hr, facilities etc.).
Form is posted to an API that creates an email (basically a no-reply adress over SMTP) and sends it to the appropriate inbox (for example hr#company.com).
Email lands in the inbox and Jira looks in it and creates an issue in project or label 'HR'.
Jira now looks in the email and finds custom tags named [user] and [user-email] (or something) and creates a user from the tag.
Example email
From: no-reply#company.com
To: hr#company.com
Subject: Some problem
Body: Explanation of problem
Have a good day!
/Mike
[user:"Michael Smith"]
[userEmail:"michael.smith#company.com"]
If we were to implement this system now, we would loose the possibility to create new users because all emails would come from the same "no-reply" adress.
I have searched in the Atlassian forums and such, but with no luck. Have not found anything in the official documentation, but I fear that I might be looking in the wrong place.
I hope that I'm being clear, and that someone has any idea if it is possible.
Thank you!
You need to write your own plugin and create your own Mailhandler.
For example you can use a regex which looks for the tag
[userEmail:"michael.smith#company.com"] and retrieve the emailadress from the string. Do the same for the [user]-tag, if the user doesn't exist.
Here is a tutorial that shows how to create and setup custom Message Handlers:
https://developer.atlassian.com/jiradev/jira-platform/guides/email/tutorial-custom-message-mail-handler-for-jira#Tutorial-Custommessage(mail)handlerforJIRA-Step7:Implementarealmessagehandlerback-end
The rest should be easy from here.
I'm working on a new Joomla site and am working on testing outgoing email. I'd like to be able to intercept all outgoing emails and reroute them to an address I specify. It is very useful in development when you have a copy of a live site with thousands of users, so email does not go to real users from the copy site.
It would be great to do this with a extension but have been unable to find one to do some. I'm also open to getting this done on the server side if necessary.
I found a Drupal module that does exactly what I'd like to do except it's obviously for Drupal and note Joomla.
https://drupal.org/project/reroute_email
On Joomla-Level you could create a system plugin that loads up own, monkey-patched JMail class.
I'm not sure if you would be able to extend the original JMail because of namespace conflict, so maybe you'd have copy it over and alter the addRecipient method:
public function addRecipient($recipient, $name = '')
{
$this->add('custom#email.com', 'custom name', 'AddAddress');
return $this;
}
References:
Related Stack Overflow answer: How to override core classes
Gist: plgSystemOverrides
I have created an email service in force.com.Can anyone help me out of how to use thta in apex classes.say,i wanna send mail when user registration is successful??
Many Thanks,
Sandhya Krishnan
I assume you want to send an email directly from Apex code, either in a Trigger or from a page controller ... ? If so, this page can get you started:
http://www.forcetree.com/2009/07/sending-email-from-your-apex-class.html
Clearly you don't want to hard-code your email template into your classes, so make sure to read at least through the part that shows how to look up the template dynamically. That should be enough to get you on your way.
I'm using Drupal 6.16: When a user creates an account on my site I have them select a category (ie children, youth, adult, etc). This is done with the select list box using the content_profile module. I have a content type that posts an announcement. In this content type is a check box that says 'email group'. Right now it does nothing, but what I would like for it to do is e-mail all the users that are associated with the group they chose when signing up for their account. If this will require extra code please be specific as I am not a strong php programmer.
Thanks for the help!!
msindle
There might be some module that do it exactly, but I don't think so.
I would have done it using few building blocks:
Retrieve the list of emails using Views - define a view that gives you the addresses according to a given group argument.
Use Rules module that will send an email notification after node is created.
Combine the two (this is the hard part) - insert the values from the view as the recipients for the email. You might be able to do it using PHP inside the Rule definition, plus view execution.
Try to accomplish it, and if you get into troubles, you are welcome to contact me via shushu.i#gmail.com
I would try http://drupal.org/project/subscriptions module + http://drupal.org/project/messaging module. You can set preferences for automatic subscribing to content type. Maybe Rules module can subscribe users automatically after creating or updating content_profile. Or maybe Rules can flag users after creating or updating content_profile and Subscription module could autosubscribe flagged users.