Java send email stuck with no exceptionsIs Java “pass-by-reference” or “pass-by-value”?How do I read / convert an InputStream into a String in Java?Creating a memory leak with JavaJava Mail Exception Error;javax.mail.MessagingException: Could not connect to SMTP host with windows server 2008R2Adding dependencies for sending mail in javaCan't send any mail using JavaMailCould not connect to SMTP host: smtp.gmail.com, port: 587; nested exception is: java.net.ConnectException: Connection timed out: connectcom.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 25; timeout -1;how to send email from using outlook using a java api

How is Sword Coast North governed?

Accurately recalling the key - can everyone do it?

What is the most 'environmentally friendly' way to learn to fly?

Can birds evolve without trees?

Can black block with a hanging piece in a back rank mate situation?

Does the problem of P vs NP come under the category of Operational Research?

A game of red and black

Using Python in a Bash Script

Went to a big 4 but got fired for underperformance in a year recently - Now every one thinks I'm pro - How to balance expectations?

How do I safety check that there is no light in Darkroom / Darkbag?

Can I shorten this filter, that finds disk sizes over 100G?

Adding a (stair/baby) gate without facing walls

Is it moral to remove/hide certain parts of a photo, as a photographer?

Skipping same old introductions

What is my clock telling me to do?

Why do MS SQL Server SEQUENCEs not have an ORDER parameter like Oracle?

How to gracefully excuse yourself from a meeting due to emergencies such as a restroom break?

Protect a 6 inch air hose from physical damage

Is it really a problem to declare that a visitor to the UK is my "girlfriend", in terms of her successfully getting a Standard Visitor visa?

Feedback diagram

Security measures that could plausibly last 150+ years?

Backpacking with incontinence

Why are prop blades not shaped like household fan blades?

Python π = 1 + (1/2) + (1/3) + (1/4) - (1/5) + (1/6) + (1/7) + (1/8) + (1/9) - (1/10) ...1748 Euler



Java send email stuck with no exceptions


Is Java “pass-by-reference” or “pass-by-value”?How do I read / convert an InputStream into a String in Java?Creating a memory leak with JavaJava Mail Exception Error;javax.mail.MessagingException: Could not connect to SMTP host with windows server 2008R2Adding dependencies for sending mail in javaCan't send any mail using JavaMailCould not connect to SMTP host: smtp.gmail.com, port: 587; nested exception is: java.net.ConnectException: Connection timed out: connectcom.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 25; timeout -1;how to send email from using outlook using a java api






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















Try to send an email using java. Find an example from: https://www.codejava.net/java-ee/javamail/send-e-mail-in-html-format-using-javamail-api.



However, when try to send the email, it looks like the code stuck at Transport.send(msg); and doesn't make any progress anymore. And it also not timed out.



import java.util.Date;
import java.util.Properties;

import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class HtmlEmailSender

public void sendHtmlEmail(String host, String port,
final String userName, final String password, String toAddress,
String subject, String message) throws AddressException,
MessagingException

// sets SMTP server properties
Properties properties = new Properties();
properties.put("mail.smtp.host", host);
properties.put("mail.smtp.port", port);
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.starttls.enable", "true");

// creates a new session with an authenticator
Authenticator auth = new Authenticator()
public PasswordAuthentication getPasswordAuthentication()
return new PasswordAuthentication(userName, password);

;

Session session = Session.getInstance(properties, auth);

// creates a new e-mail message
Message msg = new MimeMessage(session);

msg.setFrom(new InternetAddress(userName));
InternetAddress[] toAddresses = new InternetAddress(toAddress) ;
msg.setRecipients(Message.RecipientType.TO, toAddresses);
msg.setSubject(subject);
msg.setSentDate(new Date());
// set plain text message
msg.setContent(message, "text/html");

// sends the e-mail
Transport.send(msg);
log.info("Success!");



/**
* Test the send html e-mail method
*
*/
public static void main(String[] args)
// SMTP server information
String host = "smtp.gmail.com";
String port = "587";
String mailFrom = "fromemail@gmail.com";
String password = "password";

