Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!

Use sendmail for iCal reminders Apps
To have all your notifications for iCal sent by sendmail through the shell, first create a backup of, then open iCal.app -> Contents -> Resources -> mailScript.applescript and replace the contents with:
set mysubject to "$1"
set mybody to "$2"
set myrecipient to "$3"

do shell script "echo "" & mybody & "" | mail -s ""
& mysubject & "" " & myrecipient
[The 'do shell' command is split onto two lines; enter it on one when you enter the script]

I haven't extensively tested its compatability, but so far I haven't had any problems using the script to email my phone! Good luck!
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[13,113 views]  

Use sendmail for iCal reminders | 27 comments | Create New Account
Click here to return to the 'Use sendmail for iCal reminders' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Correction and apology...
Authored by: robg on Sun, Sep 22 2002 at 1:47AM PDT
1) I fixed the script; my apologies for not catching it this morning.

2) In the course of editing the article, I managed to delete all the comments (three, I think) that were posted here. One contained the corrections to the script, but I don't recall what the other two were discussing ... apologies again; it wasn't a good night to edit, apparently.

-rob.

[ Reply to This | # ]
Correction and apology...
Authored by: mrbiiggy on Sun, Sep 22 2002 at 2:07AM PDT
Thanks for fixing it! This script is definitely needed by all who don't like the retarded mail.app question of wether or not to send the email or not.. It gets frustrating!

[ Reply to This | # ]
Correction and apology...
Authored by: krove on Tue, Sep 24 2002 at 7:07PM PDT
While annoying, the reason is far from stupid. Security appears to be the main goal of asking the user to allow AppleScript to send mail. If it didn't ask, an unknowing user might launch a malicious AS that gets all the addresses from his/her address book and mails a copy of itself (i.e. what MS Outlook virii do on a daily basis).

Using sendmail is a good workaround, though!

[ Reply to This | # ]
Correction and apology...
Authored by: mrbiiggy on Thu, Apr 3 2003 at 3:17AM PST
While I realize this, and do know why it's there, it's still frustrating having Mail.app get in the way and not getting the email when I'm not around to click "send" :)

[ Reply to This | # ]
scripts for other clients
Authored by: loren_ryter on Sun, Sep 22 2002 at 9:31AM PDT
thanks for pointing out that script location. I suppose it would be left as an excersise for the viewer / user to write scripts for other mail clients.



[ Reply to This | # ]
iChat.app ?
Authored by: mervTormel on Mon, Sep 23 2002 at 1:28PM PDT
the above path in the hint should not be to iChat.app:

iChat.app -> Contents -> Resources -> mailScript.applescript

it should read:

/Applications/iCal.app/Contents/Resources/mailScript.applescript


[ Reply to This | # ]
Whoops!
Authored by: robg on Tue, Sep 24 2002 at 12:52AM PDT
Clearly my fault when formatting the article before posting. It's fixed now.

-rob.

[ Reply to This | # ]
What if I'm logged out?
Authored by: Morgoth on Tue, Sep 24 2002 at 9:07PM PDT
Can AppleScript run if I'm not logged in?

I share my computer with four others so I can't stay logged in.

Right now email notificaiton only works for me while I'm on the machine, which is pretty pointless.

[ Reply to This | # ]
What if I'm logged out?
Authored by: mrbiiggy on Wed, Sep 25 2002 at 2:08AM PDT
ical must be running for it to notify you (i dont believe it has any sort of a daemon process to do this either while the app is not running, or you're logged out) sorry.

[ Reply to This | # ]
iCal doesn't need to be running ....
Authored by: osxpounder on Tue, May 20 2003 at 2:19PM PDT
... on my OSX box, mrbiiggy. Sorry for jumping into the middle of this, but I just wanted to say that, if all you really want is for iCal to send its reminders without bothering you [without even bothering you to start iCal], you merely need to ensure that the "System Events" application is in your Login items. I have it there [and don't even recall how it got there]. I'm logged in round the clock, but iCal isn't open unless I want to go look at my calendar.

My iCal reminders get sent via Mail.app, but that's not a prob for me. It's never asked me whether I want to send, either--maybe this relates to the options I used when setting up Mail with my email account info.

One slight bummer is that Mail.app doesn't close when it's finished sending reminders--I bet that's why you folks want to use sendmail, eh?

---
--
osxpounder

[ Reply to This | # ]
Use sendmail with iCal even when iCal isn't running
Authored by: cybermill on Tue, Oct 1 2002 at 2:46AM PDT
You will also need to edit the mailscript.applescript deeper inside the iCal.app, inside the "iCal Helper.app". After I edited and tested the mailscript.applescript file, I navigated via

cd /Applications/iCal.app/Contents/Resources/'iCal Helper.app'/Contents/Resources/

Once there I made backups of mailInfoScript.applescript and mailScript.applescript using the following commands.

sudo cp mailInfoScript.applescript mailInfoScript-bu.applescript
sudo cp mailScript.applescript mailScript-bu.applescript


Then I copied the same 2 files from the iCal.app resource like so:

sudo cp ../../../mailInfoScript.applescript mailInfoScript.applescript
sudo cp ../../../mailScript.applescript mailScript.applescript


I tried just logging out and logging back in, but it didn't seem to work. Once I restarted, the emails started flowing through sendmail. You still have to be logged in but you don't have to have the iCal app running.

Maybe they can combine this with the original hint so that it is a complete solution.

[ Reply to This | # ]
Use sendmail with iCal even when iCal isn't running
Authored by: darrendavid on Tue, May 6 2003 at 11:09PM PDT
I've tried modifying pretty much every mail*.applescript file i could find (save for "Mail.applescript") and i still can't get iCal to use sendmail instead of Mail.app. Has anyone figured out how to get this working correctly?

[ Reply to This | # ]
Use sendmail with iCal even when iCal isn't running
Authored by: logo on Wed, May 7 2003 at 10:52AM PDT
The file in my case was Mail.scpt.
HTH



[ Reply to This | # ]
Use sendmail with iCal even when iCal isn't running
Authored by: logo on Wed, May 7 2003 at 11:02AM PDT
And then there was the problem to get this email out...

I always get the error message "Domain of sender address does not resolve"

well of course not: logo@localhost will not be a success in the recipient's server!!!

Any way to get a good (my real) address in there as the sender?

I know it's possible if I use a java app that can set the sender!!!

Pleeeeeease!!!!

[ Reply to This | # ]
Use sendmail with iCal even when iCal isn't running
Authored by: tkarches on Tue, May 13 2003 at 3:58PM PDT
I can't get this to work. iCal still uses mail.app after changing all the script files. Do I need to turn sendmail on?

[ Reply to This | # ]
Escape quotes
Authored by: bluehz on Fri, Oct 11 2002 at 12:03PM PDT
I was unable to get this to work until I modified the Applescript to properly escape the quotes.The line I use is:

[code]do shell script ("echo " & "\\"" & mybody & "\"" & " | mail -s " & "\"" & mysubject & "\" " & myrecipient)
[/code]

[ Reply to This | # ]
Escape quotes
Authored by: bluehz on Fri, Oct 11 2002 at 12:29PM PDT
Never mind - I have no idea how to get the string to show up properly...tried it all - no luck...sorry...

[ Reply to This | # ]
Escape quotes
Authored by: bluehz on Fri, Oct 11 2002 at 12:32PM PDT
actually - I don't know how - but the one above is almost properly formatted - remove the first forward slash and it is correct.

[ Reply to This | # ]
the rest
Authored by: Moofisto on Mon, Nov 18 2002 at 12:06PM PST
That leaves mailInfoScript.applescript and mailScriptWithAttachment.applescript in both iCal and iCal Helper.

I'm not sure what the distinct function of mailInfoScript is supposed to be.

[ Reply to This | # ]

Use sendmail for iCal reminders
Authored by: dbikel on Fri, May 16 2003 at 11:25AM PDT
Like a couple of other users, I have tried modifying every single script (except Mail.applescript), but to no avail: iCal (and iCal Helper) still use Mail.app to send reminders. What gives?

One piece of information: I do not have sendmail running.

Anyone out there have a good idea why this hint might be failing for some of us?

[ Reply to This | # ]
want mail via shell command for iCal alarms
Authored by: Moofisto on Tue, May 20 2003 at 4:29AM PDT

Hah. I was just checking back on this topic myself, after peeking into iCal again. There are a lot of scripts in there now to change, maybe you just need to change that last one ;)

Seriously, though, I don't know: looking through my mail, the last time that I got an iCal alarm sent from the BSD mail command was in January. Perhaps an iCal or OS X update brought some of these scripts I see now, because I don't remember seeing all of these. Particularly Mail.scpt which has a creation date of 2003-01-03. If changing all of these doesn't do it for anyone, I won't bother with it, and will dump iCal, as I'm sick of not getting reminders as much I'm tired of Mail.app on me while I'm using Mutt... :p Ah well, I wouldn't feel like editing new scripts with every other 0.0.1 update, anyway.

Even Apple has a replacement script, I see, for launching Applescripts, in special circumstances only, in lieu of Mail.app. It replaces Mail.scpt.



[ Reply to This | # ]
want mail via shell command for iCal alarms
Authored by: dbikel on Wed, Oct 8 2003 at 6:03PM PDT

Seriously, has anyone tried to get ical reminders working through sendmail with the latest iCal (v1.5.1)??? I would love to get this working. I have sendmail up and running (thanks to this macdevcenter link), and would like it so that Mail.app doesn't ruin my local pine session every time it's time for an e-mail reminder.

In case you are wondering, I have tried replacing mailScript.applescript and Mail.applescript and compiling the new Mail.applescript into a new Mail.scpt -- all to no avail. (Incidentally, the new Mail.scpt has a zero-length data fork and a non-zero resource fork, but the old Mail.scpt file is the opposite .. very weird.)

Thanks in advance,
Dan.



[ Reply to This | # ]
Use sendmail for iCal reminders
Authored by: dbikel on Wed, Oct 8 2003 at 6:05PM PDT

Seriously, has anyone tried to get iCal reminders working through sendmail with the latest iCal (v1.5.1)??? I would love to get this working. I have sendmail up and running (thanks to this macdevcenter link), and would like it so that Mail.app doesn't ruin my local pine session every time it's time for an e-mail reminder.

In case you are wondering, I have tried replacing mailScript.applescript and Mail.applescript and compiling the new Mail.applescript into a new Mail.scpt -- all to no avail. (Incidentally, the new Mail.scpt has a zero-length data fork and a non-zero resource fork, but the old Mail.scpt file is the opposite .. very weird.)

Thanks in advance,
Dan.



[ Reply to This | # ]
Use sendmail for iCal reminders
Authored by: dbikel on Tue, Oct 14 2003 at 12:44PM PDT

Woops. The only script that gets used is Mail.scpt, and I had modified Mail.applescript incorrectly before compiling it into Mail.scpt.

In order to get iCal reminders flowing through sendmail with the latest iCal (which, at the time of this writing, is 1.5.1), copy the Mail.applescript file from /Applications/iCal.app/Contents/Resources to some other convenient location (such as your ~/Desktop directory). Use ScriptEditor to change the function send_mail_sbr to be

on send_mail_sbr(subjectLine, messageText, myrecipient)
	do shell script ("echo \"" & messageText & "\" | mail -s \"" & subjectLine & "\" " & myrecipient)
end send_mail_sbr
and then use the ScriptEditor's "Save As Run-Only..." command to save a compiled version of this script; call this file Mail.scpt. Then, use /Developer/Tools/MvMac to change the name of the old Mail.scpt to something else (like Mail.scpt.old) and use /Developer/Tools/CpMac to copy the new Mail.scpt to /Applications/iCal.app/Contents/Resources. Finally, to make the ownership and permissions be identical to the old version of Mail.scpt, do a
sudo chown root:admin Mail.scpt
sudo chmod 664 Mail.scpt

Repeat this entire procedure for the Mail.applescript and Mail.scpt files in the directory /Applications/iCal.app/Contents/Resources/iCal Helper.app/Contents/Resources, so that e-mail reminders will flow through sendmail even when iCal is not running.

N.B.: As far as I can tell, you must be logged in to receive e-mail reminders from iCal.



[ Reply to This | # ]
Use sendmail for iCal reminders
Authored by: dbikel on Tue, Oct 14 2003 at 12:52PM PDT
Woops. Backslashes didn't go through prooperly in my previous post. Here's what the replacement code for the send_mail_sbr function should be
on send_mail_sbr(subjectLine, messageText, myrecipient)
	do shell script ("echo \"" & messageText & "\" | mail -s \"" & subjectLine & "\" " & myrecipient)
end send_mail_sbr


[ Reply to This | # ]
Use sendmail for iCal reminders
Authored by: dbikel on Thu, Oct 16 2003 at 10:19AM PDT
test "\""


[ Reply to This | # ]
Use sendmail for iCal reminders
Authored by: dbikel on Thu, Oct 16 2003 at 10:21AM PDT
Argh! You have to escape backslashes with a backslash. Even though they appear correctly when you Preview your comment, there is apparently another level of processing that requires them to be escaped. So, for the final time, here's the code:
on send_mail_sbr(subjectLine, messageText, myrecipient)
	do shell script ("echo \"" & messageText & "\" | mail -s \"" & subjectLine & "\" " & myrecipient)
end send_mail_sbr


[ Reply to This | # ]