Port 587 (submission) is used for secure connection (SMTP over STARTTLS). if you use port 587, your application must send STARTTLS command (after EHLO/HELO) to establish secure connection. If your application doesn't support this, use port 25 instead.
WARNING: With port 25, username and password are sent in plain text.