// outgoing message information
String mailTo = "toemail@gmail.com";
String subject = "Hello my friend";

// message contains HTML markups
String message = "<i>Greetings!</i><br>";
message += "<b>Wish you a nice day!</b><br>";
message += "<font color=red>Duke</font>";

HtmlEmailSender mailer = new HtmlEmailSender();

try
mailer.sendHtmlEmail(host, port, mailFrom, password, mailTo,
subject, message);
System.out.println("Email sent.");
catch (Exception ex)
System.out.println("Failed to sent email.");
ex.printStackTrace();





UPDATE:
I was able to get rid of the initial issue by turning on the IMAP optional for my gmail account. But then I got another exception:



DEBUG: setDebug: JavaMail version 1.6.0
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
DEBUG SMTP: need username and password for authentication
DEBUG SMTP: protocolConnect returning false, host=smtp.gmail.com, user='myusername', password=<null>
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 587, isSSL true
Failed to sent email.
com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 587; timeout -1;
nested exception is:
java.net.ConnectException: Operation timed out (Connection timed out)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2194)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:726)
at javax.mail.Service.connect(Service.java:388)
at javax.mail.Service.connect(Service.java:246)
at javax.mail.Service.connect(Service.java:195)
at javax.mail.Transport.send0(Transport.java:254)
at javax.mail.Transport.send(Transport.java:124)
at insbot.HtmlEmailSender.sendHtmlEmail(HtmlEmailSender.java:55)
at insbot.HtmlEmailSender.main(HtmlEmailSender.java:83)
Caused by: java.net.ConnectException: Operation timed out (Connection timed out)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:352)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:238)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2160)
... 8 more









share|improve this question





















  • 1





    Are you sending on your local machine or in a server? Have you debugged to see which line is causing the issue?

    – nullptr
    Mar 26 at 23:51






  • 2





    Autogoing connection blocked by firewall, maybe.

    – LppEdd
    Mar 27 at 0:02






  • 1





    Your new problem seems pretty obvious. There is some reason you can't connect to the service at address smtp.gmail.com listening at port 587. I can connect to that port from my Mac, so you must have some sort of firewall thing going on, or some other reason that your workstation can't reach that port. I'm pretty sure that java.net.ConnectException: Operation timed out (Connection timed out) means that the connection never happened, so it doesn't matter what the code on your side is trying to do once connected.

    – Steve
    Mar 27 at 21:51







  • 1





    A really good trick to have in your toolbox for things like this is 'telnet'. See if you can connect via 'telnet' at a command prompt, by doing: telnet smtp.gmail.com 587. Does this make a connection? If not, then the problem has nothing to do with your code.

    – Steve
    Mar 27 at 21:53







  • 1





    @chrisTina, so telnet doesn't work from your workstation, right? If so, then I can't think of anything more to suggest. You need to step away from your codeuynd just figure out what's going on with your network. Can you get out in general...like to the main google site? Are you working at a company that might be blocking certain outgoing connections? That's often what this sort of thing is about.

    – Steve
    Mar 28 at 3:20

















0















Try to send an email using java. Find an example from: https://www.codejava.net/java-ee/javamail/send-e-mail-in-html-format-using-javamail-api.



However, when try to send the email, it looks like the code stuck at Transport.send(msg); and doesn't make any progress anymore. And it also not timed out.



import java.util.Date;
import java.util.Properties;

import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class HtmlEmailSender

public void sendHtmlEmail(String host, String port,
final String userName, final String password, String toAddress,
String subject, String message) throws AddressException,
MessagingException

// sets SMTP server properties
Properties properties = new Properties();
properties.put("mail.smtp.host", host);
properties.put("mail.smtp.port", port);
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.starttls.enable", "true");

// creates a new session with an authenticator
Authenticator auth = new Authenticator()
public PasswordAuthentication getPasswordAuthentication()
return new PasswordAuthentication(userName, password);

;

