You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2003/05/09 04:12:21 UTC
cvs commit: jakarta-james/src/java/org/apache/james/transport/mailets NotifySender.java
noel 2003/05/08 19:12:20
Modified: src/java/org/apache/james/transport/mailets Tag:
branch_2_1_fcs NotifySender.java
Log:
Fixed bug 18307. Also fixed problem bouncing complex MIME messages
Revision Changes Path
No revision
No revision
1.10.4.3 +34 -25 jakarta-james/src/java/org/apache/james/transport/mailets/NotifySender.java
Index: NotifySender.java
===================================================================
RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/transport/mailets/NotifySender.java,v
retrieving revision 1.10.4.2
retrieving revision 1.10.4.3
diff -u -r1.10.4.2 -r1.10.4.3
--- NotifySender.java 8 Mar 2003 21:54:08 -0000 1.10.4.2
+++ NotifySender.java 9 May 2003 02:12:20 -0000 1.10.4.3
@@ -86,15 +86,12 @@
* message. If you do not specify one, it will use the postmaster's address
*
* Sample configuration:
- * <mailet match="All" class="NotifySender">
- * <sendingAddress>nobounce@localhost</sendingAddress>
- * <attachStackTrace>true</attachStackTrace>
- * <notice>Notice attached to the message (optional)</notice>
- * </mailet>
+ * <mailet match="All" class="NotifySender">
+ * <sendingAddress>nobounce@localhost</sendingAddress>
+ * <attachStackTrace>true</attachStackTrace>
+ * <notice>Notice attached to the message (optional)</notice>
+ * </mailet>
*
- * @author Serge Knystautas <se...@lokitech.com>
- * @author Ivan Seskar <is...@upsideweb.com>
- * @author Danny Angus <da...@thought.co.uk>
*/
public class NotifySender extends GenericMailet {
@@ -156,7 +153,7 @@
//Create the list of recipients in the Address[] format
InternetAddress[] rcptAddr = new InternetAddress[1];
- rcptAddr[0] = getMailetContext().getPostmaster().toInternetAddress();
+ rcptAddr[0] = mail.getSender().toInternetAddress();
reply.setRecipients(Message.RecipientType.TO, rcptAddr);
//Set the sender...
@@ -206,20 +203,30 @@
out.println(" Number of lines: " + message.getLineCount());
}
-
try {
//Create the message body
- MimeMultipart multipart = new MimeMultipart();
- //Add message as the first mime body part
+ MimeMultipart multipart = new MimeMultipart("mixed");
+
+ // Create the message
+ MimeMultipart mpContent = new MimeMultipart("alternative");
+ MimeBodyPart contentPartRoot = new MimeBodyPart();
+ contentPartRoot.setContent(mpContent);
+
+ multipart.addBodyPart(contentPartRoot);
+
MimeBodyPart part = new MimeBodyPart();
- part.setContent(sout.toString(), "text/plain");
- part.setHeader(RFC2822Headers.CONTENT_TYPE, "text/plain");
- multipart.addBodyPart(part);
+ part.setText(sout.toString());
+ mpContent.addBodyPart(part);
//Add the original message as the second mime body part
part = new MimeBodyPart();
- part.setContent(message.getContent(), message.getContentType());
- part.setHeader(RFC2822Headers.CONTENT_TYPE, message.getContentType());
+ part.setContent(message, "message/rfc822");
+ if ((message.getSubject() != null) && (message.getSubject().trim().length() > 0)) {
+ part.setFileName(message.getSubject().trim());
+ } else {
+ part.setFileName("No Subject");
+ }
+ part.setDisposition(javax.mail.Part.ATTACHMENT);
multipart.addBodyPart(part);
//if set, attach the full stack trace
@@ -227,13 +234,14 @@
part = new MimeBodyPart();
part.setContent(mail.getErrorMessage(), "text/plain");
part.setHeader(RFC2822Headers.CONTENT_TYPE, "text/plain");
+ part.setFileName("Reasons");
+ part.setDisposition(javax.mail.Part.ATTACHMENT);
multipart.addBodyPart(part);
}
reply.setContent(multipart);
- reply.setHeader(RFC2822Headers.CONTENT_TYPE, multipart.getContentType());
- } catch (IOException ioe) {
- throw new MailetException("Unable to create multipart body");
+ } catch (Exception ioe) {
+ throw new MessagingException("Unable to create multipart body", ioe);
}
//Create the list of recipients in our MailAddress format
@@ -248,12 +256,13 @@
if (subject == null) {
subject = "";
}
- if (subject.indexOf("Re:") == 0){
- reply.setSubject(subject);
- } else {
- reply.setSubject("Re:" + subject);
+ reply.setSubject(subject);
+
+ if (message.getMessageID() != null) {
+ reply.setHeader(RFC2822Headers.IN_REPLY_TO, message.getMessageID());
}
- reply.setHeader(RFC2822Headers.IN_REPLY_TO, message.getMessageID());
+
+ reply.saveChanges();
//Send it off...
getMailetContext().sendMail(notifier, recipients, reply);
---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org