Allow extra headers to be provided.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@1597 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2005-02-24 19:53:20 +00:00
parent 35ea2896d9
commit 1f500e7272
@@ -80,6 +80,17 @@ public class MailUtil
public static void deliverMail (String[] recipients, String sender,
String subject, String body)
throws IOException
{
deliverMail(recipients, sender, subject, body, null, null);
}
/**
* Delivers the supplied mail, with the specified additional headers.
*/
public static void deliverMail (String[] recipients, String sender,
String subject, String body,
String[] headers, String[] values)
throws IOException
{
if (recipients == null || recipients.length < 1) {
throw new IOException("Must specify one or more recipients.");
@@ -97,6 +108,10 @@ public class MailUtil
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(recipients[ii]));
}
int hcount = (headers == null) ? 0 : headers.length;
for (int ii = 0; ii < headers.length; ii++) {
message.addHeader(headers[ii], values[ii]);
}
message.setSubject(subject);
message.setText(body);
Transport.send(message);