Session session = Session.getInstance(properties, auth);

// creates a new e-mail message
Message msg = new MimeMessage(session);

msg.setFrom(new InternetAddress(userName));
InternetAddress[] toAddresses = new InternetAddress(toAddress) ;
msg.setRecipients(Message.RecipientType.TO, toAddresses);
msg.setSubject(subject);
msg.setSentDate(new Date());
// set plain text message
msg.setContent(message, "text/html");

// sends the e-mail
Transport.send(msg);
log.info("Success!");



/**
* Test the send html e-mail method
*
*/
public static void main(String[] args)
// SMTP server information
String host = "smtp.gmail.com";
String port = "587";
String mailFrom = "fromemail@gmail.com";
String password = "password";

// outgoing message information
String mailTo = "toemail@gmail.com";
String subject = "Hello my friend";

// message contains HTML markups
String message = "<i>Greetings!</i><br>";
message += "<b>Wish you a nice day!</b><br>";
message += "<font color=red>Duke</font>";

HtmlEmailSender mailer = new HtmlEmailSender();

try
mailer.sendHtmlEmail(host, port, mailFrom, password, mailTo,
subject, message);
System.out.println("Email sent.");
catch (Exception ex)
System.out.println("Failed to sent email.");
ex.printStackTrace();





UPDATE:
I was able to get rid of the initial issue by turning on the IMAP optional for my gmail account. But then I got another exception:



DEBUG: setDebug: JavaMail version 1.6.0
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
DEBUG SMTP: need username and password for authentication
DEBUG SMTP: protocolConnect returning false, host=smtp.gmail.com, user='myusername', password=<null>
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 587, isSSL true
Failed to sent email.
com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 587; timeout -1;
nested exception is:
java.net.ConnectException: Operation timed out (Connection timed out)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2194)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:726)
at javax.mail.Service.connect(Service.java:388)
at javax.mail.Service.connect(Service.java:246)
at javax.mail.Service.connect(Service.java:195)
at javax.mail.Transport.send0(Transport.java:254)
at javax.mail.Transport.send(Transport.java:124)
at insbot.HtmlEmailSender.sendHtmlEmail(HtmlEmailSender.java:55)
at insbot.HtmlEmailSender.main(HtmlEmailSender.java:83)
Caused by: java.net.ConnectException: Operation timed out (Connection timed out)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:352)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:238)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2160)
... 8 more









share|improve this question





















  • 1





    Are you sending on your local machine or in a server? Have you debugged to see which line is causing the issue?

    – nullptr
    Mar 26 at 23:51






  • 2





    Autogoing connection blocked by firewall, maybe.

    – LppEdd
    Mar 27 at 0:02






  • 1





    Your new problem seems pretty obvious. There is some reason you can't connect to the service at address smtp.gmail.com listening at port 587. I can connect to that port from my Mac, so you must have some sort of firewall thing going on, or some other reason that your workstation can't reach that port. I'm pretty sure that java.net.ConnectException: Operation timed out (Connection timed out) means that the connection never happened, so it doesn't matter what the code on your side is trying to do once connected.

    – Steve
    Mar 27 at 21:51







  • 1





    A really good trick to have in your toolbox for things like this is 'telnet'. See if you can connect via 'telnet' at a command prompt, by doing: telnet smtp.gmail.com 587. Does this make a connection? If not, then the problem has nothing to do with your code.

    – Steve
    Mar 27 at 21:53







  • 1





    @chrisTina, so telnet doesn't work from your workstation, right? If so, then I can't think of anything more to suggest. You need to step away from your codeuynd just figure out what's going on with your network. Can you get out in general...like to the main google site? Are you working at a company that might be blocking certain outgoing connections? That's often what this sort of thing is about.

    – Steve
    Mar 28 at 3:20













0












0








0








Try to send an email using java. Find an example from: https://www.codejava.net/java-ee/javamail/send-e-mail-in-html-format-using-javamail-api.



