You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Michael Osipov (JIRA)" <ji...@apache.org> on 2015/09/19 14:08:04 UTC

[jira] [Commented] (EMAIL-157) Sending an email from a Java TimerTask object doesn't work

    [ https://issues.apache.org/jira/browse/EMAIL-157?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14877076#comment-14877076 ] 

Michael Osipov commented on EMAIL-157:
--------------------------------------

You should inquire with the users mailing list. This is not a support forum unless this issue turns out to be a bug.

> Sending an email from a Java TimerTask object doesn't work
> ----------------------------------------------------------
>
>                 Key: EMAIL-157
>                 URL: https://issues.apache.org/jira/browse/EMAIL-157
>             Project: Commons Email
>          Issue Type: Bug
>    Affects Versions: 1.4
>         Environment: OS: Windows 8.1 Pro / IDE: Eclipse Juno / Servlets container: Tomcat 8
>            Reporter: LEA MASSIOT
>
> Hello,
> I'm using "Apache Commons Email 1.4".
> Consider the following simple code:
> {code}
> import org.apache.commons.mail.Email;
> import org.apache.commons.mail.EmailException;
> import org.apache.commons.mail.SimpleEmail;
> [...]
>     Email email = new SimpleEmail();
>     email.setHostName("smtp.foo.bar");
>     try
>     {
>         email.setFrom("foo2@bar2.fr");
>         email.setSubject("TestMail");
>         email.setMsg("This is a test mail ... :-)");
>         email.addTo("foo3@bar3.fr");
>         email.send();
>     }
>     catch(EmailException e)
>     {
>         // TODO Auto-generated catch block
>         e.printStackTrace();
>     }
> {code}
> The code above is put:
> - CASE 1: in the *doPost()* method of a *HttpServlet* object: it works (I receive the email).
> - CASE 2: at runtime (there are no build errors), in the *run()* method of a *TimerTask* object:  
>   If I put a breakpoint on the line *Email email = new SimpleEmail();*
>   hit F6 in Eclipse to execute the instruction,
>   I get the message: Source not found.
> What am I doing wrong? What is going wrong? How can I make it work?
> Best regards.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)