smtpx.lsp

Module index

source download

Module: smtpx.lsp

Send mail using SMTP protocol

Version: 3.1 - "\'"real name\" " now supported in
- added Date to (send-mail-header) using a gettimezone hack to avoid DATE_MISSING spam test - Fixed "Bare lf's in body" error to make servers using RFC822 Spam filtering happy Note: - My quick hack at (gettimezone) needs to be improved to work world-wide :) Version: 3.0 - Partial rewrite for Dragonfly. Addition attachments, custom port and proper utf8 encoding for subject/message/attachments
Version: 2.3 - fix in mail-send-body, thanks to Alessandro
Version: 2.2 - doc changes
Version: 2.1 - changes for 10.0
Version: 2.0 - March 2008, Cormullion added AUTH PLAIN authentication
Author: Lutz Mueller 2001-2009, Cormullion 2008, Greg Slepak 2009-2010




syntax: (SMTP:send-mail str-from str-to str-subject str-message [str-server [str-usr str-pass [int-port]]])
parameter: str-from - The email address of the sender. "\"real name\"mailname@domain.com" support added in 3.x
parameter: str-to - The email address of the recipient.
parameter: str-subject - The subject line of the email.
parameter: str-message - The message part of the email.
parameter: str-server - The address of the SMTP server (default: "localhost")
parameter: str-user - Optional user name for authentication.
parameter: str-pass - Optional password for authentication.
parameter: int-port - Optional port to communicate on (default: 25)

return: On success true, on failure nil.

In case the function fails returning nil, the function SMTP:get-error-text can be used to receive the error text.

Example:
 (SMTP:send-mail "jdoe@asite.com" "somebody@isp.com" "Greetings"
   "How are you today? - john doe -" "smtp.asite.com" "jdoe" "secret")

 This logs in to the server, tries to authenticate using the username 'jdoe' and password 'secret' (if supplied),
 and sends an email with the format:

  From:    jdoe@asite.com
  To:      somebody@isp.com
  Subject: Greetings
  Message: How are you today? - John Doe -


§

SMTP:get-error-text

syntax: (SMTP:get-error-text)

Call this to get the reason send-mail returned nil.



§

SMTP:clear-attachments

syntax: (SMTP:clear-attachments)


§

SMTP:attach-document

syntax: (SMTP:attach-document str-content str-filename [str-disposition [str-mime-type [str-encoding]]])
parameter: str-content - The attachment data.
parameter: str-filename - How you'd like your attachment to appear named in the email.
parameter: str-disposition - "attachment" or "inline". default is "attachment".
parameter: str-mime-type - default is "application/octet-stream".
parameter: str-encoding - default is "base64". If encoding is "base64" it will be automatically transformed using encode64-widthsafe


§

SMTP:encode64-widthsafe

syntax: (SMTP:encode64-widthsafe buff-data)

Useful for attaching binary data such as images. Converts the data into base64 and chops it up so that the lines are not longer than 76 characters long, making it safe to include in the body of emails.

If the attachment's encoding to "base64" (which it is by default), this function will automatically applied to the str-content of the email.

Fixed "bare lf's in body" error to make servers using RFC822 Spam filtering happy V3.x

§

SMTP:encode64-line

syntax: (SMTP:encode64-line str-line)

Creates a base64 UTF-8 compatible string, suitable for including foreign characters in the subjects of emails. This is used by send-mail automatically on the filename of any attachments, as well as the subject of the email.



- ∂ -

generated with newLISP  and newLISPdoc