Patch #237
closedget journal from MailHandler.receive
0%
Description
Hello,
here attached the patch to get Journal instance
from MailHandler.receive.
Adding notes via email can be done even now,
but I want to get the instance of Journal
that was added to the issue to send
the notify mail by Mailer model.
For example, the following solution will appropriately
handle incoming mails with help from MDA and so on:
Server side:
class MailHandlerController < ApplicationController
session :off
def import
if local_request?
begin
journal = MailHandler.receive(File.read(params[:path]))
Mailer.deliver_issue_edit(journal) if journal
rescue => e
logger.error("#{e.class}: #{e.message}") if logger
end
end
render :nothing => true
end
end
Client side:
require "tempfile"
require "open-uri"
Tempfile.open("mail-to-import") do |t|
t.write(ARGF.read)
t.flush
path = URI.escape(File.expand_path(t.path))
open("http://localhost/mail_handler/import?path=#{path}"){}
end
I intend this for receiving mails without script/runner,
that is too heavy to be invoked by each incoming mail.
Thanks,
Files
Updated by Jean-Philippe Lang over 15 years ago
- Status changed from New to Closed
Current trunk now behaves as expected here.