Note that there are some explanatory texts on larger screens.

plurals
  1. POjava.security.AccessControlException: access denied ("java.net.SocketPermission" "smtp.gmail.com" "resolve")
    primarykey
    data
    text
    <p>I am using GlassFish Server 3.1 and the Java mail Api 1.4.5. </p> <p>Scenario: I have an applet, that when clicked it sends an email message.</p> <p>Send the mail works perfectly on Netbeans AppletViewer, but it turns into hell when added to the browser and trying to send the email from there.</p> <p>I have read for hours, about policy files, signed/unsigned applets...etc.</p> <p>I have tried using the signed applet (plenty of tutorials out there for signing it, was quite simple using the keytools from java). When I run it on the browser it asks for permission because it´s a self-signed certificate, I give it permission , but it still spits out the same exception.</p> <p>I have also tried modifying java.poilcy file adding</p> <p>permission java.net.SocketPermission "smtp.gmail.com:587", "listen,resolve";</p> <p>But nothing.</p> <p>I know it´s that exception because I activaded the Java Console in the Java Control Panel. I really don´t know what else to do.</p> <p>Here is the code that sends the email:</p> <pre><code> String host = "smtp.gmail.com"; String from = *****; String pass = ******; Properties props = new Properties(); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.host", host); props.put("mail.smtp.user", from); props.put("mail.smtp.password", pass); props.put("mail.smtp.port", "587"); props.put("mail.smtp.auth", "true"); Session session = Session.getDefaultInstance(props, null); this.message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); InternetAddress toAddress = new InternetAddress(this.to); this.message.addRecipient(Message.RecipientType.TO, toAddress); this.message.setSubject(this.subject); this.message.setText(this.body); Transport transport = session.getTransport("smtp"); transport.connect(host, from, pass); transport.sendMessage(this.message, this.message.getAllRecipients()); transport.close(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload