Connection to MS Exchange server using JavaMail hangs - smtp

(If this is a duplicate question, please send me a link to the appropriate thread.)
I wrote a Java program using JavaMail API to send an email to several users through Gmail and it worked perfectly. However, when I tried to use the same code (with slight modification) to use MS Exchange Server to send emails, the program hangs.
It did not throw any exceptions, so I am assuming that it is able to make the connection. (I had tried using other ports or wrong SMTP address and it gave me a 'Connection refused' exception.)
This was the last statement and the program does not terminate after that:
[DEBUG SMTP: trying to connect to host "[xxx.yyy.com]", port 135, isSSL false]
Please understand that I do not need help with the code, but I just want to understand what's going on.
I appreciate your time.

You need to connect to port 25 for SMTP, not port 135. (SMTPs is port 465.)

Related

Talend open studio send gmail mail

my job contains a simple tSendMailCompenent
the configuration are as follow:
smtp host = smtp.gmail.com
smtp port = 465
beside the user name, email to, ...
also, I have allowed a less secure app for the Gmail account sending
the problem is after I run the job, the Talend hang up the job is running forever
I've never seen this component hang. It usually returns quickly if there is an issue.
Have you tried creating a simple Job with just the component so that you can establish that it is this component, on it's own, at fault?

Greenmail standalone smtp server email error

I started a standalone Greenmail SMTP server with the following configurations in root mode so that i can use 25 port,
java -Dgreenmail.setup.all -Dgreenmail.users=test1:pwd1 -Dgreenmail.hostname=10.107.45.11 -jar greenmail-standalone.jar
I am able to connect to this mail server on port 25 and send an email (from telnet as well as a java program) without any error.
But when i try to find the email I sent (using a java program), it comes out as 0 always.
Received emails is always zero.
I am not sure if Greenmail can be used in this manner as a standalone server.
Can anyone please help?
After much of trying, I understand that the "INBOX" from which we need to fetch the messages is tied to the username and the following invocation of standalone greenmail jar gives you the emails that you expect to receive.
We need to pass the username, password and To-email address for it work seamlessly.
Also, specifying the ports separately makes it much easier to customize.
java -Dgreenmail.smtp.port=25 -Dgreenmail.imap.port=143 -Dgreenmail.users=test1:pwd1#10.107.45.11 -Dgreenmail.hostname=10.107.45.11 -jar greenmail-standalone-1.5.3.jar

Sending test mail fails in confluence

I need to evaluate notification functionality in confluence.
I have installed confluence locally on my PC.
I have configured mail server in it by going to General Configuration->Mail Servers->Add a new SMTP mail server
I have provided smtp.office365.com as Server Host Name and 587 as Server port.
I have used my company user id as User name and corresponding password.
However when I try to send a test mail, it fails with below exception
"Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.office365.com, port: 587" and also we have tried to configure our smtp server and getting error as "Caused by: java.net.SocketException: Permission denied: connect"
I have seen accepted answers for this question at post https://answers.atlassian.com/questions/139025/error-while-configuring-mail-server
However that is related to a bug Java1.7 whereas I am using Java1.8.
Can someone please suggest any idea what thing can be wrong?
Looking at the hostname it seems that the mail server is in the internet. If you are behind a proxy you will need to configure this in the java options as described here
https://confluence.atlassian.com/doc/configuring-web-proxy-support-for-confluence-117068.html

Implementing an intelligent relay with an SMTP server/client

