Next: , Previous: Mailbox, Up: libmailbox


3.1.3 Mailer

     /* Prefix mu_mailer_ is reserved. */
     #include <mailutils/mailer.h>
     
— Function: int mu_mailer_create (mu_mailer_t *, const char *url)
— Function: void mu_mailer_destroy (mu_mailer_t *)
— Function: int mu_mailer_open (mu_mailer_t, int flags)
— Function: int mu_mailer_close (mu_mailer_t)
— Function: int mu_mailer_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from, mu_address_t to);

If from is not NULL, it must contain a single fully qualified RFC2822 email address which will be used as the envelope from address. This is the address to which delivery status notifications are sent, so it never matters what it is set to until it really matters. This is equivalent to Sendmail's -f flag.

The default for from is provided by the specific mailer.

If to is not NULL, then the message will be sent to the list of addresses that it specifies.

The default for to is to use the contents of the standard "To:", "Cc:", and "Bcc:" fields, this is equivalent to Sendmail's -t flag.

— Function: int mu_mailer_get_property (mu_mailer_t, mu_property_t *)
— Function: int mu_mailer_get_stream (mu_mailer_t, mu_stream_t *)
— Function: int mu_mailer_set_stream (mu_mailer_t, mu_stream_t)
— Function: int mu_mailer_get_debug (mu_mailer_t, mu_debug_t *)
— Function: int mu_mailer_set_debug (mu_mailer_t, mu_debug_t)
— Function: int mu_mailer_get_observable (mu_mailer_t, observable_t *)
— Function: int mu_mailer_get_url (mu_mailer_t, url_t *)
— Function: int mu_mailer_check_from (mu_address_t from)
— Function: int mu_mailer_check_to (mu_address_t to)

Some Usage Notes

Some possible use cases the API must support are:

The Sendmail Mailer

/sbin/sendmail isn't always Sendmail... Sometimes it's a Sendmail-compatible wrapper, so assume /sbin/sendmail understands only a recipient list, -f and -oi, these seem to be pretty basic. Cross fingers.

Pipe to "/sbin/sendmail -oi [-f from] [to...]", supplying -f if there was a from, and supplying the recipient list from the to (if there is no recipient list, assume it will read the message contents for the recipients).

Caution: since the stdout and stderr of Sendmail is closed, we have no way of ever giving feedback on failure. Also, what should the return code be from mu_mailer_send_message() when Sendmail returns ‘1’? ‘1’ maps to EPERM, which is less than descriptive!

The SMTP Mailer

This mailer does not canonicalize the message. This must be done before sending the message, or it may be assumed that the MTA will do so.

It does blind out the Bcc: header before sending, though.

Caution: Mutt always puts the recipient addresses on the command line, even Bcc: ones, do we strip the Bcc: before forwarding with SMTP?

Non-RFC822 Addresses

An address that has no domain is not and RFC822 email address. What do I do with them? Should the user of the API be responsible for determining what is mean by email to "John" means? Or should the be able to configure Sendmail to decide globally what this means. If so, we can pass the address to Sendmail, but we have to decide for SMTP! So, right now these addresses are rejected. This could be changed.