FTP-uploading via e-mail manual

There are enough free FTP->mail servers, this is the first free
publicly accessible beta mail->FTP service intended for users who
can't use a FTP client (have email-only access or are behind a
firewall not allowing FTP-uploading). If you can (have full-fledged
online access), use a FTP client - it's faster and more convenient.
Please don't overuse this free service possible in this
beta release thanks goodwill of the free CGI hosting service
http://www.hypermart.net/, or HyperMart will close it. If such sad event
happens, download my "http://elena.stealth.ru/mail2ftp.htm page again - 
I'll try to set up this service somewhere else, but I promise nothing.

For FTP->mail file downloading and FTP directory listing use other
servers - ftpmail, www4mail etc.  If you don't know how, download
Accessing The Internet By Email (Guide to Offline Internet Access):
send "send lis-iis e-access-inet.txt" to  mailbase@mailbase.ac.uk

Besides this manual, this service consists from just one CGI script.
The script doesn't store usernames, passwords, e-mail addresses.

This service is provided free of charge, "as is" - I guarantee nothing
and am not liable for anything. I'll not answer to user questions.
If you can use this service, enjoy. If you can't, have problems - you
are out of luck. You can try to ask for help from other users on the
ACCMAIL mailing list, for subscription send "subscribe ACCMAIL" to
LISTSERV@LISTSERV.AOL.COM

   How you can FTP-upload via e-mail

1. Register your own separate (only for mail2ftp) account
on a free POP3 service. It's the most difficult part,
but you need to do it only once. Details below.

2. Send an e-mail letter with mail2ftp commands and files for
uploading (binary files uuencoded) to that POP3 account.

3. Wait a little for the letter to reach POP3 account.

4. Send another e-mail letter with the script's URL to a
web-mail server. URL must contain data about the POP3 account:
POP3 hostname, username and password. Web-mail server requests
that URL from HyperMart web-server. HyperMart web-server invokes
the script. Script reads the first e-mail letter from POP account,
processes mail2ftp commands, transfers data from POP3 account
to FTP server, deletes processed e-mail letter from POP3 account
and sends log to the web-mail server. Web-mail server sends log
to you in reply to your second e-mail letter.

   The script's URL

http://mail2ftp.hypermart.net/pop.cgi?host=***&amp;user=***&amp;pass=***
Substitute asterisks for POP3 host name, username, password.
Hostname and username can contain Latin letters, numbers,
'.', '_', '-'. For example, you can send following line
in the body of a letter to  page@grabpage.com
(names and password in this example are fictional):

URL: http://mail2ftp.hypermart.net/pop.cgi?host=pop.aa.com&user=joan&pass=h4EKg8m

The script processes and deletes only one e-mail letter from
POP3 account. If the account contains more letters, the script
processes one letter, deletes it and then warns you. You can
invoke the script again (same URL). If you invoke the script
when the POP3 account is empty, nothing bad happens - the script
warns you and does nothing. In case of an error the script
terminates processing of the letter, deletes it and sends log
with error message via the web-mail server to you.

