Hi,

I have a program which until a few days ago was working fine! It would send an email from my gmail account to another email address, perfect! All of a sudden though its stopped working and just times out with the below error message:

Exception in thread "main" java.lang.RuntimeException: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465;
nested exception is:
java.net.ConnectException: Connection timed out: connect
at remindersystem.Email.main(Email.java:44)
at remindersystem.Main.main(Main.java:31)
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465;
nested exception is:
java.net.ConnectException: Connection timed out: connect
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTra nsport.java:1934)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SM TPTransport.java:638)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
at remindersystem.Email.main(Email.java:38)
... 1 more
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl .java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSoc ketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.j ava:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.j ava:366)
at java.net.Socket.connect(Socket.java:525)
at java.net.Socket.connect(Socket.java:475)
at com.sun.mail.util.SocketFetcher.createSocket(Socke tFetcher.java:288)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFe tcher.java:231)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTra nsport.java:1900)
My code is as follows (obviously i've removed my real email addresses here and password!)

import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
 
public class Email {
 
	public static void main(String emailtitle, String emailmsg) {
 
		Properties props = new Properties();
		props.put("mail.smtp.host", "smtp.gmail.com");
		props.put("mail.smtp.socketFactory.port", "465");
		props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
		props.put("mail.smtp.auth", "true");
		props.put("mail.smtp.port", "465");
 
 
		Session session = Session.getDefaultInstance(props,
			new javax.mail.Authenticator() {
				protected PasswordAuthentication getPasswordAuthentication() {
					return new PasswordAuthentication("myemailgmail.com","mypassword");
				}
			});
 
 
		try {
 
			Message message = new MimeMessage(session);
			message.setFrom(new InternetAddress("myemail@gmail.com"));
			message.setRecipients(Message.RecipientType.TO,
					InternetAddress.parse("sendingto@hotmail.co.uk"));
			message.setSubject(emailtitle);
			message.setText(emailmsg);
 
			Transport.send(message);
 
			System.out.println("Done");
 
		}
                catch (MessagingException e) {
			throw new RuntimeException(e);
		}
	}
}

I've posted this in the network forum but to be honest that doesn't really get much of a look compared to the general one and im kinda at a dead end with this! Thanks for your patience and help!