<- SSL Encryption and HTTP Authentication Contents API - Overview of Classes, Methods, and Fields ->

Sending Emails

The JWIG API contains a simple technique for sending emails from the server:

class dk.brics.jwig.runwig.Service
public boolean sendMail(java.lang.String to,
                        java.util.Map header,
                        java.lang.String body,
                        java.lang.String enc)
Sends email.
Parameters:
to - receiver email address
header - map from String to String containing header fields
body - email contents
enc - encoding (e.g. iso-8859-1)
Returns:
false if an error occured

Example:

    HashMap header = new HashMap();
    header.put("MIME-Version", "1.0");
    header.put("Content-Transfer-Encoding", "8bit");
    header.put("Content-Type", "text/plain; charset=iso-8859-1");
    header.put("To", p.email);
    header.put("Subject", "JWIG password");
    header.put("From", root.email);
    header.put("Reply-To", root.email);
    header.put("Errors-To", root.email);
    String body = 
        "Your login for the JWIG meta-service is: "+p.login+"\n"+
        "and the password is: "+p.password+"\n\n"+
        "Go to "+getURL(Run.class)+" to log in.";
    boolean ok = sendMail(p.email, header, body, "iso-8859-1");

With the default installation configuration, the sendmail program with the options -n -i -t is used to send the email. This can be changed during installation of the JWIG system using the --with-sendmail and --with-sendmail-args configuration options.


<- SSL and HTTP Authentication Contents API - Overview of Classes, Methods, and Fields ->