Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup mailcatcher and run as service in CentOS

I have followed the steps in this tutorial but it wouldn't work.

https://serversforhackers.com/setting-up-mailcatcher

I did however successfully installed mailcatcher and have tested. It is working, however I can't run it as a service.

Anyone knows how to do this in CentOS? Thanks.

like image 318
TheGPWorx Avatar asked Nov 30 '25 02:11

TheGPWorx


1 Answers

All operations made by root or sudoer user.

  1. create file /etc/init.d/mailcatcher
  2. add to it this content (from https://gist.github.com/oppara/c4233b289c86e2b3cb66) :

    
    #!/bin/sh
    # chkconfig: 345 99 1
    # description: mailcatcher
    # processname: mailcatcher
    
    start() {
        echo -n "starting mailcatcher:"
        /usr/local/rbenv/shims/mailcatcher --http-ip=0.0.0.0
        return 0
    }
    
    stop() {
        killall mailcatcher
        return 0
    }
    
    case "$1" in
        start)
            start
            ;;
        stop)
            stop
            ;;
        *)
            echo $"Usage: $0 {start|stop}"
            exit 2
    esac
    
    exit 0
    
    
  3. make file executable:

    chmod +x /etc/init.d/mailcatcher
  4. add service available:

    chkconfig --add mailcatcher
  5. enable service:

    chkconfig mailcatcher on
  6. start or stop service with this command:

    service mailcatcher stop|start
like image 118
markux Avatar answered Dec 05 '25 01:12

markux