Javamail Transport.send problem

I send an email once in a while from my web application on a virtual dedicated server. Usually the email works. But sometimes Transport.send hangs up. Processing just stops at that statement. I don’t get anything from debug.
public class SendEmail {
    public void SendEmail(String toEmailAddress,
            String fromEmailAddress,
            String smtphost, String subject, String content)
            throws AddressException, MessagingException {
        // Create a mail session
        java.util.Properties props = new java.util.Properties();
        props.put("mail.smtp.host", smtphost);
        props.put("mail.debug", "true");
        Session session = Session.getInstance(props, null);
        // Construct the message
        Message msg = new MimeMessage(session);
        msg.setFrom(new InternetAddress(fromEmailAddress;));
        msg.setRecipient(Message.RecipientType.TO, new InternetAddress(toEmailAddress));
        msg.setSubject(subject);
        msg.setText(content);
        // Send the message
        Transport.send(msg);
        return;
}What could be causing the problem with Transport.send? Any help would be very much appreciated. Thanks.

I didn’t get anything from debug. No messages at all. I'm on Centos and looked at the console. Is this not correct?
I added this code to try to capture exceptions:
try {
            Transport.send(msg);
        } catch (Exception e) {
            try {
                out = new BufferedWriter(new FileWriter("TestLog.txt", true));
                out.newLine();
                out.write(e.getMessage());
                out.newLine();
                out.close(); 
            } catch (Exception err) {
            } finally {
        } finally {
            }But I haven't been able to duplicate the problem since then. I'm not familiar with jstack, so I'll have to research it.
Thanks for your response.

Similar Messages

  • JavaMail application hanged with no error throwed at Transport.send

    JavaMail application hanged with no error throwed at Transport.send,even though I set the timeout property
    import java.util.Date;
    import java.util.Properties;
    import javax.mail.Authenticator;
    import javax.mail.Message;
    import javax.mail.PasswordAuthentication;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeBodyPart;
    import javax.mail.internet.MimeMessage;
    import javax.mail.internet.MimeMultipart;
    import javax.mail.internet.MimeUtility;
    public class tt {
         static Properties props=null;
         static boolean needAuth=true;
         static MailAuthenticator authenticator = null;
         static String host="host";
         static String account="account";
         static String password="pwd";
         static String sender="sender";
          * @param args
          * @throws Exception
         public static void main(String[] args) throws Exception{
               if (props == null) {
                     props = new Properties();
                     props.put("mail.smtp.host", host);
                     props.put("mail.smtp.timeout      ", "1000");
                     props.put("mail.smtp.connectiontimeout      ", "1000");
    //                 props.put("mail.debug", "true");
                     props.put("mail.smtp.auth", String.valueOf(needAuth));
                     authenticator = new MailAuthenticator(account, password);
                 MailData mailData = new MailData();
                 mailData.setSubject("altireport mail configuration");
                 mailData.setContent("mail server has been configured successfully.");
                 mailData.setRecipients(new String[]{"[email protected]"});
                 final Session session = Session.getInstance(props, authenticator);
                 final MimeMessage msg = new MimeMessage(session);
                 InternetAddress from = new InternetAddress(sender);
                 msg.setFrom(from);
                 //        msg.setSender(from);
                final InternetAddress[] addressTo = new InternetAddress[mailData.getRecipients().length];
                 for (int i = 0; i < mailData.getRecipients().length; i++) {
                     addressTo[i] = new InternetAddress(mailData.getRecipients());
         msg.addRecipients(Message.RecipientType.TO, addressTo);
         //msg.setSubject(mailData.getSubject());
         msg.setSubject(MimeUtility.encodeText(mailData.getSubject(), "UTF-8", "B"));
         MimeBodyPart bodyPart1 = new MimeBodyPart();
         bodyPart1.setContent(mailData.getContent(), "text/plain; charset=UTF-8");
         MimeMultipart multipart = new MimeMultipart();
         multipart.addBodyPart(bodyPart1);
         msg.setContent(multipart);
         msg.setSentDate(new Date());
    //     msg.saveChanges();
         for(int i=0;i<10;i++){
              new Thread(new Runnable(){
                             public void run() {
                             try {
                                  System.out.println("send...");                                   
                                  Transport.send(msg);
                                  } catch (Exception e) {
                                       e.printStackTrace(System.out);
                        System.out.println("end!");
              }).start();
    class MailData {
    private String[] recipients = null;
    private String subject = null;
    private String content = null;
    private String attachment = null;
    private String attachmentName = null;
    * @return the attachment
    public String getAttachment() {
    return attachment;
    * @param attachment the attachment to set
    public void setAttachment(String attachment) {
    this.attachment = attachment;
    * @return the content
    public String getContent() {
    return content;
    * @param content the content to set
    public void setContent(String content) {
    this.content = content;
    * @return the recipients
    public String[] getRecipients() {
    return recipients;
    * @param recipients the recipients to set
    public void setRecipients(String[] recipients) {
    this.recipients = recipients;
    * @return the subject
    public String getSubject() {
    return subject;
    * @param subject the subject to set
    public void setSubject(String subject) {
    this.subject = subject;
    * @return the attachmentName
    public String getAttachmentName()
    return attachmentName;
    * @param attachmentName the attachmentName to set
    public void setAttachmentName(String attachmentName)
    this.attachmentName = attachmentName;
    class MailAuthenticator extends Authenticator {
    private PasswordAuthentication authentication;
    public MailAuthenticator(String account, String password) {
    authentication = new PasswordAuthentication(account, password);
    protected PasswordAuthentication getPasswordAuthentication() {
    return authentication;
    I have tried use session to get a SMTPTransport instance to use sendMessage ,but still have the same problem.No exception ,No error.
    This problem doesn't appear always. It appears sometimes.
    I hope get help for someone who has the solution for this problem.
    Thanks in advanced.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Ok, I think I see the problem:
         props.put("mail.smtp.timeout      ", "1000");
         props.put("mail.smtp.connectiontimeout      ", "1000");
    Why do you have spaces at the end of the property names?
    Those spaces are not being ignored, which means you've
    set the wrong properties.

  • Problem in sending mail for a pop3 account using transport.send(msg)

    hi,
    i am having problem in not able to send mail for a pop3 account ...
    I have written an email gateway which listens to my pop3 account...on email arrival it listens nd extract the contents and send it as an sms msg...upon failure it needs to deliver the mail to sender id.I am using quartz to listen.
    i am using jboss for server and java mail api.
    here is my code
    MimeMessage mimemsg = new MimeMessage(session);
                                                           mimemsg.setFrom();
                                                           mimemsg.setRecipients(Message.RecipientType.TO, to);
                                                           mimemsg.setSubject(subject);
                                                           mimemsg.setText(parsedText);
                                                           mimemsg.setSentDate(new Date());
                                                           mimemsg.setContent(strBuff.toString(), "text/html");
                                                           System.out
                                                                                    .println("Before sending mail");
                                                           Transport.send(m);
                                                                System.out.println("message sent successfully");
    excepition i am getting is :
    2008-09-12 11:45:11,140 INFO [STDOUT] Before sending mail
    2008-09-12 11:45:11,140 ERROR [STDERR] javax.mail.IllegalWriteException: POP3 messages are read-only
    2008-09-12 11:45:11,140 ERROR [STDERR]      at com.sun.mail.pop3.POP3Message.saveChanges(POP3Message.java:438)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at javax.mail.Transport.send(Transport.java:97)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at com.openstream.emailgateway.sources.ListenEmailGateway.execute(ListenEmailGateway.java:422)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at java.lang.reflect.Method.invoke(Method.java:585)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at org.jboss.invocation.Invocation.performCall(Invocation.java:359)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:495)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:116)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:109)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:402)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at org.jboss.ejb.Container.invoke(Container.java:960)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at sun.reflect.GeneratedMethodAccessor88.invoke(Unknown Source)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at java.lang.reflect.Method.invoke(Method.java:585)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    2008-09-12 11:45:11,140 ERROR [STDERR]      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    2008-09-12 11:45:11,171 ERROR [STDERR]      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    2008-09-12 11:45:11,171 ERROR [STDERR]      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    2008-09-12 11:45:11,171 ERROR [STDERR]      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    2008-09-12 11:45:11,171 ERROR [STDERR]      at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:169)
    2008-09-12 11:45:11,171 ERROR [STDERR]      at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:118)
    2008-09-12 11:45:11,171 ERROR [STDERR]      at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:209)
    2008-09-12 11:45:11,171 ERROR [STDERR]      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:195)
    2008-09-12 11:45:11,171 ERROR [STDERR]      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61)
    2008-09-12 11:45:11,171 ERROR [STDERR]      at org.jboss.ejb.plugins.inflow.MessageEndpointInterceptor.delivery(MessageEndpointInterceptor.java:263)
    2008-09-12 11:45:11,171 ERROR [STDERR]      at org.jboss.ejb.plugins.inflow.MessageEndpointInterceptor.invoke(MessageEndpointInterceptor.java:140)
    2008-09-12 11:45:11,171 ERROR [STDERR]      at org.jboss.proxy.ClientMethodInterceptor.invoke(ClientMethodInterceptor.java:74)
    2008-09-12 11:45:11,171 ERROR [STDERR]      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
    2008-09-12 11:45:11,171 ERROR [STDERR]      at $Proxy73.execute(Unknown Source)
    2008-09-12 11:45:11,171 ERROR [STDERR]      at org.jboss.resource.adapter.quartz.inflow.QuartzJob.execute(QuartzJob.java:57)
    2008-09-12 11:45:11,171 ERROR [STDERR]      at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
    2008-09-12 11:45:11,171 ERROR [STDERR]      at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
    2008-09-12 11:45:11,171 INFO [STDOUT] USer flag ..[Ljava.lang.String;@115c6cb                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    as i am writing the message failure details to a template...
         //on failure to send messages , reply to the sender about the failure
                                                                strBuff= tempDetail.writeToTemplate(smsmsg);     
    is that bcoz i am getting an exception

  • URGENT::Status returned by Transport.send() and problem with mail.smtp.host

    Hello,
    I am writing a code to send an email using JavaMail. I have added mail.jar and activation.jar in the classpath. Also I would like to mention that I am using Weblogic6.1 SP4.
    A bunch of questions:
    1. After calling Transport.send(), how do i know if the mail was sent successfully or not ?? Is there anyway I can handle that?
    2. I am using props.put(mail.smtp.host, <some-value>). What should be this <some-value> ?? Where can I get this value from??
    And is this value sufficient for the code to know that which server we are using for it? Do we need to give any URL/Port etc? How does this work?
    3. Is there anything else other than smtp host, username and password to be added to props?? Do we need to create a properties file??
    4. After doing these things, do I need to create a mail session in the Weblogic server also or is it a different method?
    Please help me in resolving these issues.
    Thanks

    Thanks for your kind answers, Dr. Clap..!!
    However, I will again like to ask u this:
    1. As i said that I installed Weblogic 6.1 in my local machine, can I use it as the mail server? As the server is local to my machine, i know that its only me who is the incharge of it. How do I know what smtp host to use.
    2. I am using this code:
    public callService(ServiceRequest request) throws Exception {
         EmailRequest req = (EmailRequest) request;
         Session session = null;
         MimeMessage msg = new MimeMessage(session);
         String accNum = req.getAccountNumber();
         String toAddress = req.getToAddress().trim();
         String fromAddress = generalConfig.FROM_EMAIL_ADDRESS;
         String subject = req.getSubject().trim();
         String message = req.getMessage().trim();
         String [] arrToAddress = null;
         String fileName = "./"+accNum+".htm";
         if (toAddress != null) {
    arrToAddress = convertToArray(toAddress);
         Properties props = System.getProperties();
         props.put("mail.smtp.host", "MYSERVER"); //STILL NEED TO FIGURE OUT WHAT VALUE TO PUT HERE
    session = Session.getDefaultInstance(props);
         setRecipientsTo(msg,arrToAddress);
         msg.setFrom(new InternetAddress(fromAddress));
         msg.setSubject(subject);
         msg.setText(message);
    MimeMultipart mp = new MimeMultipart();
    MimeBodyPart text = new MimeBodyPart();
         text.setDisposition(Part.INLINE);
         text.setContent(message, "text/html");
         mp.addBodyPart(text);
         MimeBodyPart file_part = new MimeBodyPart();
         File file = new File(fileName);
         FileDataSource fds = new FileDataSource(file);
         DataHandler dh = new DataHandler(fds);
         file_part.setFileName(file.getName());
         file_part.setDisposition(Part.ATTACHMENT);
         file_part.setDescription("Attached file: " + file.getName());
         file_part.setDataHandler(dh);
         mp.addBodyPart(file_part);
         msg.setContent(mp);
    Transport.send(msg); //send message
    In this code, like I am using Properties class, will this code work fine(as it is) even if I dont make any Properties text file?? or is it mandatory for me to make the properties text file and to add some values to it?
    I am sorry, I may sound a bit dumb, but I just need to learn it somehow.
    Thanks.
    P.S: convertToArray() and setRecipientsTo() are my own defined private methods.

  • Problem in tracking  Transport.send(msg)

    {color:#ff0000}+protected PasswordAuthentication getPasswordAuthentication()+
    +{ return new PasswordAuthentication("username","password");+
    +}+
    +});+
    Message msg = new MimeMessage(session);
    msg.setFrom(new InternetAddress(from));
    msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to));
    msg.setSubject(subject);
    msg.setText(message"Dear Mail Crawler, \n\n No spam to my email, please!");{color}
    {color:#ff0000}Transport.send(msg);{color}
    {color:#ff0000}System.out.println("Done");{color}
    now whenever controller comes at Transport.send(msg); and if network connection fails, then controller keep on same point until it doent gotta any network connection
    As a result user dont understand what goes wrong
    as it doesnt went ain any exception we cant throw any error msg or cant redirect to any error page.
    how we can examine timing of controller like if controller stays on Transport.send(msg) more than 5 minute then throws exception
    can we do like this???

    If you wanted to solve the problem as quickly as possible, you would've read the
    docs and had the answer by now. Really, it's not that difficult. Go to the first page
    of the javadocs. Scroll to the bottom where it tells you that each of the providers
    has properties that are specific to the provider. Click on the link for the SMTP
    provider. Scroll down that page until you see the word "timeout".
    Go ahead, you can do it...

  • Help transport .send(message) problem

    I am getting an error at transport.send(message)
    javax.mail.SendFailedException: Sending failed; nested exception is: class javax.mail.AuthenticationFailedException After eleminating all lines the error is at transport.send(msg)
    Please help - tell me what I have been doing wrong
    My code - is java mail using a jsp
    try{
         //Properties props = System.getProperties();
    Properties props = new Properties();
    Store store;
    props.put("mail.smtp.host", "smtp.snet.yahoo.com");
    props.put("mail.smtp.auth", "true");
    Session s = Session.getInstance(props,null);
    MimeMessage message = new MimeMessage(s);
    InternetAddress from = new InternetAddress("[email protected]");
    message.setFrom(from);
    String toAddresses = request.getParameter("to");
    message.addRecipients(Message.RecipientType.TO, toAddresses);
    String ccAddresses = request.getParameter("cc");
    message.setRecipients(Message.RecipientType.CC, ccAddresses);
    String bccAddresses = request.getParameter("bcc");
    message.setRecipients(Message.RecipientType.BCC, bccAddresses);
    String subject = request.getParameter("subject");
    message.setSubject(subject);
    message.setSentDate(new Date());
    String text = request.getParameter("text");
    message.setText(text);
    Transport.send(message); //error is here
    %>

    You are specifying authentication to be used, but you aren't supplying any authentication credentials, hence the AuthenticationFailedException.
    You need to create an Authenticator class. If you just need simple username/password authentication, just create a class to handle this.
    For example:
    public class SimpleAuthenticator extends Authenticator {
      private String username;
      private String password;
      private PasswordAuthentication auth;
      public java.lang.String getPassword() {
        return password;
      public PasswordAuthentication getPasswordAuthentication() {
        if(auth == null) {
          auth = new PasswordAuthentication(username, password);
        return auth;
      public java.lang.String getUsername() {
        return username;
      public void setPassword(java.lang.String password) {
        password = password;
      public void setUsername(java.lang.String username) {
        username = username;
    }Then, when you create the session:
    SimpleAuthenticator auth = new SimpleAuthenticator();
    auth.setUsername("yourusername");
    auth.setPassword("yourpassword");And instead of
    Session s = Session.getInstance(props,null);use
    Session s = Session.getInstance(props,auth);

  • Javamail html send partial message

    hi,
    I have problem with javamail when I want send a html message, the received message is incomplete(I have more than 1000 characters). And this is not the end of the message that missed.
    Can you help me?
    Here is my code:
    MimeBodyPart mbp1 = new MimeBodyPart();
    mbp1.setContent(msgText, "text/html");
    mp.addBodyPart(mbp1);
    msg.setContent(mp);
    Transport.send(msg);

    Have you looked at the Javamail FAQ? Have you looked at the sendhtml email example?

  • Transport.send(msg) size limit?!?

    Hello,
    I am having some trouble with my javamail application. I am able to send and retrieve e-mails with no problem, but sometimes when I try to send a large message, some of the message seems to be cut off, so that when I retrieve the message, only 1/2 of it is there.
    Message msg = new MimeMessage(session);
    msg.setFrom(new InternetAddress(from));
    msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to, false));
    msg.setSubject(subject);
    msg.setHeader("X-Mailer", mailer);
    msg.setSentDate(new Date());
    msg.setContent(message_param, "text/plain");
    //*** send the message
    Transport.send(msg);
    message_param is a String that holds the message.
    Thank you for you help

    I also noticed that after a certain number of lines in my message, there are blank lines being inserted which aren't in the original message. For example, my message looks ok for about 4-5 lines, but then after that, the rest of the message is on every other line, etc...
    Thanks again

  • Javamail to send message with a custom messageclass to outook exchange

    Hello,
    I developed a microsoft outlook addin which added a custom message class to our outlook exchange. Now if a user sends a message of type "IPM.Note.OurCustomForm"; the recipient gets our custom addin when the message is received. My question is, is there any way to use JavaMail to send a message from our server, which is all in Java, which the Microsoft Office exchange will pick up as the "IPM.Note.OurCustomForm"; message class and display my addin.
    Some example code, or reference to similar problems would be appreciated, I have not programmed in Java since I graduated many a years ago :). Also, I was hoping to do this without using third party software (unless it is free), but I would none the less appreciate information about them too.
    Thanks much,

    I know nothing about Exchange, so all I can give you is a general approach to
    solving this problem. Remember that Exchange is full of Microsoft proprietary
    features that are not defined by any standard or specification.
    You need to learn how to construct a MIME format message that is equivalent
    to the new Exchange-proprietary message you created. One way to do that would
    be to use JavaMail (or some other non-Outlook email client) to read a message of
    that type from Exchange and examine the MIME structure of that message. That
    should give you enough information to construct a MIME message using JavaMail
    that has the same structure (MIME types, headers, etc.).
    The second part is constructing the actual content of the message. Since you
    created the new custom message class, maybe you already know how to do that.
    But if you used a tool to do that you might not understand the raw format of that
    message, in which case you may need to reverse engineer the format by reading
    sample MIME messages in that format.
    Does that help?

  • Using JSF and JavaMail to send Automated Email

    Hi All,
    Can any one please suggest I can use JSF and JavaMail to send automated email messages i.e after a person has successfully completed a form , a message is sent to his/her email address confirming that he has succesfully registered or completed a form. I have succesfull implemeted the use of javamail for sending email meassages in a JSF web application but cant seem to figure out how i can achieve automated sending of emails in JSF. Please any ideas, tutorials or source code would be very much appreciated.
    Thanks.

    I don't understand your problem:
    You have already been able to send e-mails from a JSF webapplication, but you are not capable of sending e-mails from a JSF webapplication?!
    Automated sending of e-mails will be exactly the same as non-automated.

  • Java mail Transport.send()

    I'm getting a cryptic message when I call Transport.send(messag_object):
    no provider for address type: rfc822
    exception thrown in non-transactional ejb invoke:
    com.ssga.exception.MailManagerException
    I am using a stateless session bean to do the work.
    This call to Transport.send() is the last line in the EJB method before returning.
    Thanks
    Paul Dudley
    [email protected]

    Also make sure that you have tha activation.jar.
    Regards,
    Eric
    "Jim Typrowicz" <[email protected]> wrote in message
    news:[email protected]..
    >
    I found a reference to a mail problem in the Newsgroup. It said that WLSis missing
    two files. I downloaded the mail.jar from sun and put it in front of theweblogic.jar
    file and now the e-mail works.
    "Jim Typrowicz" <[email protected]> wrote:
    I'm getting the same error. If you find something out please let me
    know, and
    I'll do likewise. Thanks.
    "Paul Dudley" <[email protected]> wrote:
    I'm getting a cryptic message when I call Transport.send(messag_object):
    no provider for address type: rfc822
    exception thrown in non-transactional ejb invoke:
    com.ssga.exception.MailManagerException
    I am using a stateless session bean to do the work.
    This call to Transport.send() is the last line in the EJB method before
    returning.
    Thanks
    Paul Dudley
    [email protected]

  • SMTP: Transport.send() works, transport.sendMessage() not ("not connected")

    Sendig a SMTP Message to a running SMTP Server on localhost, port 25 works fine, if i use
    Transport.send( myMessage);However, it does not when i use
    Transport tr = session.getTransport(..);
    tr.connect("localhost", 25, "user", "pass");
    tr.sendMessage ( myMessage );In this case, the connect seems to work (actually, debugging in eclipse has shown that the Transport-internal field "connected" is set to true!), but sending myMessage throws the following Exception:
    java.lang.IllegalStateException: Not connected
         at com.sun.mail.smtp.SMTPTransport.checkConnected SMTPTransport.java:1398)
         at com.sun.mail.smtp.SMTPTransport.sendMessage SMTPTransport.java:489)calling transport.isConnected() also returnsfalseWell, using the static way is a first workaround, that i don't want to use because of the bad performance (need to send lot of mails under certain circumstances).
    Does anyone have an idea whats wrong?

    If your SMTP server does not require authentication, do not use "Transport.connect(server, port, username, password)", use "Transport.connect()" instead.
    If you SMTP server does require authentication, you should have the "mail.smtp.auth" property of the session set as "true".
    The following code is working properly on my machine.
    import java.lang.*;
    import java.util.*;
    import javax.mail.*;
    import javax.mail.event.*;
    import javax.mail.internet.*;
    public class SendMail {
    static String mailHost = "mail.mydomain.com";
    static String source = "[email protected]";
    static String subject = "Test JavaMail";
    static String content = "Content";
    public static void main(String args[]) {
    Properties properties = new Properties();
    properties.put("mail.smtp.host", mailHost);
    properties.put("mail.from", source);
    Session session = Session.getInstance(properties, null);
    try {
    Message message = new MimeMessage(session);
    InternetAddress[] address = new InternetAddress[args.length];
    for (int i = 0; i < args.length; i++)
    address[i] = new InternetAddress(args);
    message.setRecipients(Message.RecipientType.TO, address);
    message.setFrom(new InternetAddress(source));
    message.setSubject(subject);
    message.setContent(content, "text/plain");
    Transport transport = session.getTransport(address[0]);
    transport.addConnectionListener(new ConnectionHandler());
    transport.addTransportListener(new TransportHandler());
    transport.connect();
    transport.sendMessage(message, address);
    } catch (Exception e) {
    System.out.println(e.toString());
    class ConnectionHandler extends ConnectionAdapter {
    public void opened(ConnectionEvent e) {
    System.out.println("Connection opened.");
    public void disconnected(ConnectionEvent e) {
    System.out.println("Connection disconnected.");
    public void closed(ConnectionEvent e) {
    System.out.println("Connection closed.");
    class TransportHandler extends TransportAdapter {
    public void messageDelivered(TransportEvent e) {
    System.out.println("Message delivered.");
    public void messageNotDelivered(TransportEvent e) {
    System.out.println("Message NOT delivered.");
    public void messagePartialDelivered(TransportEvent e) {
    System.out.println("Message partially delivered.");

  • Wierd Email sending problem

    Hi,
    I used my email server, for example, "email.ZZZ.edu", to send email by the following code:
    Properties prop = System.getProperties();
    prop.put("mail.smtp.host","email.ZZZ.edu");
    Session session = Session.getDefaultInstance(prop, null);
    InternetAddress fromAddress = new InternetAddress(SendFrom);
    InternetAddress toAddress = new InternetAddress(SendTo);
    replyadd[0] = new InternetAddress(ReplyTo);
    MimeMessage emailmsg = new MimeMessage(session);
    emailmsg.setFrom(fromAddress);
    emailmsg.setRecipient(Message.RecipientType.TO, toAddress);
    emailmsg.setSentDate(new java.util.Date());
    emailmsg.setSubject(Subject);
    emailmsg.setText(EmailContent);
    Transport.send(emailmsg);
    When I send out an email to a person who is under the same email server, it works(e.g., from "[email protected]" to "[email protected]"). However, if I send to an email address that is not under the same server (e.g, from "[email protected]" to "[email protected]", I got the following error msg:
    >>>>>>>>>>>>>>>>>>>>>>>
    Email Sending Exception: javax.mail.SendFailedException: Sending failed;
    nested exception is:
         javax.mail.SendFailedException: Invalid Addresses;
    nested exception is:
         javax.mail.SendFailedException: 554 <[email protected]>: Recipient address rejected: Relay access denied
    So it seems sending to an outside address from my own email server doesn't work.
    However, on the contrary, if I send an email from [email protected] to my address "[email protected]" by using my email server "email.ZZZ.edu", it works. You see, this will cause security problem, that means, a person can send to me an email by using an forged email address.
    Does anybody knows how to solve the above two problems? Thanks in advance,
    Yihua

    What are you using for SMTP services? It looks like you have it setup to only relay messages to its own domain but accept messages for relaying from any where.
    I would talk to whoever setup the service to get it configured to relay messages anywhere but accept requests from your domain only. Your Java code looks fine and does work so I think you just need to get the environment setup right.
    Sean

  • Transport.send() connection didn't close

    Hi, I'm using JavaMail API 1.2 to create an email application. But I experienced some issues when sending emails using Transport.send(). The symptoms is the function call of Transport.send() didn't return, it hangs there forever. I don't know if it's caused by the bad email address or the SMTP server is too busy or what. Did anybody have the similar experience or solutions?

    the function call of Transport.send() didn't return,
    it hangs there forever. I don't know if it's caused by
    the bad email address or the SMTP server is too busy
    or what. Did anybody have the similar experience or
    solutions?SOmethinging is wrong with the sMtp server.Try using some other SMTP server.

  • Transport Stream Problems

    My compressor keep locking up when I set it to export in "MPEG-2/Transport Stream" setting. I would like to export in this setting because I believe that this is how Toast encodes to BluRay.
    Any ideas/thoughts/solutions?
    Go Hornets!

    I'm not sure about your transport stream problem, but Toast doesn't need it; it will use its AVCHD encoder on a regular QT movie; I exported a self contained QT movie from an FCP timeline, dragged it into the Toast window, and let it encode; it worked well.
    If you send Toast a previously compressed file, it will encode it again in the AVCHD format, probably at a loss of quality.
    Toast can burn the Blu Ray format to a standard DVD, giving you about 30 minutes of HD footage, and using your standard DVD burner.

Maybe you are looking for