Note that there are some explanatory texts on larger screens.

plurals
  1. POSending email with GWT: getting AccessControlException
    primarykey
    data
    text
    <p>I have this issue that I cant seem to solve easily. </p> <p>I want to send an email from within a GWT webApp. I did everything correctly in terms of putting the code in the server side and invoking it with an Async interface as its expected. So all is ok, except that when I execute the send email function, I get an error of type mailexception with and inner exception of type AccessControlException <code>"access denied (java.net.SocketPermission &lt;my smtp server&gt; resolve)"</code>. </p> <p>Now I tested the function in a regular Java console app and it worked perfectly. So I guess I need to add some code to grant access somehow. Anyone can assist me in this?</p> <p>Here is the code of the send email:</p> <pre><code> public void SendMail(String name, String email, String message) throws EmailException{ Email email1 = new SimpleEmail(); email1.setHostName("mysmtpserver"); email1.setSmtpPort(25); email1.setAuthenticator(new DefaultAuthenticator("myemail", "mypwd")); email1.setTLS(false); email1.setFrom(email); email1.setSubject("Feedback from your website"); email1.setMsg(escapeHtml(message)); email1.addTo("targetemail"); email1.send(); } </code></pre> <p>and that's the code of the class calling it:</p> <pre><code>public class SiteDataServiceImpl extends RemoteServiceServlet implements SiteDataService { @Override public boolean SendEmail(String name, String email, String message) throws IllegalArgumentException { try { new Common().SendMail(name, email, message); return true; } catch (EmailException e) { e.printStackTrace(); return false; } } </code></pre> <p>}</p> <p>PS: I thought at first that I need to include the mail.jar archive, but it is included in the gwt toolkit already, so its not the cause of the problem. And I am using Jetty with Eclipse.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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