APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

GETTING A MAC TO "PHONE HOME" WITH AN E-MAIL - NO SENDMAIL, NO POSTFIX

By anonymous

INTRODUCTION

I'm testing a setup, on my own Power Mac G4, for the benefit of my mom and her iMac G4.

My interest, has been to set up my mom's iMac G4, so that, when she connects to the Internet, her iMac "phones home" --- that is, her iMac sends me an e-mail.

So then, I can derive her Internet [WAN] IP address from that e-mail's headers (she's a dial-up customer, with, of course, an ever-changing, "dynamic," IP address on the Internet). I then use that IP address in order to make an SSH connection back to her machine and perform maintenance routines, for her. (She's 83 years old and still quite agile, and she likes her iMac.)

I wanted to do this WITHOUT fiddling around with SENDMAIL or POSTFIX settings and setups, and thus bypass the roadblocks of security "issues" with ISPs' e-mail servers.

I could set up and schedule iCal on the Mac, to use the Mac's Mail.app and send me an e-mail, but Mail.app does not launch quietly (and I have not figured out how to launch it in the form of *isMiniaturized* or something like that, in the Dock) --- instead, Mail.app shows on the iMac's display, and that is going to confuse the situation for my dear ol' mom.

I could order up a file containing her IP address:

 curl -s http://checkip.dyndns.org/ | grep 'Current' > /ip.txt
 

and then send that ip.txt file to an FTP server, and retrieve it from that FTP server, but the challenge has been to "simply get an e-mail" and quietly, from her iMac.

For the following installations, I was using Mac OS X v.10.3.8 Panther, and the XcodeUpdate1.1.pkg is installed. By the way, when I install Mac OS X on any Mac, I always include the BSD Subsystem, X11, and the Developers Tools. For Mac OS X updates, such as from v.10.3.4 to 10.3.8, I always use the "combo" updates from Apple's Support > Downloads website. In other words, I try to set up the Mac with the extras that will help it in the UNIX environment, such as with these installations, described on this page

The remainder of this e-mail is in two parts and very detailed, because every little piece of installation information helps other Mac users to NOT go through a lot of grief; the Mac, having subtle command and file location differences from the Linux PC.

The first part describes my installation of Pine 4.62 which was successful up to a point, where I could not figure out how to get Pine to run entirely without user (keyboard) input, such as from a script.

The second part describes my installation of Email 2.3.2 which was successful.

(I use the terms, folder, and, directory, interchangeably; ie. they're the same thing.)

INSTALLING PINE 4.62

I consulted these instructions: http://www.novajo.ca/pine.html

I included in the Pine installation, a version 4.62 patch, available at: http://www.math.washington.edu/~chappa/pine/info/fromheader.html

I cd'd to my home directory and downloaded the Pine file:

 curl -O ftp://ftp.cac.washington.edu/pine/pine.tar.gz
 

I placed the downloaded Pine file in my home directory on the Mac, so the file was now at:

 ~/pine.tar.gz
 

I made sure that I was in my home directory and decompressed that file, with this command:

 gnutar zxf pine.tar.gz
 

The result was a new folder in my home directory:

 ~/pine4.62
 

I cd'd to my home directory and downloaded the version 4.62 patch and placed it in my home directory:

 ~/fromheader.patch.gz
 

I made sure that I was in my home directory and decompressed that file, with this command:

 gnutar zxf fromheader.patch.gz
 

The result was a new file in my home directory:

 ~/pine4.62.fromheader.patch
 

I placed a copy of that patch file, into the folder, pine4.62 :

 ~/pine4.62/pine4.62.fromheader.patch
 

I cd'd into that folder, pine4.62 , and I ran this command:

 patch -p1 <pine4.62.fromheader.patch
 

The results:

 patching file pine/init.c
 patching file pine/pine.h
 patching file pine/pine.hlp
 patching file pine/send.c
 

Then, I continued with the installation steps at http://www.novajo.ca/pine.html as follows ...

Making sure I was in the ~/pine4.62 directory, I used this command suggested by the author:

 ./build osx EXTRACFLAGS='-DPASSFILE=.pine.pwd'
 

and, after the errors that author mentions:

 imap.c: In function `passfile_name':
 imap.c:3182: error: parse error before '.' token
 imap.c:3183: error: parse error before ')' token
 imap.c:3188: error: parse error before '.' token
 make: *** [imap.o] Error 1
 

I used this command suggested by the author:


 ./build osx EXTRACFLAGS='-DPASSFILE=\".pine.pwd\"'
 

Then, these commands suggested by the author, in succession:

 sudo install -o root -g admin -m 755 -d /usr/local/bin
 sudo install -o root -g admin -m 755 -d /usr/local/share/man/man1

 sudo install -o root -g admin -m 755 -c bin/pine bin/pilot /usr/local/bin
 sudo install -o root -g admin -m 644 -c doc/pine.1 doc/pilot.1 /usr/local/share/man/man1
 

Then, in the author's section, "Setting up the files:" I skipped the rehash command, only using these commands in succession:

 cd
 /usr/local/bin/pine -pinerc .pinerc
 cd
 touch .pine.pwd
 chmod 700 .pine.pwd
 

My Mac did not comprehend the rehash command, and actually, I don't need its purpose, here; so, like I said, I skipped it.

Also, I did NOT use the author's suggestions for modifying this file:

 ~/.pinerc
 

Instead, I launched Pine 4.62 and used its Setup > Config features, in order to enter the information about my e-mail address, my ISP's SMTP server, and such.

Works good.

Yet, I obviously do not know enough, and I could not quite figure out how to get Pine to do what I was after, which is to function quietly, without user input, entirely by way of a bash script, that is used by a cron job (I use CronniX).

So ...

INSTALLING EMAIL 2.3.2

I happened upon this website and an article by A.P. Lawrence: http://www.aplawrence.com/Reviews/cleancodeemail.html

I read enough to get the general idea, and then I went to: http://www.cleancode.org/projects/email

I downloaded the email-2.3.2 file: http://www.cleancode.org/downloads/email/

(I used Interarchy 7.3.1 for downloading that.)

I placed the file in my home directory on the Mac, so the file was now at:

 ~/email-2.3.2.tar.gz
 

I cd'd to my home directory and used this command to decompress the file:

 gnutar zxf email-2.3.2.tar.gz
 

I cd'd into the new directory:

 cd ~/email-2.3.2
 

IMPORTANT ---

In order to use the author's suggested commands, I had to duplicate two files in that directory:

 email.1.in
 email.help.in
 

The duplicates, I named:

 email.1
 email.help
 

So, now, the directory held these:

 ~/email-2.3.2/email.1
 ~/email-2.3.2/email.1.in
 ~/email-2.3.2/email.help
 ~/email-2.3.2/email.help.in
 

BECAUSE, IF YOU DO NOT DO THIS, THE INSTALLATION WILL FAIL, GIVEN THE INSTALLATION COMMAND PROVIDED BY A.P. LAWRENCE --- which I also had to correct --- he had, in his command:

 ./install-sh
 

which needed to be:

 ./install.sh
 

and the version number needed to be changed to:

 2.3.2
 

So ... making sure that I was in:

 ~/email-2.3.2
 

I used A.P. Lawrence's command (corrected, and all one line):

sudo ./install.sh --bindir /usr/local/bin --sysconfdir /usr/local/etc --mandir /usr/local/man --binext '' --version "2.3.2" --docdir /usr/local/doc

And finally, I got this result:

Success!
#######################################################
Done installing E-Mail client.
Please read README for information on setup and use.
If you have any questions or concerns...
Please e-mail: [email protected]
#######################################################

Yet, a check of the /usr/local/bin directory, showed that there was NO file --- email --- it DID NOT exist:

/usr/local/bin/ < hunh? >

Hmm ... it seems that, in fact, the installation was NOT --- repeat, it was NOT --- a "success."

I reviewed the situation, considering another approach.

A.P. Lawrence states, "For some reason I didn't investigate, "make install" didn't work, so I just did it by hand."

Well, I did not exactly investigate. I guessed.

While installing Pine, and examining the contents of this folder, ~/pine4.62 , I found a file that gave me the idea, and it is also why I mention the Pine installation, in detail, preceding. The term "make" rang some bell in the ol' noggin, something having to do with installations on a Linux PC, and I remembered seeing a file:

~/pine4.62/makefile

(You folks are all "old hands" and geniuses or geeks at understanding all this, and several shortcuts and other wisdom have no doubt come to your minds, about how you would proceed or doing all this, but I am quite new at installing anything from the command line on a Linux PC or on a Mac. The "hacking" that I was doing, was as if through a jungle!)

I found, in the directory:

~/email-2.3.2

there is a file named:

Makefile.in

I duplicated that file and named the duplicate:

Makefile

I also looked here, in order to confirm my "wild guess": http://vertigo.hsrl.rutgers.edu/ug/make_help.html (link dead, sorry)

They state:

Makefile Naming
"make is going to look for a file called Makefile, if not found
then a file called makefile..."

Then, in the ~/email-2.3.2 directory, I had three name-modified duplicates, resulting in:

~/email-2.3.2/email.1
~/email-2.3.2/email.1.in
~/email-2.3.2/email.help
~/email-2.3.2/email.help.in
~/email-2.3.2/Makefile
~/email-2.3.2/Makefile.in

Making certain that I was in the directory:

~/email-2.3.2

I used this command (suggested by email-2.3.2's author, Dean Jones, in his README file):

./configure

The result, lots of what I call progress statements ... and at their conclusion, I used this command:

su -c 'make install'
>

You are prompted for your root password. I entered it and at the next prompt, I used this command:

make install

Results:

./install.sh --bindir "/usr/local/bin" --sysconfdir "/usr/local/etc" \
--mandir "/usr/local/man" --binext "" --version "2.3.2" \
--docdir "/usr/local/doc/email-2.3.2"
Installing email v2.3.2...
Binary directory: /usr/local/bin
Man directory: /usr/local/man
System configuration file directory: /usr/local/etc
Copying src/email to /usr/local/bin...
Copying Files to '/usr/local/etc/email' directory...
Copying man pages to /usr/local/man/man1...
Copying email help documentation to /usr/local/doc/email-2.3.2/email-2.3.2...
Success!
#######################################################
Done installing E-Mail client.
Please read README for information on setup and use.
If you have any questions or concerns...
Please e-mail: [email protected]
#######################################################

I again checked the /usr/local/bin directory, to see if email was there, and it was, finally:

/usr/local/bin/email

Yeah!

I used the text editor BBEdit, in order to edit the email.conf file at:

/usr/local/etc/email/email.conf

(BBEdit and TextWrangler 2.0 have the great ability to open hidden files and folders.)

I edited these lines:

SMTP_SERVER = '______________' (fill in your ISP's SMTP e-mail server)
MY_NAME = '________' (fill in any name, Bill, Jane, whatever)
MY_EMAIL = '_________________' (fill in your e-mail address)
REPLY_TO = '_________________' (fill in your e-mail address)

I did not bother to "set the environment variable "EDITOR" to my favorite editor," because I'm only trying to get a "blip" so to speak.

I cd'd back to my home directory and used this command, to send myself a test e-mail:

/usr/local/bin/email -bq [email protected] (fill in your e-mail address)

Works good!

Now, I can use CronniX to set up a scheduled task that checks for an Internet connection.

Testing for the connection, using the following script, includes the e-mail "blip" to me, if the connection exists (is true):

string1="IP"
string2=`curl -s http://checkip.dyndns.org/ | grep 'Current' | awk '{print $2}'`
if test "$string1" = "$string2"
then /usr/local/bin/email -bq [email protected]
fi

Please note the distinctions between the use of the "back tick" and the apostrophe in the second line, beginning with string2 --- after the equal sign there's a "back tick" and at the end of the line, too.

I also read that "The 'policy' on quotation marks is to put them around any variable that might be empty. That way, after variables have been expanded, there will at least be a set of empty quotes to denote a null value, rather than absolutely nothing, generating a syntax error." ( see: http://www.fedoraforum.org/forum/archive/index.php/t-2827.html )

That is why I have quotes around the variables $string1 and $string2 in the third line.

The CronniX website: http://code.google.com/p/cronnix/

There, you'll find the explanation(s) for using CronniX to set up scheduled tasks on the Mac.

BTW, I don't usually use the #!/bin/sh ... "convention" for creating and saving scripts. Instead, I save them as a text file, in a folder named tasks in the root directory:

/tasks

and I run them by using something like this command:

/bin/sh /tasks/net.txt

In this case, net.txt being the script, preceding, for testing for an Internet connection and "phoning home" by way of a simple, quiet e-mail.

- end of story -

Thank you all, for your tips and information, with which I pounded my way through the weekend, toward unraveling a mystery that I have been trying to solve for over a couple years.



Got something to add? Send me email.





(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> -> GETTING A MAC TO 'PHONE HOME' WITH AN E-MAIL - NO SENDMAIL, NO POSTFIX

2 comments



Increase ad revenue 50-250% with Ezoic


More Articles by © anonymous







Mon Feb 28 23:10:52 2005: 93   TonyLawrence

gravatar
Nice article, thank you. And good for Mom, too :-)





Wed Mar 9 15:55:12 2005: 120   anonymous



I've managed to get the latest DNS software, bind-9.3.1rc1 installed and running OK on the Mac.

Among the several websites webpages that I came across, while trying to comprehend the mysteries of Bind 9, was: (link)

Having had a victory, this evening (getting the bind-9.3.1rc1 installation to work), I went for a little tour around that website, and moments ago, I found this: (link)

I thought that Paul Heinlein's explanation about installing Pine (which I did not read thoroughly), would interest you and your readers.

------------------------
Kerio Connect Mailserver

Kerio Samepage

Kerio Control Firewall

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us