There aren't limits of file size, of quantity of files in one
e-mail letter, of quantity of letters from a user. Just remember
that in case of very long letters web-mail servers can terminate
processing complaining of timeout errors (some web-mail servers
don't say "timeout", just "an error" or "can't" or such).
The script processes files one line at a time and doesn't store
whole file in memory, so it doesn't eat up HyperMart server's memory.
I tried to optimize the script for speed.

   Commands

All mail2ftp commands are case insensitive. Filenames usually are
case sensitive. EOF string is case sensitive. Blanks before a command
aren't allowed, i.e. each command must begin in the first column of
a line.

The very first line of body of the email letter sent to POP3 account
must contain the MAIL2FTP command. The letter's header including
Subject and From is ignored (except checking for quoted-printable
encoding). You must set up your mail client to send plain text only.
If the letter is a multipart MIME message (is in HTML format or
contains attachments) then the script will report the error
"Invalid syntax of first line of letter body" and the letter will be
deleted without processing. Your mail client must not encode letter
body (MIME/base64 or quoted-printable), or else you'll get an
error message and the letter will be deleted without processing.

Empty lines between commands and after last command are ignored.
Empty lines between PUT command and EOF string get included into
uploaded file.

   MAIL2FTP command

mail2ftp hostname username password
Substitute "hostname", "username" and "password" by the data
of the FTP account. Hostname and username can contain
Latin letters, numbers, '.', '_', '-'.  (Fictional) example:
mail2ftp ftp.bb.com joanna k5oBRd9

   Text file uploading - PUT command

put filename
The file for uploading you must place immediately after
the put command. After the file place a string containing only:
EOF
(case-sensitive). You can use another EOF string - see description
of SETEOF command. If the file existed, it'll be replaced
(see also RENAME command). End-of-line characters will be translated
according to the FTP server's conventions. File can contain
8bit text characters (texts on non-English languages).

   Binary file uploading

Just place uuencoded file into the letter. The first line of
uuencoded file (begin XXX filename) serves as a command. Permissions
(three or four digits 0-7 between "begin" and filename) are ignored.
Uuencoded file must end by the "end" string. If the file existed,
it'll be replaced (see also RENAME command). If your uuencoder
uses blanks instead of backticks ("`" characters) then your text
editor and mail client must not compress consecutive blanks into
one blank and must not omit blanks at ends of lines, or else you'll
get the error "invalid string of uuencoded file". In such case find
an uuencoder which uses backticks (the string just before "end"
must contain one backtick). If your uuencoder places a header before
"begin" line or/and checksums after the "end" line, remove them.

   CD command

cd dirname
If you want to upload to a directory other than one the FTP server
places you into when you login to your account, specify
CD command[s] before first PUT command or uuencoded file.
Note that many FTP servers place you in the main (or the only)
directory you own on the FTP server (depending on your username
on the FTP server), so you needn't use CD command.

   CDUP command

cdup
Changes your current directory one level up. Practically always your
attempts to CDUP from the directory the FTP server placed you into
at login will be unsuccessful (ignored).

   PWD command

pwd
prints name of your current directory on the FTP server to the log.
If the FTP server placed you in your directory at login, that
directory seems as "/" to a FTP client (the script in this case).

   DEL command

del filename
Deletes a file on FTP server.

   RENAME command

rename oldname newname
Renames a file. If newname already existed, that file will be
deleted automatically. When you update a file uploading new version
to the FTP server, I recommend to specify another name and then
rename it to the right name - then in case of an error (timeout,
corrupted uuencoded file etc.) the file will not remain corrupted
on FTP server. Example:
put index.htm
(file)
EOF
rename index.htm index.html

   MKDIR command

mkdir dirname
Creates a directory (if the FTP server allows it).

   RMDIR command

rmdir dirname
Deletes (removes) a directory (perhaps must be empty).

   GETSIZE command

getsize filename
Prints size of the file on the FTP server to the log.
Rarely needed because PUT command and uploading of binary file
(uuencoded file) determine and print size of just uploaded file.

   CHMOD command

chmod permissions filename
If you don't know what chmod is, then you needn't it.
Permissions must be specified as 3 or 4 octal digits (0-7).
The FTP protocol haven't a command for changing the permissions
of a file on the remote server. But some FTP servers
may allow a chmod command to be issued via a SITE command,
the pop.cgi script tries to do it if a user issues CHMOD command.
But this is not guaranteed to work. Note that permissions
in "begin" line of uuencoded file are ignored. Example:
chmod 755 myscript.cgi

   SETEOF command

seteof string
If your text file contains "EOF" string, use SETEOF command before
PUT command. For example, this manual contains "EOF" strings, so
I uploaded it using the script it describes :) and "seteof MYEOF"
command.

   APPEND command

append size
This command allows to upload files in parts - useful if your
mail client or ISP limits size of letters you can send, or if
you can't avoid timeout errors uploading a very large file.
You "cut" the file on your disk to parts. How to do it
is your problem - find a suitable program (there are plenty)
or write it. Upload first part, the script will tell you its
size on FTP server (for text files can differ from size on
your disk). For example, the script said:
uploaded file is 49743 bytes long
Then you upload second part, specifying
append 49743
before the PUT command (with same filename) or before uuencoded
file (with same filename in the "begin" line). The script checks
that the file has specified length, and if so, appends second part
after already uploaded part and tells you size of combined parts.
Then you repeat this process for each remaining part.

   QUIT command

quit
Terminates processing of the e-mail letter. Useful if your mail
client places a signature in your letters or if your ISP or the
POP3 service places an advertisement at the end of each letter.

   Command aliases

