Skip to content

Instantly share code, notes, and snippets.

@rykov
Created May 8, 2009 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rykov/108966 to your computer and use it in GitHub Desktop.
Save rykov/108966 to your computer and use it in GitHub Desktop.
SMTPDKIMMessage patch for ActionMailer-JavaMail
--- SMTPDKIMMessage.bak 2009-05-07 01:03:52.000000000 -0700
+++ SMTPDKIMMessage.java 2009-05-07 01:53:45.000000000 -0700
@@ -54,6 +54,11 @@
this.signer = signer;
}
+ public SMTPDKIMMessage(Session session, InputStream is, DKIMSigner signer) throws MessagingException {
+ super(session, is);
+ this.signer = signer;
+ }
+
/**
* Output the message as an RFC 822 format stream, without
* specified headers. If the <code>saved</code> flag is not set,
@@ -74,7 +79,6 @@
*/
public void writeTo(OutputStream os, String[] ignoreList) throws IOException, MessagingException {
- ByteArrayOutputStream osHead = new ByteArrayOutputStream();
ByteArrayOutputStream osBody = new ByteArrayOutputStream();
// Inside saveChanges() it is assured that content encodings are set in all parts of the body
@@ -100,7 +104,7 @@
byte[] buf = new byte[8192];
int len;
while ((len = is.read(buf)) > 0)
- os.write(buf, 0, len);
+ osBody.write(buf, 0, len);
is.close();
buf = null;
} else {
@@ -119,7 +123,7 @@
// Third, write out the header to the header buffer
Enumeration hdrLines = getNonMatchingHeaderLines(ignoreList);
- LineOutputStream los = new LineOutputStream(osHead);
+ LineOutputStream los = new LineOutputStream(os);
while (hdrLines.hasMoreElements())
los.writeln((String) hdrLines.nextElement());
@@ -127,7 +131,6 @@
los.writeln();
// send signed mail to waiting DATA command
- os.write(osHead.toByteArray());
os.write(osBody.toByteArray());
os.flush();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment