[Mrpostman-developers] problem when sending html messages
Brought to you by:
chris_humphreys,
mrbook
|
From: a g <ann...@ya...> - 2006-11-24 13:55:06
|
Hello,
I would like to allow html outgoing messages from outlook using
mrpostman
and squirrelmail. I have discovered in java code that sending mails in
html
format was not possible :
In GenericMailSession.java I had to transform the code of "sendMessage"
method to allow html outgoing messages as follows:
// this "if" was after the second "if" (with plain text)
if (parts.get("text/html") != null)
{
msg.put("mimetype", "text/html");
msg.put("text", (String) parts.get("text/html"));
}
//this "if" was before the first "if" (with html)
else if (parts.get("text/plain") != null)
{
msg.put("mimetype", "text/plain");
msg.put("text", (String) parts.get("text/plain"));
}
else
{
msg.put("mimetype", "text/plain");
msg.put("text", "");
}
Explanation :
When looking at GenericMailSession code :
public boolean sendMessage(List recipients, BufferedReader in, String
charset) {
MessageParser mparser = null;
try {
mparser = new MessageParser(recipients, in, charset);
.../...
Map parts = mparser.getParts();
When printing
parts.get("text/html")
and
parts.get("text/plain")
I have seen that both were not null when sending an html mail
(text/html is
null when sending a text/plain message), so that in the case of an html
mail
only the text/plain part of the message was sent (because of the "if"
conditions order).
Then when inverting the code I have been able to send html messages but
the
source html code of the message was transformed at the end :
& becomes &
< becomes <
> becomes ⊃
" becomes "
so that the received message looks like html code but not like a html
page
Example :
The body of the written message is as follows before sending it (in
html
code) :
This is just a mail with a link <a href="http://www.google.fr/ ">to
google</a>
which appears like that :
This is just a mail with a link to google
When receiving the message the body of the message is as
follows (when looking at the source code you will see the problem)
:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE></TITLE> <META http-equiv=Content-Type content="text/html; ? charset=iso-8859-1"> <META content="MSHTML 6.00.2900.2627" name=GENERATOR></HEAD> <BODY>This is just a mail with a link <A ? href="http://www.google.fr/" target="_blank">http://www.google.fr/">to google</A></BODY></HTML>
so that the mail is unreadable.
Do you know when and where the transformation happens, I can't find it
in
the code.
HTMLEncoder.java deals with these transcoding but doesn't seem to be
used
when sending a message.
Many thanks for answering,
Anne
Apologizes if the mail is not clear, the html code may not appear as I wrote it
---------------------------------
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses. |