
Signature
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
Hi Daniel
this is the code:
public int sendAdminNotification(String pFrom,String pTo,String
smtpHost,String pData )
{
String subject="denemetest";
Session ses = null;
java.util.Properties
properties=System.getProperties();
properties.put("mail.smtp.host","nowhere");
properties.put("mail.smtp.connectiontimeout","60000");
properties.put("mail.smtp.timeout","60000");
ses = Session.getInstance(properties,null);
Transport trp =null;
try
{
trp = ses.getTransport("smtp");
}
catch (NoSuchProviderException ns)
{
System.out.println("error in
gettransportconnection:"+ns.getMessage());
}
catch (MessagingException mns)
{
System.out.println("error in
gettarnsportconnection:"+mns.getMessage());
}
trp = ConnectTransport(trp,smtpHost);
try {
MimeMessage message=new MimeMessage(ses);
Address fromAddress=new InternetAddress(pFrom);
message.setFrom(fromAddress);
Address[] toAddress=InternetAddress.parse(pTo);
message.setRecipients(Message.RecipientType.TO,toAddress);
message.setSubject(subject);
MimeMultipart mp = new MimeMultipart();
MimeBodyPart b1 = new MimeBodyPart();
b1.setContent(pData,"text/html");
b1.setDisposition(b1.INLINE);
mp.addBodyPart(b1);
message.setContent(mp);
System.out.println("sending ");
trp.sendMessage(message,message.getAllRecipients() );
System.out.println("sent ");
}
catch(AddressException ae)
{
System.out.println("h1:"+ae.getMessage());
return -1;
}
catch(SendFailedException se)
{
System.out.println("h2:"+se.getMessage());
return -2;
}
catch(MessagingException me)
{
System.out.println("h3:"+me.getMessage());
return -3;
}
ses=null;
trp=null;
return 1;
}
public static void main(String[] args)
{
mailServerData m = new mailServerData();
m.sendAdminNotification( "t@xxx","a@aaaa","smtpserver","test" );
m.sendAdminNotification( "t@xxx","b@bb","smtpserver","test" );
m.sendAdminNotification( "t@xxx","c@ccc","smtpserver","test" );
}
}
On 28 Aralık, 02:19, Daniel Pitts
<newsgroup.spamfil...@virtualinfinity.net> wrote:
> > Hi All,
>
[quoted text clipped - 22 lines]
>
> - Alıntıyı göster -