Idea: using a URI for sending email

In order to send an email over SMTP, you need 2 sets of information:

  • WHAT: the content of the email, i.e. from-address, subject, to/cc addresses and the actual message (in TXT and/or in HTML)
  • HOW: you also need the name/address of an SMTP server (and its SMTP port), and optionally a username/password to authenticate to the server (ESMTP) – these would typically be fixed for the email sending application.

On the other hand, you have the HTTP GET format where you can put everything you need to execute the request in 1 string: /hr /request /?type=holiday&start=2004-11-22&end=2004-11-24
No need to save the ‘server/port’ data separate from the ‘request’ location or from the actual content.

Which inspired me to a similar format for sending email:

smtp://[username[:password]]@server[:port] /from:address [/subject:text] [/to:address] [/cc:address] [/bcc:address] [?[subject=text] [&message=text] [&to=text] [&cc=text] [&bcc=text] [&attachment=file]]

Some examples:

  • smtp:// / /subject:Test+was+OK%21 / /?message=Here+I+am%21
  • smtp://localhost:2525 / /subject:webserver+3+is+down ?
  • smtp://james:password@localhost / /subject:this+is+authenticated /

Keep in mind: a URL is typically limited to 255 characters (depending on implementation), and a querystring (the part after the “?”) is limited to 4KB.

  • Out of principle, the from address should always be specified as the 1st level pseudo-folder /from:address/. Because it should never be longer than 100 characters, and there should always be one, and only one.
  • If your subject is more than 200 characters, you need the ?subject=text notation. Otherwise the /subject:text/ is preferable because you would be less inclined to specify more than 1 subject.
  • If your message content is more than 200 characters, you need the ?message=text. If you need more than 4KB, you could use the equivalent of a HTTP POST, i.e. not specify it in the URL string, but stream the whole this after giving the request.
  • You could allow multiple /cc:address/ entries, or just use a /cc:addr1;addr2;addr3/
  • to allow ‘pretty’ email addresses, you could allow / (Any better suggestions for that?)
  • You could allow a smtp://default/... if you still want your email sending application to choose its SMTP server.
  • Attachments can be specified with an address on a local disk, or on the Internet (with another URI)

The advantages of this system?

  1. you can specify a complete email in 1 single text string (with size limitations)
  2. one could easily specify a lists of emails to be sent (e.g. a text file with 1 email per line), and use different SMTP servers for some of them (e.g. send the Hotmail/MSN ones directly to mx? for speedy delivery)
  3. it can be interpreted by the SMTP client (email sending application), that translates it into a regular SMTP conversation (HELO ... MAIL FROM ... RCPT TO ... DATA)
  4. it could easily be accepted by a web server, that accepts the URI with the smtp:// replaced by http://. One could send an email by just clicking on a link in a browser. The server would of course not accept these requests from anyone, otherwise it would be an easy spam machine. But one could send emails with cURL or WGET. How about that?
  5. if a company stores all sent messages on a special server, you could have a search-within-your-emails-site with +- the same URI format: / /?subject=*contract* &notbefore=2004-11-15 &notafter=2004-11-20 &to=*robert*
  6. One could also adopt smtps:// for SMTP over TLS.

If anyone can do something useful with this, be my guest!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.