However, when try to send the email, it looks like the code stuck at Transport.send(msg); and doesn't make any progress anymore. And it also not timed out.



import java.util.Date;
import java.util.Properties;

import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class HtmlEmailSender

public void sendHtmlEmail(String host, String port,
final String userName, final String password, String toAddress,
String subject, String message) throws AddressException,
MessagingException

// sets SMTP server properties
Properties properties = new Properties();
properties.put("mail.smtp.host", host);
properties.put("mail.smtp.port", port);
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.starttls.enable", "true");

// creates a new session with an authenticator
Authenticator auth = new Authenticator()
public PasswordAuthentication getPasswordAuthentication()
return new PasswordAuthentication(userName, password);

;

Session session = Session.getInstance(properties, auth);

// creates a new e-mail message
Message msg = new MimeMessage(session);

msg.setFrom(new InternetAddress(userName));
InternetAddress[] toAddresses = new InternetAddress(toAddress) ;
msg.setRecipients(Message.RecipientType.TO, toAddresses);
msg.setSubject(subject);
msg.setSentDate(new Date());
// set plain text message
msg.setContent(message, "text/html");

// sends the e-mail
Transport.send(msg);
log.info("Success!");



/**
* Test the send html e-mail method
*
*/
public static void main(String[] args)
// SMTP server information
String host = "smtp.gmail.com";
String port = "587";
String mailFrom = "fromemail@gmail.com";
String password = "password";

// outgoing message information
String mailTo = "toemail@gmail.com";
String subject = "Hello my friend";

// message contains HTML markups
String message = "<i>Greetings!</i><br>";
message += "<b>Wish you a nice day!</b><br>";
message += "<font color=red>Duke</font>";

HtmlEmailSender mailer = new HtmlEmailSender();

try
mailer.sendHtmlEmail(host, port, mailFrom, password, mailTo,
subject, message);
System.out.println("Email sent.");
catch (Exception ex)
System.out.println("Failed to sent email.");
ex.printStackTrace();





UPDATE:
I was able to get rid of the initial issue by turning on the IMAP optional for my gmail account. But then I got another exception:



DEBUG: setDebug: JavaMail version 1.6.0
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
DEBUG SMTP: need username and password for authentication
DEBUG SMTP: protocolConnect returning false, host=smtp.gmail.com, user='myusername', password=<null>
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 587, isSSL true
Failed to sent email.
com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 587; timeout -1;
nested exception is:
java.net.ConnectException: Operation timed out (Connection timed out)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2194)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:726)
at javax.mail.Service.connect(Service.java:388)
at javax.mail.Service.connect(Service.java:246)
at javax.mail.Service.connect(Service.java:195)
at javax.mail.Transport.send0(Transport.java:254)
at javax.mail.Transport.send(Transport.java:124)
at insbot.HtmlEmailSender.sendHtmlEmail(HtmlEmailSender.java:55)
at insbot.HtmlEmailSender.main(HtmlEmailSender.java:83)
Caused by: java.net.ConnectException: Operation timed out (Connection timed out)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:352)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:238)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2160)
... 8 more









share|improve this question
















Try to send an email using java. Find an example from: https://www.codejava.net/java-ee/javamail/send-e-mail-in-html-format-using-javamail-api.



However, when try to send the email, it looks like the code stuck at Transport.send(msg); and doesn't make any progress anymore. And it also not timed out.



import java.util.Date;
import java.util.Properties;

import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class HtmlEmailSender

public void sendHtmlEmail(String host, String port,
final String userName, final String password, String toAddress,
String subject, String message) throws AddressException,
MessagingException

// sets SMTP server properties
Properties properties = new Properties();
properties.put("mail.smtp.host", host);
properties.put("mail.smtp.port", port);
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.starttls.enable", "true");

// creates a new session with an authenticator
Authenticator auth = new Authenticator()
public PasswordAuthentication getPasswordAuthentication()
return new PasswordAuthentication(userName, password);

;

Session session = Session.getInstance(properties, auth);

// creates a new e-mail message
Message msg = new MimeMessage(session);

