done

Thanks,
Deepal
................................................................
~Future is Open~



----- Original Message ----- From: "Chamil Thanthrimudalige" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, August 10, 2005 2:25 PM
Subject: [Axis2]Patch to get the char encoding in the mail transport


hi,

Can some one with enough karma apply this patch.

It has changes to get character encoding working in the mail transport.

Best Regards,
Chamil Thanthrimudalige.



--------------------------------------------------------------------------------


Index: modules/core/src/org/apache/axis2/transport/mail/MailConstants.java
===================================================================
--- modules/core/src/org/apache/axis2/transport/mail/MailConstants.java (revision 231170) +++ modules/core/src/org/apache/axis2/transport/mail/MailConstants.java (working copy)
@@ -31,4 +31,7 @@
    public final static String SMTP_USER = "transport.mail.smtp.user";
public final static String SMTP_PASSWORD = "transport.mail.smtp.password";
    public final static String SMTP_PORT = "transport.mail.smtp.port";
+
+    public final static String DEFAULT_CHAR_SET = "us-ascii";
+    public final static String DEFAULT_CHAR_SET_ENCODING = "7bit";
}
\ No newline at end of file
Index: modules/core/src/org/apache/axis2/transport/mail/MailTransportSender.java
===================================================================
--- modules/core/src/org/apache/axis2/transport/mail/MailTransportSender.java (revision 231170) +++ modules/core/src/org/apache/axis2/transport/mail/MailTransportSender.java (working copy)
@@ -68,6 +68,7 @@
//TODO this is just a temporary hack, fix this to use input streams

                String eprAddress = msgContext.getTo().getAddress();
+ String charEncoding = (String)msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING);
                int index = eprAddress.indexOf('/');
                String subject = "";
                String email = null;
@@ -78,11 +79,10 @@
                    email = eprAddress;
                }

-
                sender.send(
                    subject,
                    email,
-                    new String(byteArrayOutputStream.toByteArray()));
+ new String(byteArrayOutputStream.toByteArray()), charEncoding);
            } else {
                if (user == null) {
                    throw new AxisFault(
Index: modules/core/src/org/apache/axis2/transport/mail/EMailSender.java
===================================================================
--- modules/core/src/org/apache/axis2/transport/mail/EMailSender.java (revision 231170) +++ modules/core/src/org/apache/axis2/transport/mail/EMailSender.java (working copy)
@@ -17,15 +17,22 @@
 */
package org.apache.axis2.transport.mail;

-import org.apache.axis2.AxisFault;
-import org.apache.axis2.transport.EmailReceiver;
+import java.util.Properties;

-import javax.mail.*;
+import javax.mail.Authenticator;
+import javax.mail.Flags;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
-import java.util.Properties;

+import org.apache.axis2.AxisFault;
+import org.apache.axis2.transport.EmailReceiver;
+
/**
 * @author hemapani
 *         <p/>
@@ -48,7 +55,7 @@
        this.password = password;
    }

- public void send(String subject, String targetEmail, String message) throws AxisFault { + public void send(String subject, String targetEmail, String message, String charSetEn) throws AxisFault {
        try {
            final PasswordAuthentication authentication =
                    new PasswordAuthentication(user, password);
@@ -70,10 +77,14 @@
                    new InternetAddress(targetEmail));
            msg.setSubject(subject);

- msg.addHeaderLine("Content-Type: text/plain; charset=us-ascii");
+            if (charSetEn.equals("")){
+                charSetEn = MailConstants.DEFAULT_CHAR_SET_ENCODING;
+            }

+ msg.addHeaderLine("Content-Type: text/plain; charset=" + MailConstants.DEFAULT_CHAR_SET);
+
            msg.setText(message);
-            msg.setHeader("Content-Transfer-Encoding", "7bit");
+            msg.setHeader("Content-Transfer-Encoding", charSetEn);
            Transport.send(msg);
        } catch (AddressException e) {
            throw new AxisFault(e);
@@ -92,7 +103,7 @@

        sender.send("Testing mail sending",
                "[EMAIL PROTECTED]",
-                "Hellp, testing");
+                "Hellp, testing", "us-ascii");

        EmailReceiver receiver = new EmailReceiver(user,
                host,
Index: modules/core/src/org/apache/axis2/transport/mail/MailWorker.java
===================================================================
--- modules/core/src/org/apache/axis2/transport/mail/MailWorker.java (revision 231170) +++ modules/core/src/org/apache/axis2/transport/mail/MailWorker.java (working copy)
@@ -85,6 +85,8 @@
msgContext = new MessageContext(reg, transportIn, transportOut);
                msgContext.setServerSide(true);
msgContext.setProperty(MailConstants.CONTENT_TYPE, mimeMessage.getContentType()); + msgContext.setProperty(MessageContext.CHARACTER_SET_ENCODING, mimeMessage.getEncoding());
+
String soapAction = getMailHeader(MailConstants.HEADER_SOAP_ACTION);
                msgContext.setWSAAction(soapAction);
                msgContext.setSoapAction(soapAction);



Reply via email to