I'm using rails 2.2.2 on a linux box and am using a rake task to send some emails. It's a very simple script without error handling:
1.) Get emails to send
2.) Send email
3.) Mark emails as sent
Right now, the port on the smtp server has been blocked temporarily so steps 1 and 3 are completing but not step 2. My question is, when I unblock the port, are the messages that previously failed queued somewhere (and are going to be sent) or did they timeout and get /dev/nulled? If they are queued up somewhere, can I get the file location? I just want to understand the behavior so I can build out appropriate error handling. Thanks,
Drew
Related
I configured a message processor in ESB WSO2. every now and then, all the messages are not carried out and they stay pending in the queue (message broker)
I can I can find only this log in the ESB console
"BlockingMessageSender of message processor [SAPMoveMaterialMessageProcessor] failed to send message to the endpoint"
My questions:
1, how and where can I see the real reason (detailed logs, error msg) why the message processor could not be sent out? I have defined a Fault sequence on the message processor but shows nothing
2, in case that I get this issue in the production environment is there a way how to "copy" a pending message (from the message broker queue) to my DEV environment and debug it there?
thank you very much for your ideas!
AFAIK you can get more details from enabling DEBUG logs related to message processors. You can get these in the server management console tools- >'logging' and doing a search for matches which contains 'messageprocessor' and make the log level to DEBUG.
eg:
org.wso2.carbon.message.processor.service.MessageProcessorAdminService
org.wso2.carbon.message.processor.MessageProcessorServiceComponent
As a solution for this you can try out by using a clone mediator (the use of clone mediator here is to make multiple identical copies of the message) inside the fault sequence (when pending message gets fail to consume) to persist to a database - may be to your dev environment.
I love the site. It's a good place to look for answers. Thanks for that.
I am wrestling with a feature of munin on a test server.
It runs lighttpd, mysql, ssh, proftpd, postfix and dovecot.
If one of them fails, I would like to receive a text message next to the 'default' email. I have got an SMS gateway in use, with VoipBuster. If I request an url (as stated below) I will receive a text message.
https://www.voipbuster.com/myaccount/sendsms.php?username=xxxxxx&password=xxxxxx&from=xxxxxx&to=xxxxxx&text=xxxxxx
I have tried including this in my monit config, but I just can't get it to work.
Here's what I tried.
Including a 'if failed then' under every check, like this:
check process lighttpd with pidfile /var/run/lighttpd.pid
group lighttpd
start program = "/etc/init.d/lighttpd start"
stop program = "/etc/init.d/lighttpd stop"
if failed host 178.21.118.206 port 80
protocol http then restart
if 5 restarts within 5 cycles then timeout
if failed then (url https://www.voipbuster.com/myaccount/sendsms.php?username=xxxxxx&password=xxxxxx&from=xxxxxx&to=xxxxxx&text=CHECK EMAIL -- SERVER ERRORS!)
But I keep getting errors like this when I am restarting.
/etc/monit/monitrc:194: Error: syntax error 'EMAIL'
I tried moving around with the 'if failed then' clause, but I literally don't know how to solve this anymore.
Thanks for the possible solutions.
I ended up using Pushover, which is an app for mobile phones.
With his app you can send an email to a specific email address (built-in feature in Monit) and get push notifications on your mobile.
I used Delayed_Jobs to send emails. Except I think that if it fails to send to 'every single email' then it tries and reruns the entire batch again.
How do I make it skip an email address if its not correct?
if an exception occurs delayed_job will treat the job as failed and keep rerunning it.
You should capture exceptions to make sure that at the end a job will always be considered as succesful.
How would i go about to receive mails in a Ruby on Rails application without going through a mail server like PostFix or to fetch them by pop3 etc.
What i was to do is to catch all mails sent to #mydomain.com and just do something with them in my application. I don't need to store the mails or anything like that.
Is this posible?
I just implemented this for my SAAS to autoprocess mailer-bounce notification messages.
Call me, call you?
You call me
You can set up a local mail server. It would then respond to an incoming email, and start up a rails executable to process the email. This method is NOT recommended since starting up rails is a big task (takes multiple secs and lots of memory). You don't want a Rails bad boy started up just because you received an email. You'd be writing your own DDOS attack. (Attacking yourself.)
I call you
Instead, poll for email on your own schedule by using a single job to process all currently waiting emails. You need to set up a background job handler since stock rails is focused on responding to web requests. I use delayed_job, but there are other alternatives including kicking off a cron job every so in often.
Another benefit is that you don't need to manage a mail server. Leave that headache to someone else. Then use the Ruby library net::imap to read the incoming mail and process it.
If your process doesn't recognize the email format, then forward the msg to a human for processing.
And be sure that if the process sends mail in addition to reading/processing it, that the process uses a different email address as its From address. Otherwise, odds are good that sometime along the way, you'll end up in an email loop and many gigabytes of messages going back and forth. For example, your process receives a message, responds to it, but in the meantime the sender (a human) has switched on vacation response. And your robot then responds to the vacation response..... oops....
Writing your own mail server
Re:
How would i go about to receive mails in a Ruby on Rails application without going through a mail server like PostFix or to fetch them by pop3 etc.
What i was to do is to catch all mails sent to #mydomain.com and just do something with them in my application. I don't need to store the mails or anything like that.
Direct answer: Yes, you could do this by writing an smtp server and setting up dns so your machine will be the mail destination for the domain. Your smtp server would process the messages on the fly, they would not be stored on your system at any point.
Is this a good idea? No, not at all. While appearances may be to the contrary, email is a store and forward system. Trying to avoid storing the messages before your app processes them is not smart. It would be a very very poor "optimization." However, using an access protocol (POP3 or IMAP) is a good way to avoid the costs of installing, configuring and managing a mail server.
You can do this if you write your own mail server, or if your mail server supports hooks to run external programs upon receipt of mail (e.g. procmail).
If you don't have procmail available (or, if on something like Exchange Server, don't feel like writing custom rules or extensions), you're simply better off using a pop3 library to fetch mail.
Obviously, writing a mail server is more difficult than any of the alternatives.
If you're mostly worried about checking potentially hundreds of email accounts, that's solvable by configuring your email server properly. If you're on a hosted provider, ask your server administrator about creating a "catch-all" account that routes all mail to unknown addresses to a single account.
If you're aiming to avoid having to poll a server, consider the IMAP IDLE command. I've successfully written a Ruby client that opens a connection to an IMAP server, and gets told by the server when new mail arrives.
Having issues with a rails 2.2.2 app running on a VPS (Ubuntu 8.10): looking for github repos, posts, anything that covers the right way of setting up email processing. For example, should it be using sendmail or smtp?
This is not Ubuntu-specific.
Configuring the sending of mail doesn't really have a "correct" answer. If you have sendmail working upon your machine (so that "mail foo#bar.com" works) then use that.
If you have an SMTP server running locally, which works, then use that.
The more specific answer really depends on you saying:
What did you try?
How did it fail?
Are you looking to send or receive email (or both)?
The answers will be different in each case, and may (or may not) include configuring a mail server on the VPS.
If you need to configure a mail server the best guides (extensive and step by step) I found are those from slicehost that you find here: Mail server setup and configuration
If you need to just receive emails the best thing is to avoid installing a mail server and let your service provider (or Moogle) handle the incoming email.
Then you have to write some code to fetch those emails form the POP or IMAP server and feed them to the incoming mail handler (which typically is based on ActionMailer). One easy way to write the fetching code is to use the fetcher plug-in which incorporates the following common pattern of interaction with the mail server:
Connect to a remote server (POP or IMAP)
Download the available messages
Process each message (passing it to another object)
Remove all downloaded messages from the remote server
you need to create an instance of the class Fetcher passing the class of the object that will process the emails (plus any other configuration parameters that are needed), then calling the fetch method will execute the steps 1 to 4 above.
The plug-in is on Github: http://github.com/look/fetcher/tree/master and you can use it both to build a daemon (i.e. a process which stays in a loop polling the mail server for new messages), or to write a batch file to be run from cron (taken from the plug-in docs):
begin
Lockfile.new('cron_mail_fetcher.lock', :retries => 0) do
config = YAML.load_file("#{RAILS_ROOT}/config/mail.yml")
config = config[RAILS_ENV].to_options
fetcher = Fetcher.create({:receiver => MailReceiver}.merge(config))
fetcher.fetch
end
rescue Lockfile::MaxTriesLockError => e
puts "Another fetcher is already running. Exiting."
end