i am using JDK 1.8 and Eclipse Mars IDE .
I have added Javamail api in build path and also tried to enter proxy details in Window-> Preference-> Network settings-> Proxy settings. In proxy setting , i set proxy ip and other details to connect to internet.But when i run below code, exception is thrown. Please guide me , how to set up smtp server in eclipse so that i could send mail from java code in eclipse.
I run this sample code to send email from my system:
Your code specifies that the host is 172.31.1.6:8090, and by default port 25 is being used.
Set the mail.smtp.port property to specify the port:
posted 4 years ago
Thanks a lot for quick response!!
I made change in default port setting as highlighted by Ron and code is running but no result is coming on console now.
I suppose this line is not executing since next line after this send message does not print text on console. So i suppose code enter into certain deadlock as eclipse shows application is running but no response is recorded on console.
Also , i have few other doubts in this sample code like , i have not entered password for mail authentication So how this code works on authentication part. Also, IP 172.31.1.6
is proxy address of network..SO this also needs to bypassed to connect to gmail and send mail but this code doesn't ask for that credentials also.. SO this code will work then.
I found gmail alerted me when i tried to run this code by send warning mail in inbox but didn't receive email from java code..SO how to tackle this.
I ran this same code substituting my own email server and To/From addresses, and it worked fine.
I don't understand the relationship between IP address 172.31.1.6 port 8090 and Gmail. If you are trying to send through Gmail, why don't you connect directly to smtp.gmail.com?
Also, if you will be using Gmail, it is going to require password authentication and a connection over TLS (smtps).
posted 4 years ago
Thanks again Rob!!
Actually, being new to topic , it took time to understand concepts that were highlighted. I made few changes in code like added authentication and gmail settings updated, lowering down security of my gmail account so that my device could connect to gmail. Thankfully these changes worked and code is working at my end too.