Hi everyone.
Thx for your help in many times. I’ve make my first donation to Macscripter. I’n not (already) a true boss of AS, so this is the only way to help community.
So, here you are
I’m away from my Mac for many times, so I think it can be intesting that it mail me everytime someone turn it on but, this is the key, without any interface. The only way that I think is to make a simple shell command in a AppleScript budle application that mail me something like… “Hello” to my mail.
But it seems to be not so easy.
Does someone know a shell command to do something like…
set messTo to "to@isp.com"
set messFrom to "from@isp.com"
set messSub to "Message subject"
set messBody to "message" & return & "body"
do shell script "echo " & (quoted form of "" & messBody) & " | mail -s " & (quoted form of messSub) & " " & messTo & " -f " & messFrom
I have noted that certain characters generate an error if they are in the message body when you execute the above shell script. You should parse out or remove the offending characters. Suggested subroutine to do this is set out below.
That said, there may be a much cleverer shell script way to allow the offending characters through without generating an error and without the need to parse them out.
to parseout(stringtoparse)
set illegals to "<>|&()`'" & (ASCII character of 47)
repeat with i from 1 to count (illegals)
set testletter to (text i thru i of illegals)
set the_offset to 1
repeat
set the_offset to offset of testletter in stringtoparse
--display dialog the_offset as text
if the_offset > 0 then
if the_offset = length of stringtoparse then
set stringtoparse to (text 1 thru (the_offset - 1) of stringtoparse)
else if the_offset = 1 then
set stringtoparse to (text (the_offset + 1) thru -1 of stringtoparse)
else
set stringtoparse to (text 1 thru (the_offset - 1) of stringtoparse) & "" & (text (the_offset + 1) thru -1 of stringtoparse)
end if
else
exit repeat
end if
end repeat
end repeat
return stringtoparse
end parseout
Your computer has a mail server (I believe it’s postfix on 10.5 and maybe 10.4 too) that unix mail uses. The default configuration is to only allow email sent to local accounts on your computer. If you try to send email to someone else it won’t work. For that to work you have to set up the mail server, and that’s where you would enter your smtp address.