msg.setFrom(new InternetAddress(userName));
InternetAddress[] toAddresses = new InternetAddress(toAddress) ;
msg.setRecipients(Message.RecipientType.TO, toAddresses);
msg.setSubject(subject);
msg.setSentDate(new Date());
// set plain text message
msg.setContent(message, "text/html");

// sends the e-mail
Transport.send(msg);
log.info("Success!");



/**
* Test the send html e-mail method
*
*/
public static void main(String[] args)
// SMTP server information
String host = "smtp.gmail.com";
String port = "587";
String mailFrom = "fromemail@gmail.com";
String password = "password";

// outgoing message information
String mailTo = "toemail@gmail.com";
String subject = "Hello my friend";

// message contains HTML markups
String message = "<i>Greetings!</i><br>";
message += "<b>Wish you a nice day!</b><br>";
message += "<font color=red>Duke</font>";

HtmlEmailSender mailer = new HtmlEmailSender();

try
mailer.sendHtmlEmail(host, port, mailFrom, password, mailTo,
subject, message);
System.out.println("Email sent.");
catch (Exception ex)
System.out.println("Failed to sent email.");
ex.printStackTrace();





UPDATE:
I was able to get rid of the initial issue by turning on the IMAP optional for my gmail account. But then I got another exception:



DEBUG: setDebug: JavaMail version 1.6.0
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
DEBUG SMTP: need username and password for authentication
DEBUG SMTP: protocolConnect returning false, host=smtp.gmail.com, user='myusername', password=<null>
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 587, isSSL true
Failed to sent email.
com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 587; timeout -1;
nested exception is:
java.net.ConnectException: Operation timed out (Connection timed out)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2194)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:726)
at javax.mail.Service.connect(Service.java:388)
at javax.mail.Service.connect(Service.java:246)
at javax.mail.Service.connect(Service.java:195)
at javax.mail.Transport.send0(Transport.java:254)
at javax.mail.Transport.send(Transport.java:124)
at insbot.HtmlEmailSender.sendHtmlEmail(HtmlEmailSender.java:55)
at insbot.HtmlEmailSender.main(HtmlEmailSender.java:83)
Caused by: java.net.ConnectException: Operation timed out (Connection timed out)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:352)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:238)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2160)
... 8 more






java javamail






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 21:39







chrisTina

















asked Mar 26 at 23:43









chrisTinachrisTina

9273 gold badges26 silver badges47 bronze badges




9273 gold badges26 silver badges47 bronze badges










  • 1





    Are you sending on your local machine or in a server? Have you debugged to see which line is causing the issue?

    – nullptr
    Mar 26 at 23:51






  • 2





    Autogoing connection blocked by firewall, maybe.

    – LppEdd
    Mar 27 at 0:02






  • 1





    Your new problem seems pretty obvious. There is some reason you can't connect to the service at address smtp.gmail.com listening at port 587. I can connect to that port from my Mac, so you must have some sort of firewall thing going on, or some other reason that your workstation can't reach that port. I'm pretty sure that java.net.ConnectException: Operation timed out (Connection timed out) means that the connection never happened, so it doesn't matter what the code on your side is trying to do once connected.

    – Steve
    Mar 27 at 21:51







  • 1





    A really good trick to have in your toolbox for things like this is 'telnet'. See if you can connect via 'telnet' at a command prompt, by doing: telnet smtp.gmail.com 587. Does this make a connection? If not, then the problem has nothing to do with your code.

    – Steve
    Mar 27 at 21:53







  • 1





    @chrisTina, so telnet doesn't work from your workstation, right? If so, then I can't think of anything more to suggest. You need to step away from your codeuynd just figure out what's going on with your network. Can you get out in general...like to the main google site? Are you working at a company that might be blocking certain outgoing connections? That's often what this sort of thing is about.

    – Steve
    Mar 28 at 3:20












  • 1





    Are you sending on your local machine or in a server? Have you debugged to see which line is causing the issue?

    – nullptr
    Mar 26 at 23:51






  • 2





    Autogoing connection blocked by firewall, maybe.

    – LppEdd
    Mar 27 at 0:02






  • 1





    Your new problem seems pretty obvious. There is some reason you can't connect to the service at address smtp.gmail.com listening at port 587. I can connect to that port from my Mac, so you must have some sort of firewall thing going on, or some other reason that your workstation can't reach that port. I'm pretty sure that java.net.ConnectException: Operation timed out (Connection timed out) means that the connection never happened, so it doesn't matter what the code on your side is trying to do once connected.

    – Steve
    Mar 27 at 21:51







  • 1





    A really good trick to have in your toolbox for things like this is 'telnet'. See if you can connect via 'telnet' at a command prompt, by doing: telnet smtp.gmail.com 587. Does this make a connection? If not, then the problem has nothing to do with your code.

    – Steve
    Mar 27 at 21:53







  • 1





    @chrisTina, so telnet doesn't work from your workstation, right? If so, then I can't think of anything more to suggest. You need to step away from your codeuynd just figure out what's going on with your network. Can you get out in general...like to the main google site? Are you working at a company that might be blocking certain outgoing connections? That's often what this sort of thing is about.

    – Steve
    Mar 28 at 3:20







