English 中文(简体)
email sent status from rails or actionmailer
原标题:

I am developing a test application and running the whole thing on my work pc. I am using my corporate mail server to send mails. It works fine normally. I was wondering how to handle any conditions like if the mail server is not reachable from my pc. As far as i have read about it, the rails application just sends the mail and that s it. There is no way to know if the mail reached the recipient, if the recipient mail id was correct etc. Any thoughts on how to handle this scenario? Thanks and Regards, Anjali

最佳回答

I believe you re mixing together two problems here, those are quite unrelated really.

First problem - making sure that the email was accepted by the corporate mail server (that is mail relay in this case). To solve this you can either build a local queue of messages (store them in the database, queue server, whatever) - and send them with a separate worker process, that will pull each message from a queue, try to deliver it and delete it only if it was accepted by the mail relay.

Or, if you don t need low-level manual control of the process, you can set up a simple local mail server on your machine and instead if sending emails directly to your corporate mail relay, just give them to your local mail server. It will then make sure that the emails were delivered to the corporate properly.

But in both cases you won t get any info about where the message was delivered to the final recipient - like whether the email address was valid, user s mailbox was not full, etc.

Second problem - track mail delivery errors. To properly and completely solve this problem you need to catch all mail bounced back to you from the remote servers and analyze it, as many errors are unknown at the moment when the email is send - but they come back later in the form of mail bounces. If you catch and track these bounces you ll be able to catch errors likefull mailboxes, invalid emails, just temporarily delivery failures, etc.

It s the way it is done in mail lists management software - for example, phpList operates in exactly the same way.

问题回答

I thought about this problem. My thought was to store the message into a separate model called "mailqueue" and then run a ruby script that will pull and delete a message from that mailqueue only if the corporate mail server is available (which I already have the code to do that, I believe). Of course, if there is a better way, I would welcome it as well.





相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签