Repository is archived
No commit activity in last 3 years
No release in over 3 years
The way of allow your GitLab support Email receive and parse the email content, and find Issue/MergeRequest to create reply.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 0.7.3
>= 1.0
>= 0.17.0
 Project Readme

GitLab Mail Receiver

Gem Version CI Status

The way of allow your GitLab support Email receive and parse the email content, and find Issue/MergeRequest to create reply.

中文介绍


PS: After my created this gem, GitLab have released 8.0, and it included same feature. So you don't need this.

Features

  • Receive Email reply to check Issue/MergeRequest and create comment.
  • Very easy to configure on GitLab project.
  • Cleanup the mail content.

The WorkFlow:

                 /-->  [ Notify ] ----------------> [Mail Server] <---> [Mail Client]
  { GitLab } ---/                                         ^
       ^                                                  |
       |-------< [ gitlab-mail-receiver ] <---- check --> |

Requirements

  • GitLab 7.13 (I just tested on this version.)
  • An Email can receive mail via POP3/IMAP.

Configuration

Add this gem in GitLab project Gemfile:

gem 'gitlab-mail-receiver'

Create initialize file in GitLab config/initializes/gitlab-mail-receiver.rb:

require 'gitlab-mail-receiver'

Notify.send(:prepend, MailReceiver::ReplyTo)

MailReceiver.configure do
  self.sender = 'xxx@your-mail-host.com'
  self.poll_interval = 5
  self.imap = {
    server: 'imap.your-mail-host.com',
    port: 993,
    ssl: true,
    username: 'xxx@your-mail-host.com',
    password: 'your-password'
  }
end

Run commands

$ cd gitlab
$ bundle exec gitlab-mail-receiver -h
Commands:
  gitlab-mail-receiver help [COMMAND]  # Describe available commands or one specific command
  gitlab-mail-receiver restart         # Restart Daemon
  gitlab-mail-receiver start           # Start Daemon
  gitlab-mail-receiver stop            # Stop Daemon
  gitlab-mail-receiver version         # Show version

Options:
  [--root=ROOT]
                 # Default: ./
$ bundle exec gitlab-mail-receiver start
Started gitlab-mail-receiver on pid: 59386
I, [2015-09-01T13:36:50.813124 #59387]  INFO -- : Celluloid 0.17.1.2 is running in BACKPORTED mode. [ http://git.io/vJf3J ]
...

Run in production

$ cd gitlab
$ RAILS_ENV=production bundle exec gitlab-mail-receiver start -d
pid_file: ./tmp/pids/gitlab-mail-receiver.pid
log_file: ./log/gitlab-mail-receiver.log
Started gitlab-mail-receiver on pid: 58861

NOTE: The daemon log will write to $rails_root/log/gitlab-mail-receiver.log

Stop daemon

$ bundle exec gitlab-mail-receiver stop
Stoping gitlab-mail-receiver... [OK]

Daemon Signals

gitlab-mail-receiver has support the Unix process signal to manage the daemon.

You can use the kill command to send the signal to the master process.

  • USR2 - Hot reload processes.
  • QUIT - Stop processes.
$ ps aux | grep gitlab-mail-receiver
git      15488  0.2  0.2 612612 242920 pts/3   Sl   14:24   0:16 gitlab-mail-receiver [worker]
git      16320  0.0  0.0 309100 43004 pts/3    Sl   11:54   0:00 gitlab-mail-receiver [master]
$ kill -USR2 15488