« Home safe, but a little freaked out | Main | Jed the Unready »

Autoresponder for Mail.app?


I need a way to automatically send responses to received email using Mail.app in OS X Leopard. Can any of you help me?

Here's how I want it to work (with the difficult parts in italics):

  1. A new message arrives.
  2. A Rule recognizes the new message as one that should get an autoresponse. (This part is easy; no need to tell me how to do this.)
  3. Mail.app generates a response message, using boilerplate text, but does not include the original message or attachments in the response.
  4. Mail.app sends the response message and leaves a copy of the sent message in a particular folder.

The standard approach to autoresponders in Mail.app is to set up a Rule that says "Reply to Message" and specifies message text. Unfortunately, that includes the full message plus all attachments in the reply, which I don't want. Also, it apparently makes the reply vanish, rather than putting it in the Sent folder.

The AppleScript provided by "Set up a Non-Quoting Autoresponder in Mac OS X Mail" seems like it ought to do more or less exactly what I want, but I can't get it to work. I installed it, I set up a rule to call it; the rule gets triggered properly; but the script doesn't run. It sets off some kind of crash log in the Console, filled with stuff I don't understand.

Also, Mac OS X Hints has an article that says that AppleScripts that generate a new Mail message won't run when called from a Rule in Leopard! They provide a wacky workaround in which the Rule calls a mini-AppleScript script that calls a shell script that calls the real AppleScript script. Horribly kludgy, but I'll live with it if I have to.

But I'm pretty sure that some other problem is happening that's preventing me from even getting to that problem.

As a test, I created the following script, put it in ~/Library/Scripts/Applications/Mail, and ran it from the Script-icon menu in Mail.app.

using terms from application "Mail"
	on run
		tell application "Mail"
			display dialog "Hello, world!"
		end tell
	end run
end using terms from

That script works perfectly.

But if I change "on run" to "on perform mail action with messages" and try to call it from a Rule, it dies. Here's that version:

using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		tell application "Mail"
			display dialog "Hello, world!"
		end tell
	end perform mail action with messages
end using terms from

When I open the AppleScript Dictionary for Mail.app and look up "perform mail action with messages", it looks pretty straightforward--and it looks like it's the right way (maybe the only way) to get a message or messages to operate on. But something sure isn't working.

Any ideas? I need to figure out some kind of answer by 9:00 p.m. California time tonight.

If all else fails, I may switch to sending an autoresponse when I enter stories into the database, rather than when the mail arrives. It'll take longer for the responses to go out (sometimes a couple of days), but at least that way authors can be certain that the story has actually made it into our database. We'll see.


If you want to autorespond to every message at a given address, then the only hacky workaround I can think of, knowing naught of AppleScript or mail.app, is to set up a .forward to an account which can send such an autoresponse.

There might be some procmail way to do it, for instance.

But I think, perhaps, that e-mailing after the data is entered makes a certain amount of sense as well.

Thanks, Josh. I don't want to respond to every message, though (only those with "FICTION SUB" at the start of the subject line), and I don't want the server to respond; I want the response to go out after my mail client (Mail.app) receives the message. (I could have the server send an autoresponse as soon as the story is sent, but we already have an acknowledgment screen that says the story has been sent; the autoresponse is meant to indicate that we've actually received it and the mail hasn't gone astray.)

Anyway, I ended up finding a Mail.app plugin called MailTemplate, which lets you create templates and use them for replies (including plugging in pieces of the message you're replying to). Cool beans. Unfortunately, there doesn't seem to be any easy way to use MailTemplate in a Mail.app Rule, so for now my "auto"responses are sent by hand. I'll try and improve that by judicious use of AppleScript over the next few days.

If any of you are good with AppleScript and would be willing to answer questions as I try to learn it, let me know....

Did you ever manage to do this?

I have a similar requirement.

I too found that the "reply" process in Rules doesn't put a copy in the "Sent Items" folder, really annoying and a major bug in my opinion, how are you supposed to keep track of what you have sent if a "rule reply" vanishes into thin air!?!?!?!

I have found another stumbling block too.

As far as I can tell, the "rule reply" process in mail.app seems to use the "From" field in the original messages header rather than the expected "Reply-To" field.

To prove this, I have an email with a different "From" and "Reply-To" address in the header. This is perfectly normal, because the email is an enquiry sent to me from a rentals website. If I want to reply to the enquiry, the reply should go to the "Reply-To" address not the "From" address.

If I manually reply to this message, everything works normal, the "To" field of the reply is correct and contains the "Reply-To" email but if I use a "Rules Reply" on the same message, the email goes to the "From" address and I get an auto-responder message complaining I'm sending to the wrong address.

I can't believe this hasn't been noticed before, its clearly a bug because a reply is a reply no matter how its done and the "reply-to" field should always be used.


I'm trying to do a similar thing. Did anybody get it to work?

I'm having the same problem with one added snag: NO auto-reply message is being sent at all! It's an immense bug. Any working applescripts would be greatly appreciated and sorely needed.

Dave, David, and Jordan: The only solution that I've been able to get working is to buy and use MailTemplate--which doesn't do autoresponses per se, but does let you manually respond using a template. It's not as nice as a real autoresponder, but it works okay, at a volume of around 15-20 messages a day.

But if you're getting hundreds of emails a day that need autoresponses, then this is probably not a great choice.

I'm hoping that at some point Apple will fix the underlying problems in Mail.app that (I assume) are preventing the various AppleScripts from working. But in the meantime, I don't know of a good answer.

Do you know that you can set up a rule with the reply text in the rule? I have them set up to auto reply to incoming messages with certain criteria. The only problem is that attachments are not allowed. Eudora allowed all of this but my new hosting company and Eudora don't get along.

I have the same problem - tested, the rule recognises the email according to the set rules, because I have set it to change colour. However, the response does not go out (which may be why it is not in the sent items folder??!!!) This is really annoying - any got the auto-response to work? i.e. in Rules, set "reply to message" as the action and it sends a reply?

Anonymous: Yeah, I wasn't thrilled about putting the reply text into the rule, but iIrc that was the way to do an autoresponse. But (again iIrc, which I may not) it still included the text of the incoming message as part of the reply.

Eudora worked just the way I wanted it to, but it started crashing too much for me.

Ash: iIrc, there's a bug in Mail.app that prevents some things from working as part of a "reply to message" Rule. But I haven't looked into any of this stuff in over a year, and I don't remember it clearly.

It turns out that in Mail.app in Snow Leopard, the bug has been fixed, so the about.com script works fine when called from a rule.

For much more info, and an expanded script, see my Snow Leopard autoresponder entry.

Post a comment