The Easy Way to Run Your Own Mail Server

By September 24, 2012 Announcements, HowTo No Comments
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

You asked for it. You voted for it. You emailed us about it. You hit us up on Twitter and Facebook about it… and now?

We’ve implemented it. You can now install your own mail server on Jelastic. We know that a lot of you had been waiting for this: in fact, over 1500 of you voted for this feature. So, if you don’t know what a mail server is, or why it would be a good idea to be running your own, here is a quick breakdown.

your own email serverA mail server is something like the computerized equivalent of your friendly neighborhood mailman. Every email that is sent passes through a series of mail servers along its way to its intended recipient.

The major benefits you get from having a mail server are:

  • complete control over your personal mail server (usage polices can be set and enforced, incoming messages can be scanned, messages can be stored as they come in, and scanning for viruses and spam can be performed at any time);
  • privacy (the information is stored and protected by the owner of the mail server);
  • users can be added immediately (name changes can be made and even aliases can be added to existing users without any wait. It’s also a simple task to create lists of specific users for sending mass emails out to an entire group with a single click);
  • your mail is faster (you eliminate the lag time between sending and receiving messages with your own mail server);
  • mailbox charges are avoided (you don’t have to pay anyone else for mailbox usage);

The benefits of having and running your own mail server quickly add up.With Jelastic you can keep communications flowing smoothly by running your own mail server, thanks to VDS node. To do this, just follow the instructions below:

Create the environment and establish an SSH connection as described here.

Install the Mail server

We are going to show you the process of installing a mail server using Postfix as an example.

1. After establishing your SSH connection, enter in the opened console the following command:

yum install postfix

run your own email server

2. After that the installation process starts.

During this process you just need to confirm two things:

  • total download size

run own email server

  • total warning

get your own email server

3. When the installation is finished you can check if it’s been successful, just enter the following command:

echo thisistestmail | mail -s test <your_email>

get own email server

If the installation has succeeded you’ll receive a test message.

run my own email server

Send Email

1. If you want, your servers are able to use the mail server you’ve installed at VDS. You will need to set this up in the configuration file of your mail server.

For that edit file /etc/postfix/ and add these lines, adjusting a list of servers ip-address you want to allow:

mynetworks_style = host
mynetworks = < server1 IP address>, < server2 IP address>

2. After editing your config file you need to apply changes with a command:

/etc/init.d/postfix restart

3. Now you can send emails from your servers (the IPs of which you’ve stated in config file of your mail server).

You just need to add the right code with the email you want to send to the config file of your application and deploy it to the necessary environment. As an example, you can use the code given below:

package com.mkyong.common;

 import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

 public class SendMailTLS {

    public static void main(String[] args) {

        Properties props = new Properties();
        props.put(&quot;mail.smtp.auth&quot;, &quot;false&quot;);
        props.put(&quot;mail.smtp.starttls.enable&quot;, &quot;false&quot;);
        props.put(&quot;;, &quot;host&quot;);
        props.put(&quot;mail.smtp.port&quot;, &quot;25&quot;);

            try {

            Session session = Session.getInstance(props);
            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress(&quot;;));
            message.setSubject(&quot;Testing Subject&quot;);
            message.setText(&quot;Text of the message&quot;);



    } catch (MessagingException e) {
    throw new RuntimeException(e);

That’s all. Hope this was helpful for you. If so, you’ll get all the benefits of having your own mail server!

BTW, don’t forget to tell us what you want/need from Jelastic and vote for other’s ideas here.

Related articles:

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

Leave a Reply

Subscribe to get the latest updates