Hi,

okay I have been a little fast. I knew that you can send emails without
including the recipients in the header, with smtp you can even send anything
else than a mime message. But I wouldn't recommend anybody to do send emails
without including the final recipient in the header, if the recipient in the
To: header is not an email address well known to the actual recipient. The
only thing I didn't think about is, that the Forward Servlet is, of course
not changing the headers. I don't know about James handling of the Bcc:
header. Is it removed from the mail before delivery? Is this done by james
or the mail api? On the incoming or the outgoing?

Stefan, to answer your question: The code I posted will deliver a mail sent
to the email address given in the james.conf to any address returned by the
method getRecipients() which you would have to implement. It could do
anything. But refering to what I just wrote, you should think about changing
the To: header. The code could look like this:

    public void service(Mail mail) throws MessagingException {
          MailAddress [] recipients = getRecipents(mailinglist);
          MimeMessage source = mail.getMessage();
          for (int i=0;i<recipients.length;i++) {
                InternetAddress [] to = recipients[i].toInternetAddress();
                MimeMessage msg = new MimeMessage(source);
                msg.setRecipients(Message.RecipientType.TO,to);
                getMailetContext().sendMail(mail.getSender(), recipients[i],
msg);
        }
        mail.setState(Mail.GHOST);
    }

I really don't know if james processes several mails in parallel. in this
case i would insert a sleep in the mailet.
But probably writing such a mailet isn't what you really want? As I wrote
before, there is probably a way to use the already written Mailets for
Mailinglists. The Mailet I presented is just one way. (The way I would do
it.) It enables you to get the Recipients from any resource you can access
from within Java, what should be anywhere, if you know Java at all. If to
correct another error I made in my last posting: MailetContext.sendMail()
let the Mail be processed by the root processor first and not the transport
processor. I don't know what made me think so ....

Greetings,
  Marcus


> -----Urspr�ngliche Nachricht-----
> Von: Serge Knystautas [mailto:[EMAIL PROTECTED]]
> Gesendet: Montag, 3. September 2001 21:17
> An: [EMAIL PROTECTED]
> Betreff: Re: Disabling javax.mail.SendFailedException: 552 Too many
> receipts
> 
> 
> You can send a message to multiple recipients without 
> including the other
> recipients in the headers.  Email client software will call 
> it BCC, and if
> you're generating the SMTP message yourself, you do whatever you want
> (message headers can be completely unrelated to delivery 
> information, hence
> the difficulties in stopping spammers)
> 
> Serge Knystautas
> Loki Technologies
> http://www.lokitech.com/
> ----- Original Message -----
> From: "Labib Iskander, Marcus" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, September 03, 2001 2:49 PM
> Subject: AW: Disabling javax.mail.SendFailedException: 552 
> Too many receipts
> 
> 
> Hi Nick,
> 
> please excuse my question, but wouldn't you normally want to 
> send to only
> one recipient at a time, instead of telling the people every 
> single address
> which recieved the same message? Not to mention the waste of transfer
> bandwidth sending an email whichs header is bigger than the body.
> You could use some mailinglist tool. I am not used to the 
> mailinglist tools
> of james (certainly there is some cool way to use them) but 
> with a mailet
> you could implement it easily.
> You just send to a single email address which will be processed by the
> mailet:
> <mailet match="RecipientIs='[EMAIL PROTECTED]'" class="MyList">
>                         <mailinglist>list1</mailinglist>
> </mailet>
> 
> The mailet shoud look like this (analog to the
> org.apache.james.transport.mailets.Forward mailet):
> 
> package mymailets;
> 
> import org.apache.mailet.*;
> import java.util.*;
> import javax.mail.*;
> import javax.mail.internet.*;
> 
> public class MyList extends GenericMailet {
> 
>     private String mailinglist;
> 
>     public void init() throws MessagingException {
>         mailinglist = 
> getMailetConfig().getInitParameter("mailinglist");
>     }
> 
>     private MailAddress [] getRecipients(String listName) {
>         // your code
>     }
> 
>     public void service(Mail mail) throws MessagingException {
>   MailAddress [] recipients = getRecipents(mailinglist);
>   for (int i=0;i<recipients.length;i++) {
>         getMailetContext().sendMail(mail.getSender(), recipients[i],
> mail.getMessage());
>         }
>         mail.setState(Mail.GHOST);
>     }
> 
>     public String getMailetInfo() {
>         return "List Mailet";
>     }
> }
> 
> 
> Dont forget to include this in the spoolmanager element
> <mailetpackages>
>     <mailetpackage>mymailets.</mailetpackage>
> 
> <mailetpackage>org.apache.james.transport.mailets.</mailetpackage>
> </mailetpackages>
> 
> And take care that the transport processor is configured to 
> send mail from
> the mailaddress your webapplication is using to the outside, 
> because the
> MailetContext.sendMail() passes the mail directly to the transport
> processor.
> 
> Greetings,
>   Marcus
> 
> -----Urspr�ngliche Nachricht-----
> Von: Nick [mailto:[EMAIL PROTECTED]]
> Gesendet: Montag, 3. September 2001 19:24
> An: [EMAIL PROTECTED]
> Betreff: Disabling javax.mail.SendFailedException: 552 Too 
> many receipts
> 
> 
> Hi,
> 
> I am trying to set up an application where I need to be able to mail
> thousands of people from our database via a web interface. My 
> problem has
> been sending over 100 emails at a time where I get the 552 
> message. Is there
> a way to disable this feature in James so that I can send my emails?
> 
> Thanks,
> 
> Stefan
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

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

Reply via email to