Fun and games with SMTP and mail protocols
Work is continuing on mailMaker 2.0.
The problem falls in to two areas:
- Sending mail directly from mailMaker
- Processing the message – files (attachments), ‘includes’, and text layout for correct handling and transmission via e-mail.
Sending mail:
There are three approaches:
1. The ‘mail’ can be sent using Apple events/AppleScript
- This is the approach currently used by mailMaker. However, this can be flakey, slow, and unreliable. Hence the need for a change!
2. Using NSMailDelivery –
This is an API hidden in Cocoa (see here). In principle it works very well, however, the protocol is limited in that it can only use the ‘default’ SMTP (simple mail transfer protocol) server. This may not be ideal. Also, handling of formated text is a problem.
3. ‘Roll your own’ (or use someone elses) SMTP protocols –
Using a framework from another developer can be an option but is limited in the level of control you achieve, therefore I decided to ‘roll my own’…..
‘Roll your own’ –
This is easier said then done…. And progress is slow…. The use of NSStream (can only be used for 10.3 or greater) has really helped. It is now just a question of handling the ‘chatter’ between the client and the server. At present things are working, but error trapping is proving to be difficult.
Processing the message:
Sending ‘plain text’ is easy! Sending ‘rich text’ and attachments is difficult….
Done:
Processing ‘left’, ‘right’, and ‘centred’ text – solved
Encoding attachments – solved
(BASE64 can be such fun!)
Getting the correct MIME information an attached file – solved (well for most types!)
Getting text colour right – solved
To do:
Lots of stuff. Far too much to list here…..
(Thanks to Jeff Franklin for help with the solving the MIME problem.)