You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Nils Köster <ni...@lolili.de> on 2004/05/04 13:07:18 UTC

Sendmail Action HTML-Mail & Attachment

Since it's important for me and nobody answered yet, i repost my question:


Hi there,

I'm trying to send mail via the sendmail action with html-body and
pdf-attachment, my sitemap looks like this:

  <map:act type="sendmail">
    <map:parameter name="smtphost" value="some.smtp.de"/>
    <map:parameter name="from" value="somebody@somewhere.de"/>
    <map:parameter name="to" value="somebody@somewhere.de"/>
    <map:parameter name="subject" value="{request-param:subject}"/>
    <!--map:parameter name="body" value="{request-param:message}"/-->
    <map:parameter name="src" value="context://mailer/test.html"/>
    <map:parameter name="srcMimeType" value="text/html"/>
    <map:parameter name="cc" value=""/>
    <map:parameter name="bcc" value="somebody@somewhere.de"/>
    <map:parameter name="attachments" value="{request-param:attachment}"/>
    <map:parameter name="charset" value="ISO-8859-1"/>
  </map:act>

In request-param:attachment i have something like:
context:/nkpm/resources/documents/some.pdf

But it doesn't send the mail when I have both in it: attachment and
html-src. With one of them it works.

Does anybody have a clue?

Regards,
Nils





In the error.log I get:
-----------------------------------------------
ERROR   (2004-05-02) 22:25.32:156   [sitemap.action.sendmail] (/mailer/mail)
http8080-Processor25/Sendmail: SendmailAction: An exception was thrown while
sending email. java.lang.NullPointerException
	at
org.apache.cocoon.mail.MailMessageSender.send(MailMessageSender.java:323)
	at org.apache.cocoon.acting.Sendmail.act(Sendmail.java:253)
	at
org.apache.cocoon.components.treeprocessor.sitemap.ActTypeNode.invoke(ActTyp
eNode.java:154)
	at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invo
keNodes(AbstractParentProcessingNode.java:84)
	at
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invok
e(PreparableMatchNode.java:165)
	at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invo
keNodes(AbstractParentProcessingNode.java:107)
	at
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(Pipel
ineNode.java:162)
	at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invo
keNodes(AbstractParentProcessingNode.java:107)
	at
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(Pipe
linesNode.java:136)
	at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcess
or.java:371)
	at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcess
or.java:312)
	at
org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke(MountNod
e.java:133)
	at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invo
keNodes(AbstractParentProcessingNode.java:84)
	at
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invok
e(PreparableMatchNode.java:165)
	at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invo
keNodes(AbstractParentProcessingNode.java:107)
	at
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(Pipel
ineNode.java:162)
	at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invo
keNodes(AbstractParentProcessingNode.java:107)
	at
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(Pipe
linesNode.java:136)
	at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcess
or.java:371)
	at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcess
or.java:312)
	at org.apache.cocoon.Cocoon.process(Cocoon.java:656)
	at
org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:1112)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:284)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:204)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:257)
	at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:151)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
	at
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContext
Valve.java:245)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:199)
	at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:151)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:184
)
	at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:151)
	at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164
)
	at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:149)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:156)
	at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:151)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
	at
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
	at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:833)
	at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:732)
	at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:619)
	at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:688)
	at java.lang.Thread.run(Thread.java:534)


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: AW: Sendmail Action HTML-Mail & Attachment

Posted by Christian Haul <ha...@informatik.tu-darmstadt.de>.
Nils wrote:
> Hi Christian,
> 
> Thanks for your answer.
> 
> The lack of the Body-part wasn't the real problem. The problem ist, that it
> throws an exception as soon as i have an attachment and a html-mail. As far
> as I know the body-part is only used, when theres no src etc.

Nils,

I believe to have found the problem - a not initialized variable that
mattered only in your case. Funny it hasn't surfaced earlier.

Anyway, I've just comitted a fix to the repository. Please cross check
and report back.

Thanks for spotting this one!

	Chris.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


AW: Sendmail Action HTML-Mail & Attachment

Posted by Nils <co...@lolili.de>.
Hi Christian,

Thanks for your answer.

The lack of the Body-part wasn't the real problem. The problem ist, that it
throws an exception as soon as i have an attachment and a html-mail. As far
as I know the body-part is only used, when theres no src etc.

Regards,
Nils

