Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot send an email via jsp in gmail
    primarykey
    data
    text
    <p>I've the following code in a file called clave.jsp:</p> <pre><code>@ page contentType="text/html;charset=UTF-8" language="java" %&gt; &lt;%@ page import="com.detelexia.bbdd.Datos" %&gt; &lt;%@ page import="com.detelexia.web.Utils" %&gt; &lt;%@ page import = "java.text.*" %&gt; &lt;%@ page import="java.io.*,java.util.*,javax.mail.*, javax.mail.Service"%&gt; &lt;%@ page import="javax.mail.internet.*,javax.activation.*"%&gt; &lt;%@ page import="javax.servlet.http.*,javax.servlet.*" %&gt; [....] &lt;div&gt;&lt;a href="javascript:void();" onclick="email(); return false;" class="button button-alt"&gt;ENVIAR&lt;/a&gt;&lt;/div&gt; &lt;script&gt; function email() { Properties props = new Properties(); props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.from","existingdirection@gmail.com"); props.put("mail.smtp.port", "587"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.auth", "true"); props.put("mail.debug", "true"); Session session = Session.getInstance(props, new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("existingdirection@gmail.com", "correctpassword"); } }); try { MimeMessage msg = new MimeMessage(session); msg.setFrom(); msg.setRecipients(Message.RecipientType.TO, "existingdirection@gmail.com"); msg.setSubject("JavaMail hello world example"); msg.setSentDate(new Date()); msg.setText("Hello, world!\n"); Transport.send(msg); } catch (MessagingException mex) { } } &lt;/script&gt; [....] </code></pre> <p>The code is based in the second one shown here <a href="https://stackoverflow.com/questions/6512430/tls-issue-when-sending-to-gmail-through-javamail">TLS issue when sending to gmail through JavaMail</a>, but although it's said to work I cannot get it to work. I've also tested to input root as user and password and to pass the user and password as shown there but it doesn't work.</p> <p>But it doesn't seem to send something, maybe it's that the receiving inbox can't get the message but I doubt it.</p> <p>Any idea of what I can be doing wrong? I've tried to check that code and a lot more of them but none of them seems to work and i don't know why, it all looks right.</p> <p>Of course, the compilation of the page goes perfectly.</p> <p>Thanks for your help.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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