Hi to the list.
I'm getting a rare problem with james 2.2.0 distribution.
I've well configured and runing test list in my WinXP & j2sdk1.4.2_05.
But, when sending html messages, it appears this error:
(At bottom it is the code of sending html)
Lot of thanks.

16/11/05 12:12:02 DEBUG spoolmanager: ==== Begin processing mail
Mail1132139521187-0====
16/11/05 12:12:02 DEBUG spoolmanager: Processing Mail1132139521187-0
through transport
16/11/05 12:12:02 DEBUG spoolmanager.transport: Servicing mail:
Mail1132139521187-0
16/11/05 12:12:02 DEBUG spoolmanager.transport: Checking
Mail1132139521187-0 with
[EMAIL PROTECTED]
16/11/05 12:12:02 DEBUG spoolmanager.transport: Checking
Mail1132139521187-0 with
[EMAIL PROTECTED]
16/11/05 12:12:02 DEBUG spoolmanager.transport: Servicing
Mail1132139521187-0 by 
16/11/05 12:12:02 ERROR spoolmanager: Exception in processor <transport>
java.lang.ClassCastException
        at
org.apache.james.transport.mailets.CommandListservFooter.service(Command
ListservFooter.java:121)
        at
org.apache.james.transport.mailets.CommandListservProcessor.addFooter(Co
mmandListservProcessor.java:228)
        at
org.apache.james.transport.mailets.CommandListservProcessor.service(Comm
andListservProcessor.java:203)
        at
org.apache.james.transport.LinearProcessor.service(LinearProcessor.java:
407)
        at
org.apache.james.transport.JamesSpoolManager.process(JamesSpoolManager.j
ava:451)
        at
org.apache.james.transport.JamesSpoolManager.run(JamesSpoolManager.java:
360)
        at java.lang.Thread.run(Thread.java:534)
16/11/05 12:12:02 ERROR spoolmanager: An error occurred processing
Mail1132139521187-0 through transport
16/11/05 12:12:02 ERROR spoolmanager: Result was error
16/11/05 12:12:02 DEBUG spoolmanager: Processing Mail1132139521187-0
through error
16/11/05 12:12:02 DEBUG spoolmanager.error: Servicing mail:
Mail1132139521187-0
16/11/05 12:12:02 DEBUG spoolmanager.error: Checking Mail1132139521187-0
with [EMAIL PROTECTED]
16/11/05 12:12:02 DEBUG spoolmanager.error: Servicing
Mail1132139521187-0 by ToRepository Mailet
16/11/05 12:12:02 DEBUG spoolmanager: Processed Mail1132139521187-0
through error
16/11/05 12:12:02 DEBUG spoolmanager: Result was ghost
16/11/05 12:12:02 DEBUG spoolmanager: ==== Removed from spool mail
Mail1132139521187-0====


==================== Code of sending html mail
============================


import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import java.io.*;

/*
  To use this program, change values for the following three constants,

    SMTP_HOST_NAME -- Has your SMTP Host Name
    SMTP_AUTH_USER -- Has your SMTP Authentication UserName
    SMTP_AUTH_PWD  -- Has your SMTP Authentication Password

  Next change values for fields

  emailMsgTxt  -- Message Text for the Email
  emailSubjectTxt  -- Subject for email
  emailFromAddress -- Email Address whose name will appears as "from"
address

  Next change value for "emailList".
  This String array has List of all Email Addresses to Email Email needs
to be sent to.


  Next to run the program, execute it as follows,

  SendMailUsingAuthentication authProg = new
SendMailUsingAuthentication();

*/

public class SendMailUsingAuthentication
{

  private static final String SMTP_HOST_NAME = "localhost";
  private static final String SMTP_AUTH_USER = "dsoriano";
  private static final String SMTP_AUTH_PWD  = "simba";

  private static final String emailMsgTxt      = "Boletin 76";
  private static final String emailSubjectTxt  = "Boletin 76";
  private static final String emailFromAddress = "[EMAIL PROTECTED]";

  // Add List of Email address to who email needs to be sent to
  private static final String[] emailList = {"[EMAIL PROTECTED]"};

  public static void main(String args[]) throws Exception
  {
    SendMailUsingAuthentication smtpMailSender = new
SendMailUsingAuthentication();
    
    BufferedReader bf = new BufferedReader(new
FileReader("F:\\proyectos\\elcano\\web\\src\\mantenimiento_real\\boletin
75\\boletin75.htm"));
    StringBuffer html = new StringBuffer();
    String line = "";
    while ((line=bf.readLine())!=null){
        html .append(line);
    }
    bf.close();
    
    smtpMailSender.postHtmlMail( emailList, emailSubjectTxt,
html.toString() , emailFromAddress);
    
    //smtpMailSender.postMail( emailList, emailSubjectTxt, emailMsgTxt ,
emailFromAddress);
    System.out.println("Sucessfully Sent mail to All Users");
  }

  public void postMail( String recipients[ ], String subject,
                            String message , String from) throws
MessagingException
  {
    boolean debug = false;

     //Set the host smtp address
     Properties props = new Properties();
     props.put("mail.smtp.host", SMTP_HOST_NAME);
     props.put("mail.smtp.auth", "true");

    Authenticator auth = new SMTPAuthenticator();
    Session session = Session.getDefaultInstance(props, auth);

    session.setDebug(debug);

    // create a message
    Message msg = new MimeMessage(session);

    // set the from and to address
    InternetAddress addressFrom = new InternetAddress(from);
    msg.setFrom(addressFrom);

    InternetAddress[] addressTo = new
InternetAddress[recipients.length];
    for (int i = 0; i < recipients.length; i++)
    {
        addressTo[i] = new InternetAddress(recipients[i]);
    }
    msg.setRecipients(Message.RecipientType.TO, addressTo);


    // Setting the Subject and Content Type
    msg.setSubject(subject);
    msg.setContent(message, "text/plain");
    
    Transport.send(msg);
 }

 public void postHtmlMail( String recipients[ ], String subject,
                           String message , String from) throws
MessagingException
 {
   boolean debug = false;

    //Set the host smtp address
    Properties props = new Properties();
    props.put("mail.smtp.host", SMTP_HOST_NAME);
    props.put("mail.smtp.auth", "true");

   Authenticator auth = new SMTPAuthenticator();
   Session session = Session.getDefaultInstance(props, auth);

   session.setDebug(debug);

   // create a message
   Message msg = new MimeMessage(session);

   // set the from and to address
   InternetAddress addressFrom = new InternetAddress(from);
   msg.setFrom(addressFrom);

   InternetAddress[] addressTo = new InternetAddress[recipients.length];
   for (int i = 0; i < recipients.length; i++)
   {
       addressTo[i] = new InternetAddress(recipients[i]);
   }
   msg.setRecipients(Message.RecipientType.TO, addressTo);


   // Setting the Subject and Content Type
   msg.setSubject(subject);
   msg.setContent(message, "text/html");
   Transport.send(msg);
}

/**
* SimpleAuthenticator is used to do simple authentication
* when the SMTP server requires it.
*/
private class SMTPAuthenticator extends javax.mail.Authenticator
{

    public PasswordAuthentication getPasswordAuthentication()
    {
        String username = SMTP_AUTH_USER;
        String password = SMTP_AUTH_PWD;
        return new PasswordAuthentication(username, password);
    }
}

}


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to