put - upload
cd - chdir, cwd
del - delete, erase, remove
rename - ren
mkdir - md
rmdir - rd
getsize - size
append - offset
quit - end, stop, a line with first "-" or "_" character

   Timeouts

If you get timeout errors from the web-mail server, try to use
another web-mail server or upload one file at a time.
If it doesn't help with a very large file, upload it in parts
(see APPEND command). Note that despite of a timeout error,
the e-mail letter with mail2ftp commands could be processed
successfully (or partially), you just don't get the log.

   Port number

You can specify port number after hostname (separated by colon).
It's rarely needed, if ever.

   How to register an account on a free POP3 service using
   accmail methods (entirely by e-mail)

There are many free POP3 services. They appear, improve, deteriorate
and go; differ in reliability (percent of downtime), advertising
policy, registration requirements. Lists of POP3 services:
http://www.emailaddresses.com/email_pop.htm
http://fepg.net/pop3.html
http://www.beebware.com/email/pop3.html
http://www.geocities.com/SiliconValley/Vista/8015/pop3.html
http://www.chez.com/ayhan/pop3.html
http://www.netins.net/showcase/phdss/freebies/popemail.htm
http://dos.ipclub.ru/free/ub/pop3e.html
http://www.freestuff.gr/en/free_email/free_email.shtml
http://dmoz.org/Computers/Internet/E-mail/Free_E-mail/POP3/
http://www.ashlists.org/pop3
There is a mailing list about free POP3 services - for subscription
you can send "subscribe pop3" to  Majordomo@ASHLists.org

Usually registration is done by filling of forms on web-sites.
Some sites require cookies - in such case use a www4mail server
which supports cookies. In February 2000 www4mail@wm.ictp.trieste.it
and www4mail@ftp.uni-stuttgart.de supported cookies,
www4mail@unganisha.idrc.ca and www4mail@web.bellanet.org didn't.
You can check does a www4mail server currently support cookies by
HELP INFO command. If a site doesn't require cookies for POP3
account registration then you can use any www4mail or getweb server
for registration.

You must choose username (login name) and password. Username can
contain Latin letters, numbers, ".", "_", "-". If username already
is in use, you'll have to try other username. You can underestimate
fantasy and quantity of other users, so a name which seems
original enough for you, easily can be already taken.
Nobody except you will use the username, so it haven't to be short
or easily-pronounced. So I recommend to use your name and 5-6 random
characters. Example:  lena9sm3r   Password will be sent via e-mail
and can be intercepted by hackers, so devise separate password for
the POP3 account, don't use a password you use also for something else.

In February 2000 I asked on the POP3 list for free POP3 services
which meet following criteria:

1. Registration can be done by accmail methods and doesn't require
cookies.
2. The service doesn't place ads in separate letters added to POP3
account.
3. The service doesn't place ads in beginning of letters.
4. Web-site in English language.
5. The service is more or less reliable, rarely down.

Alan S. Harrell recommended two POP3 services, their web-sites:
http://www.mailandnews.com
http://www.operamail.com
Both use same software, both don't place ads in letters at all.
I registered (by accmail methods) two accounts (one on each
of services) and used them for debugging of the script. I used a
getweb server for registration, but a www4mail server could be used.
You can begin from one of following pages:
http://www.mailandnews.com/register
http://www.operamail.com/register
Registration consists of filling of two forms. MailAndNews requires
to fill telephone number, but I entered "sorry, private" and it was
accepted. OperaMail placed an introductory letter to the POP3
account after registration, so I had to repeat invoking of the
script once. Host names: mailandnews.com, operamail.com
Addresses where to send letters with mail2ftp commands to:
username@mailandnews.com, username@operamail.com
(for abovementioned example: lena9sm3r@mailandnews.com).


Lena

----------

Credits:

http://www.hypermart.net - for free CGI hosting

Jane McCormack http://www.jjmdesign.com on womendesigners
list - for the advice to try http://www.hypermart.net

Faisal Nasim swiftkid@bigfoot.com,faisal@nasim.org -
for tips in news://news.hypermart.net/hypermart.help.cgi
and module locator+manpages http://wss.hypermart.net/hm/

Matt Wright - for TextCounter 1.2.1
http://www.worldwidemart.com/scripts/

Gerald E. Boyd gboyd@netcom.com - for ACCMAIL list

high prices and low wages in Ukraine - for incentive to use
accmail methods :)
