Jira/Confluence will generate email notifications for various events or an issue added to it.
These are useful if they utilized correctly and are limited in number. However the default configuration for email notifications in Jira/Confluence will send too many emails which may block port 25 by service providers. SSH tunneling can be considered as a workaround for this situation. An SSH tunnel is simply a tunnel created by logging into another SSH server at the same time configuring a local port and a remote output host and a port. This tunnel runs through SSH connection, which provides a secure layer for the data transfer to and from the SSH server. It provides data compression too.SSH tunnel will work only if we maintain a connection to a remote SSH server. If we disconnect from remote SSH server or quit the SSH session, the tunnel goes down and mail can’t be sent from server.

We need to use an SSH tunnel to connect to another server(server-2.com) in order to use that server’s SMTP server (port 25). We need to create a tunnel to server, which will be listening to port 2525 of first server.

================================

$ssh -f user@server1.com -L 2525:server2.com:25 -N
The -f instructs ssh to go into the background before it executes the command.
the -N instructs OpenSSH to not execute a command on remote server(server2.com).
================================

After executing above mentioned commands in terminal, we need to modify our outgoing email configuration in JIRA/CONFLUENCE to use our local “SMTP” as localhost:2525. Then the mails sent from server1.com will be tunneled to server2.com and will be routed from there, like it was sent from that server itself (server2.com).

In JIRA perform the following:
—————-
Log in as admin with the JIRA System Administrators global permission.
Select -> System -> Mail -> Outgoing Mail
Edit link at the right to edit the existing SMTP mail server, Change hostname to localhost and SMTP port to 2525 and save the modification.

In CONFLUENCE perform the following:
—————–
Select Confluence Administration -> General Configuration ->Mail Servers
then edit an existing mail server setting and Change hostname to localhost and SMTP port to 2525 and save configuration

Click Send Test Email in JIRA/CONFLUENCE to check that the mail configuration is working, and make sure that you get the test email in your inbox.