1




1





Are you sending on your local machine or in a server? Have you debugged to see which line is causing the issue?

– nullptr
Mar 26 at 23:51





Are you sending on your local machine or in a server? Have you debugged to see which line is causing the issue?

– nullptr
Mar 26 at 23:51




2




2





Autogoing connection blocked by firewall, maybe.

– LppEdd
Mar 27 at 0:02





Autogoing connection blocked by firewall, maybe.

– LppEdd
Mar 27 at 0:02




1




1





Your new problem seems pretty obvious. There is some reason you can't connect to the service at address smtp.gmail.com listening at port 587. I can connect to that port from my Mac, so you must have some sort of firewall thing going on, or some other reason that your workstation can't reach that port. I'm pretty sure that java.net.ConnectException: Operation timed out (Connection timed out) means that the connection never happened, so it doesn't matter what the code on your side is trying to do once connected.

– Steve
Mar 27 at 21:51






Your new problem seems pretty obvious. There is some reason you can't connect to the service at address smtp.gmail.com listening at port 587. I can connect to that port from my Mac, so you must have some sort of firewall thing going on, or some other reason that your workstation can't reach that port. I'm pretty sure that java.net.ConnectException: Operation timed out (Connection timed out) means that the connection never happened, so it doesn't matter what the code on your side is trying to do once connected.

– Steve
Mar 27 at 21:51





1




1





A really good trick to have in your toolbox for things like this is 'telnet'. See if you can connect via 'telnet' at a command prompt, by doing: telnet smtp.gmail.com 587. Does this make a connection? If not, then the problem has nothing to do with your code.

– Steve
Mar 27 at 21:53






A really good trick to have in your toolbox for things like this is 'telnet'. See if you can connect via 'telnet' at a command prompt, by doing: telnet smtp.gmail.com 587. Does this make a connection? If not, then the problem has nothing to do with your code.

– Steve
Mar 27 at 21:53





1




1





@chrisTina, so telnet doesn't work from your workstation, right? If so, then I can't think of anything more to suggest. You need to step away from your codeuynd just figure out what's going on with your network. Can you get out in general...like to the main google site? Are you working at a company that might be blocking certain outgoing connections? That's often what this sort of thing is about.

– Steve
Mar 28 at 3:20





@chrisTina, so telnet doesn't work from your workstation, right? If so, then I can't think of anything more to suggest. You need to step away from your codeuynd just figure out what's going on with your network. Can you get out in general...like to the main google site? Are you working at a company that might be blocking certain outgoing connections? That's often what this sort of thing is about.

– Steve
Mar 28 at 3:20












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55367746%2fjava-send-email-stuck-with-no-exceptions%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55367746%2fjava-send-email-stuck-with-no-exceptions%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현