I need to implement an intelligent mailing list/relay (on Linux). The idea is that:
The server receives emails to a list address
It parses the mail, and confirms that it's from a trusted source
It looks up a list of recipients in a local database
It does some minor processing on the incoming mail, and sends it out to the list
It returns any bounce messages to the original sender
The server already has sendmail installed, but I can use another MTA if necessary.
This sounds straightforward, and sendmail already has a database look-up capability. However, I don't think this is particularly flexible, and I don't want to give sendmail independent access to my database.
The closest I've come to an existing solution is E-MailRelay, which looks good, but I don't want the overhead of integrating it if I can avoid it.
I'd appreciate a sanity check on my Plan B before starting it, or alternative suggestions. I haven't found any useful docs on this and the Sendmail book doesn't seem to have anything relevant in it.
What I'm thinking about is:
Implement an SMTP delivery agent for sendmail, and have sendmail and the DA running on the same server, with the DA listening on some unspecified port (which?)
Sendmail presumably acts as an SMTP client when connecting to the DA, and my DA will respond to MAIL/RCPT/DATA commands
The DA processes the received mail, which will be either a message out to the mailing list, or a bounce, or possibly a response
The DA then switches to client mode, connects to sendmail, and issues MAIL/RCT/DATA commands to return the response to the original sender
Does this make sense? Thanks.
This turned out to be pretty straightforward, although I didn't use a sendmail delivery agent - I just did everthing in SMTP. The server has two IP addresses, and sendmail is already listening on port 25 on IP#1.
I wrote an SMTP proxy which listens on port 25 on IP#2. This runs an SMTP server, which accepts incoming messages, and re-writes them. It then connects (as a client) to port 25 on IP#1, sending the re-written message to sendmail. sendmail then handles transmission to the re-written destination addresses. This is all transparent to the original mail client.
Not sure how I'd do this if the server only had one IP address, though.

Connecting to HTML5 Websocket

I'm a bit confused about HTML5 Websockets. I've looked at numerous tutorials out there and a lot of them have different variations of connecting using different ports. What do these ports mean?
Adobe for instance, uses this:
new WebSocket('ws://localhost:1740');
Then another tutorial has this where no ports are required:
new WebSocket("ws://www.websockets.org");
And finally a third tutorial has a port, but it's completely different:
new WebSocket("ws://localhost:8080/echo");
My question would be, why do these vary? How do I know which ports to connect to? Also, I've attempted to do my own connection:
var ws = new WebSocket("ws://test.ontarget-network.com/");
But I get the following error: Unexpected response code: 200
I've tested around and tried connecting to various other "ports" (not knowing what I'm doing obviously, typing in random numbers) and this error would disappear, however, my code
ws.onopen = function(){
alert("Connection Established");
};
would not execute.
I'm trying to fully understand HTML5's Websockets API so I can experiment and create more dynamic applications. Thanks for the help.
The server should have an endpoint that accepts WebSocket connections. So, if that endpoint is /echo you would want to connect to:
ws://localhost:8080/echo/websocket
You will get the Unexpected response code: 200 error if you exclude the /websocket suffix after the endpoint. I was having the same confusion and this link cleared things up a bit for me.
The following comes from the latest WebSocket draft:
By default the WebSocket protocol uses port 80 for regular WebSocket
connections and port 443 for WebSocket connections tunneled over TLS
[RFC2818].
Really though, you should be able to use any valid port not in use. As long as clients are trying to connect to the same port that the server-side script opens for the socket connection, you should be fine.
A quick note on ports:
Port 80 is the HTTP port.
Port 8080 is the alternate HTTP port.
Port 443 is the HTTPS (i.e., HTTP with TLS) port.
Port 1740 in the Adobe code seems like some random port not already in use by other services.
For a full list of preset ports, please see the following:
http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
As for your "Unexpected response code: 200" error, I'm guessing that the WebSocket URL you're using on the client side is not pointing to a valid server-side script, but that's hard to comment on without more info.
I had the same issue, But to survive with
Unexpected response code: 200
You need to have either server-side script to handle the web socket, or you can use Node.js to build a you server script.
for the sake of education you can try to biuld your own websocket sever script.
Actually there is something else... You can not open a connection to every port since there is a list of blocked ports in every browser. I remember seeing the full list of ports in 'The tangled Web' from Michal Zalewski; however, I think a quick google will show this also.