Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

signed applet get access denied java.net.SocketPermision smtp.gmail.com

821042Dec 3 2010 — edited Dec 4 2010
Hi, i have a signed applet which send emails. It works fine on netbeans, but when i run it in browsers(ie,mozila,crome,opera) i get this error: java.security.AccessControlException access denied java.net.SocketPermission smtp.gmail.com

This is the code but i'm sure is not the problem:

//start code_____________________________________________________________________________
public class ABC {
public String to="";
public String file="";
static GMailAuthenticator auth=new GMailAuthenticator("myemail", "mypassword");
public ABC(String to_,String file_)
{
this.to=to_;
file=file_;
}

public boolean send()
{ boolean ok=true;

try {
Properties props = System.getProperties();
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "587"); // smtp port
Session session = Session.getInstance(props,auth );


MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("editor.onxml@gmail"));
msg.setSubject(file+" attachment");
msg.setRecipient(RecipientType.TO, new InternetAddress(to));

//add atleast simple body
MimeBodyPart body = new MimeBodyPart();
body.setText("on-xml " + file + " file saved attachment");

//do attachment
MimeBodyPart attachMent = new MimeBodyPart();
FileDataSource dataSource = new FileDataSource(new File(file));
attachMent.setDataHandler(new DataHandler(dataSource));
attachMent.setFileName(file);
attachMent.setDisposition(MimeBodyPart.ATTACHMENT);
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(body);
multipart.addBodyPart(attachMent);
msg.setContent(multipart);
Transport.send(msg);
} catch (Exception ex)
{ok=false;JOptionPane.showMessageDialog(null, "Failed to send: "+ex.toString() , "Failed to send: "+ex.toString(), JOptionPane.INFORMATION_MESSAGE);}
return ok;
}

}

//end code______________________________________________________________________________

PS: i also signed mail.jar and activation.jar but make no difference :)
Thx
This post has been answered by baftos on Dec 4 2010
Jump to Answer

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jan 1 2011
Added on Dec 3 2010
16 comments
499 views