> -----Ursprüngliche Nachricht-----
> Von: Christian Haul [mailto:haul@informatik.tu-darmstadt.de] 
> Gesendet: Freitag, 7. Mai 2004 09:11
> An: users@cocoon.apache.org
> Betreff: Re: Sendmail Action HTML-Mail & Attachment
> 
> 
> Joerg Heinicke wrote:
> > 
> > 
> > On 04.05.2004 13:07, Nils Köster wrote:
> > 
> >> I'm trying to send mail via the sendmail action with html-body and 
> >> pdf-attachment, my sitemap looks like this:
> >>
> >>   <map:act type="sendmail">
> >>     <map:parameter name="smtphost" value="some.smtp.de"/>
> >>     <map:parameter name="from" value="somebody@somewhere.de"/>
> >>     <map:parameter name="to" value="somebody@somewhere.de"/>
> >>     <map:parameter name="subject" value="{request-param:subject}"/>
> >>     <!--map:parameter name="body" 
> value="{request-param:message}"/-->
> >>     <map:parameter name="src" value="context://mailer/test.html"/>
> >>     <map:parameter name="srcMimeType" value="text/html"/>
> >>     <map:parameter name="cc" value=""/>
> >>     <map:parameter name="bcc" value="somebody@somewhere.de"/>
> >>     <map:parameter name="attachments"
> >> value="{request-param:attachment}"/>
> >>     <map:parameter name="charset" value="ISO-8859-1"/>
> >>   </map:act>
> >>
> >> In request-param:attachment i have something like: 
> >> context:/nkpm/resources/documents/some.pdf
> >>
> >> But it doesn't send the mail when I have both in it: 
> attachment and 
> >> html-src. With one of them it works.
> >>
> >> Does anybody have a clue?
> > 
> > 
> >> In the error.log I get:
> >> -----------------------------------------------
> >> ERROR   (2004-05-02) 22:25.32:156   [sitemap.action.sendmail] 
> >> (/mailer/mail)
> >> http8080-Processor25/Sendmail: SendmailAction: An exception was 
> >> thrown
> >> while
> >> sending email. java.lang.NullPointerException
> >>     at
> >> 
> org.apache.cocoon.mail.MailMessageSender.send(MailMessageSende
> r.java:323)
> >>     at org.apache.cocoon.acting.Sendmail.act(Sendmail.java:253)
> > 
> > 
> >  From the code the NPE is obvious:
> > 
> > 306    BodyPart bodypart = null;
> > 307
> > 308    if (this.src != null) {
> > 309        DataSource ds = null;
> > 310
> > 311        Source source = resolver.resolveURI(this.src);
> > 312        sourcesList.add(source);
> > 313        if (source.exists()) {
> > 314            ds =
> > 315                new SourceDataSource(
> > 316                    source,
> > 317                    (this.srcMimeType == null
> > 318                        ? source.getMimeType()
> > 319                        : this.srcMimeType),
> > 320                    
> this.src.substring(this.src.lastIndexOf('/') + 1));
> > 321        }
> > 322
> > 323        bodypart.setDataHandler(new DataHandler(ds));
> > 324        bodypart.setFileName(ds.getName());
> > 325
> > 326        multipart.addBodyPart(bodypart);
> > 
> > bodypart was never set/is still null in line 323.
> > 
> > Unfortunately I don't know how to fix it and I don't have 
> the time to
> > dive in at the moment. Christian wrote the code and could 
> probably fix 
> > it in the shortest time as he knows what should happen. 
> Unfortunately he 
> > made himself very rare on the lists in the last weeks, so I 
> guess he has 
> > not much time ATM neither.
> 
> Hi Nils, Joerg,
> 
> sorry that I can't look into this ATM but I believe the 
> original idea was that every mail should contain a plain text 
> body, not just attachments. However, we could for example 
> provide a default text like "please see attachment" or the 
> like but I feel like it would make more sense to do this 
> application specific.
> 
> So, the simplest solution for Nils would be to add such a 
> body text and add the pdf as attachment.
> 
> I need to dig up the specs to see if it is allowed to have no 
> bodypart. Will try to look into this over the weekend.
> 
> Cheers,
> 	Chris.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Sendmail Action HTML-Mail & Attachment

Posted by Christian Haul <ha...@informatik.tu-darmstadt.de>.
Joerg Heinicke wrote:
> 
> 
> On 04.05.2004 13:07, Nils Köster wrote:
> 
>> I'm trying to send mail via the sendmail action with html-body and
>> pdf-attachment, my sitemap looks like this:
>>
>>   <map:act type="sendmail">
>>     <map:parameter name="smtphost" value="some.smtp.de"/>
>>     <map:parameter name="from" value="somebody@somewhere.de"/>
>>     <map:parameter name="to" value="somebody@somewhere.de"/>
>>     <map:parameter name="subject" value="{request-param:subject}"/>
>>     <!--map:parameter name="body" value="{request-param:message}"/-->
>>     <map:parameter name="src" value="context://mailer/test.html"/>
>>     <map:parameter name="srcMimeType" value="text/html"/>
>>     <map:parameter name="cc" value=""/>
>>     <map:parameter name="bcc" value="somebody@somewhere.de"/>
>>     <map:parameter name="attachments" 
>> value="{request-param:attachment}"/>
>>     <map:parameter name="charset" value="ISO-8859-1"/>
>>   </map:act>
>>
>> In request-param:attachment i have something like:
>> context:/nkpm/resources/documents/some.pdf
>>
>> But it doesn't send the mail when I have both in it: attachment and
>> html-src. With one of them it works.
>>
>> Does anybody have a clue?
> 
> 
>> In the error.log I get:
>> -----------------------------------------------
>> ERROR   (2004-05-02) 22:25.32:156   [sitemap.action.sendmail] 
>> (/mailer/mail)
>> http8080-Processor25/Sendmail: SendmailAction: An exception was thrown 
>> while
>> sending email. java.lang.NullPointerException
>>     at
>> org.apache.cocoon.mail.MailMessageSender.send(MailMessageSender.java:323)
>>     at org.apache.cocoon.acting.Sendmail.act(Sendmail.java:253)
> 
> 
>  From the code the NPE is obvious:
> 
> 306    BodyPart bodypart = null;
> 307
> 308    if (this.src != null) {
> 309        DataSource ds = null;
> 310
> 311        Source source = resolver.resolveURI(this.src);
> 312        sourcesList.add(source);
> 313        if (source.exists()) {
> 314            ds =
> 315                new SourceDataSource(
> 316                    source,
> 317                    (this.srcMimeType == null
> 318                        ? source.getMimeType()
> 319                        : this.srcMimeType),
> 320                    this.src.substring(this.src.lastIndexOf('/') + 1));
> 321        }
> 322
> 323        bodypart.setDataHandler(new DataHandler(ds));
> 324        bodypart.setFileName(ds.getName());
> 325
> 326        multipart.addBodyPart(bodypart);
> 
> bodypart was never set/is still null in line 323.
> 
> Unfortunately I don't know how to fix it and I don't have the time to 
> dive in at the moment. Christian wrote the code and could probably fix 
> it in the shortest time as he knows what should happen. Unfortunately he 
> made himself very rare on the lists in the last weeks, so I guess he has 
> not much time ATM neither.

Hi Nils, Joerg,

sorry that I can't look into this ATM but I believe the original idea was
that every mail should contain a plain text body, not just attachments.
However, we could for example provide a default text like "please see attachment"
or the like but I feel like it would make more sense to do this application
specific.

So, the simplest solution for Nils would be to add such a body text and add the
pdf as attachment.

I need to dig up the specs to see if it is allowed to have no bodypart. Will try
to look into this over the weekend.

Cheers,
	Chris.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Sendmail Action HTML-Mail & Attachment

Posted by Joerg Heinicke <jo...@gmx.de>.

On 04.05.2004 13:07, Nils Köster wrote:

> I'm trying to send mail via the sendmail action with html-body and
> pdf-attachment, my sitemap looks like this:
> 
>   <map:act type="sendmail">
>     <map:parameter name="smtphost" value="some.smtp.de"/>
>     <map:parameter name="from" value="somebody@somewhere.de"/>
>     <map:parameter name="to" value="somebody@somewhere.de"/>
>     <map:parameter name="subject" value="{request-param:subject}"/>
>     <!--map:parameter name="body" value="{request-param:message}"/-->
>     <map:parameter name="src" value="context://mailer/test.html"/>
>     <map:parameter name="srcMimeType" value="text/html"/>
>     <map:parameter name="cc" value=""/>
>     <map:parameter name="bcc" value="somebody@somewhere.de"/>
>     <map:parameter name="attachments" value="{request-param:attachment}"/>
>     <map:parameter name="charset" value="ISO-8859-1"/>
>   </map:act>
> 
> In request-param:attachment i have something like:
> context:/nkpm/resources/documents/some.pdf
> 
> But it doesn't send the mail when I have both in it: attachment and
> html-src. With one of them it works.
> 
> Does anybody have a clue?

> In the error.log I get:
> -----------------------------------------------
> ERROR   (2004-05-02) 22:25.32:156   [sitemap.action.sendmail] (/mailer/mail)
> http8080-Processor25/Sendmail: SendmailAction: An exception was thrown while
> sending email. java.lang.NullPointerException
> 	at
> org.apache.cocoon.mail.MailMessageSender.send(MailMessageSender.java:323)
> 	at org.apache.cocoon.acting.Sendmail.act(Sendmail.java:253)

 From the code the NPE is obvious:

306    BodyPart bodypart = null;
307
308    if (this.src != null) {
309        DataSource ds = null;
310
311        Source source = resolver.resolveURI(this.src);
312        sourcesList.add(source);
313        if (source.exists()) {
314            ds =
315                new SourceDataSource(
316                    source,
317                    (this.srcMimeType == null
318                        ? source.getMimeType()
319                        : this.srcMimeType),
320                    this.src.substring(this.src.lastIndexOf('/') + 1));
321        }
322
323        bodypart.setDataHandler(new DataHandler(ds));
324        bodypart.setFileName(ds.getName());
325
326        multipart.addBodyPart(bodypart);

bodypart was never set/is still null in line 323.

Unfortunately I don't know how to fix it and I don't have the time to 
dive in at the moment. Christian wrote the code and could probably fix 
it in the shortest time as he knows what should happen. Unfortunately he 
made himself very rare on the lists in the last weeks, so I guess he has 
not much time ATM neither.

Joerg

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org