cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gabriel Gruber (JIRA)" <j...@apache.org>
Subject [jira] Commented: (COCOON-1438) [MAIL] Weird Encoding problem with SendMailAction
Date Sat, 14 Oct 2006 14:10:36 GMT
    [ http://issues.apache.org/jira/browse/COCOON-1438?page=comments#action_12442295 ] 
            
Gabriel Gruber commented on COCOON-1438:
----------------------------------------

1) Why is it not feasable to change the container-encoding inside the web.xml?   

I thought to correctly handle character-encoding with UTF8 throughout my cocoon web-application
I did modifications inside these files:

a) web.xml

    <init-param>
      <param-name>form-encoding</param-name>
      <param-value>utf-8</param-value>
    </init-param>

However now I realised, that this setting is intented to be used, if the surruounding servlet
container has a encoding other than iso set. At my use-case with tomcat that is actually *NOT*
the case, as the setting for UTF-8 has to be done explicitly... this maybe explains my problem...

2) model.KollegeEmailBodyText
This is the String containing the BodyText for the Email being submitted via cforms.
This is the full flowcode:

function sendacol() {

	// Flowscript um Kollegen einen Link auf ARL zu schicken

    var myarl = cocoon.request.get("uid");

    var form = new Form("forms/sendacol_form.xml");
    form.showForm("forms/sendacol");
    
    var model = form.getModel();

    
    // Send Mail through Mailsender Component

	// kurios: body muss mit ISO Charset codiert werden ansonsten ist 
	// das endg�ltige HTML-Mail falsch...
	// eigentlich unlogisch, da sonst alles UTF-8....
	
	var cocoonurl = "cocoon:/mailtext/arllink/" + myarl + "?body=" 
	if (model.KollegeEmailBodytext!=null) {
	 	cocoonurl += java.net.URLEncoder.encode(model.KollegeEmailBodytext,"ISO-8859-1");
	}

	
	var mailsender = cocoon.getComponent(Packages.org.apache.cocoon.mail.MailSender.ROLE);

	// Logging
	if (cocoon.log.isDebugEnabled) {
		cocoon.log.debug("cocoon-url f�r mailtext = " + cocoonurl);
		cocoon.log.debug("eohb_smtp_host = " + cocoon.parameters["eohb_smtp_host"]);
		cocoon.log.debug("eohb_smtp_user = " + cocoon.parameters["eohb_smtp_user"]);
		cocoon.log.debug("eohb_smtp_password = " + cocoon.parameters["eohb_smtp_password"]);
	}
	if ((cocoon.parameters["eohb_smtp_user"] == null) || (cocoon.parameters["eohb_smtp_user"]
== "anonymous" )) {
		// SMTP anmeldung ohne User (anonymous)
	    mailsender.setSmtpHost(cocoon.parameters["eohb_smtp_host"]);	
	} else {
		// SMTP Anmeldung mit User
	    mailsender.setSmtpHost(cocoon.parameters["eohb_smtp_host"],cocoon.parameters["eohb_smtp_user"],cocoon.parameters["eohb_smtp_pwd"]);

	}

    mailsender.setTo(model.KollegeEmail);
    mailsender.setFrom(cocoon.parameters["eohb_smtp_from"]);
    mailsender.setBodyFromSrc(cocoonurl);
    mailsender.setSubject("eOHB Link");
    mailsender.setCharset("UTF-8");
    mailsender.setBodyFromSrcMimeType("text/html; charset=utf-8");
    
    try {
    	mailsender.send();
    } catch (e) {
    	cocoon.log.error("Problem mit Mailversand",e);
    	cocoon.sendPage("page_sendmail_failure");
    	return;
    }
    
    if (cocoon.log.isDebugEnabled && model.KollegeEmailBodytext!=null)
    	cocoon.log.debug("Body-Mailtext: " + java.net.URLDecoder.decode(model.KollegeEmailBodytext,"UTF-8"));
    
    cocoon.sendPage("page_sendmail_success");
}

> [MAIL] Weird Encoding problem with SendMailAction
> -------------------------------------------------
>
>                 Key: COCOON-1438
>                 URL: http://issues.apache.org/jira/browse/COCOON-1438
>             Project: Cocoon
>          Issue Type: Bug
>          Components: Blocks: Mail
>    Affects Versions: 2.1.6
>         Environment: Operating System: Windows XP
> Platform: PC
>            Reporter: Gabriel Gruber
>         Assigned To: Cocoon Developers Team
>
> I have a flowscript, wich uses the sendmailaction to send a mail.
> As the mail is supposed to be a html-mail, it is generated through a cocoon-
> pipeline and feeded by a request-param which contains the body-text.
> this body-text is first submitted by a cform.
> the cform correctly delivers the bodytext (after changing all the encoding 
> settings in the web.xml and serializer configs to "UTF-8") with 
> specialcharacters correctly.
> However the mail which is generated doesn't encode the bodytext correctly. the 
> weird thing is that when I submit the same URL I gave to the SendMailaction via 
> a browser, the character-encoding is correct.
> when looking at the following sourcecode, then Bodytext should logically be 
> encoded with UTF-8 (as everything else is done with UTF-8). However in order to 
> work, I had to switch to ISO-8859-1 for this single line. Otherwise the 
> generated html-mail had strange special characters..
> var cocoonurl = "cocoon:/mailtext/arllink/" + myarl + "?body=" + 
> java.net.URLEncoder.encode(model.KollegeEmailBodytext,"ISO-8859-1");
> 	
> var mailsender = cocoon.getComponent
> (Packages.org.apache.cocoon.mail.MailSender.ROLE);
> mailsender.setSmtpHost(cocoon.parameters["eohb_smtp_host"],cocoon.parameters
> ["eohb_smtp_user"],cocoon.parameters["eohb_smtp_pwd"]);
> mailsender.setTo(model.KollegeEmail);
> mailsender.setFrom(cocoon.parameters["eohb_smtp_from"]);
> mailsender.setBodyFromSrc(cocoonurl);
> mailsender.setSubject("eOHB Link");
> mailsender.setCharset("UTF-8");
> mailsender.setBodyFromSrcMimeType("text/html; charset=utf-8");
> mailsender.sendIt();

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

Mime
View raw message