July 14, 2015

Copy Outgoing Email on a cPanel Server with Exim

Note: It is mentioned in the comments that recent versions of cPanel include an Email Archiving feature that stores copies of email on the server for you.  If this is what you’re trying to do, this feature is probably the better option. However, if you’re trying to forward copies of outgoing email to other addresses, the instructions in this post are appropriate.
A common request we get is how a user can automatically BCC outgoing email to another address. This is most often requested by law firms that need to be able to retain copies of communication. Forwarding incoming email is easy – there’s already a section in cPanel for it. However, if you want to forward outgoing email there’s a small twist.
First, go to WHM > Exim Configuration Editor, then click “Advanced Editor” at the bottom. Don’t make any changes, just click “save”. This should create a file on the server called /etc/exim.conf.local. From command line as root, you’ll need to edit /etc/exim.conf.local and add some options to the @CONFIG@ and @TRANSPORTSTART@ sections. The end result would look like this (plus any edits you may have already made):

@AUTH@
@BEGINACL@
@CONFIG@
system_filter_directory_transport = local_copy_outgoing

@DIRECTOREND@
@DIRECTORMIDDLE@
@DIRECTORSTART@
@ENDACL@
@RETRYEND@
@RETRYSTART@
@REWRITE@
@ROUTEREND@
@ROUTERSTART@
@TRANSPORTEND@
@TRANSPORTMIDDLE@
@TRANSPORTSTART@
local_copy_outgoing:
driver = appendfile
delivery_date_add
envelope_to_add
return_path_add
group = cpaneleximfilter
user = cpaneleximfilter
mode = 0660
maildir_format = true
create_directory = true
Now, make a copy of the existing system filter file to a custom location, so cPanel updates don’t mess with it:
cp /etc/cpanel_exim_system_filter /etc/cpanel_exim_system_filter_custom
Edit /etc/exim.conf.localopts and change the “systemfilter” option to match our new file:
systemfilter=/etc/cpanel_exim_system_filter_custom
Now, open /etc/cpanel_exim_system_filter_custom and add the following block of code to the end of the file:
if $header_from: contains "@senderdomain.com"
then
unseen deliver "other@emailaddress"
endif
Replace the blue text with the sender domain (or email address) and the email address that outgoing mail should be copied to.
Apply these new settings to the exim.conf and restart:
/scripts/buildeximconf
service exim restart
Now when you send email from the email address or domain specified in the filter file, it will be copied to the other email address.

Related Posts:

  • Những điều cần thiết khi xây dựng Mail Server Có những điểm đáng lưu ý khi triển khai Email server mà không phải bất kì quản trị hệ thống nào cũng lưu tâm, hoặc biết đến, ngay cả trong các khóa đào tạo người ta cũng ít nhắc đến vấn đề này. Khi đảm bảo được máy chủ … Read More
  • các cơ chế lọc mail - cơ bản Tình trạng gửi thư rác hiện nay đang rất nghiêm trọng nên các hệ thống máy chủ mail đã được thiết lập các chính xác lọc mail rất khắt khe, điều này cũng gây ảnh hưởng không mong muốn đối với những email hợp pháp. Một email… Read More
  • Cài đặt Postfix SMTP client trên Shinken Server để gửi mail Tại Shinken host: Cài đặt các gói cần thiết: sudo apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules -y Sau đó postfix sẽ yêu cầu khai báo một số thông số, ta chọn Internet Site và điền một doma… Read More
  • Một số kinh nghiệm khi thiết lập email server Sau 1 thời gian  vật lộn với postfix + dovecot để tạo được email server cho chính bản thân mình, tôi cũng đã học được khá nhiều điều và bên dưới là một số kinh nghiệm mà tôi nghĩ là quan trọng nhất để xây dựng được emai… Read More
  • Xây dựng mail server postfix và quản lý email bằng php mysql Trước đây tôi đã có một bài viết hướng dẫn triển khai mail server đơn giản trên hệ điều hành linux, sử dụng các user của hệ điều hành làm email account. Nay tôi tiếp tục phát triển hướng này và chia sẻ cách để có thể quản lý… Read More

0 comments:

Post a Comment