How to get PMG to work with WHM/Cpanel?

bari86

New Member
Apr 2, 2021
7
1
3
38
Hi. I want Proxmox Mail Gateway to sit in front of the WHM/Cpanel and filter out all the spam for both incoming and outgoing email first. I can't find any good step by step tutorial on how to do it. So far, I have a bit and pieces together but not sure it will work. What I know I must do are as below. Please see if its correct or piece it up altogether.

1) To use Smarthost features. In WHM, I need to put in the hostname of my PMG as smarthost. This is under Exim Configuration Manager settings. I put in
* myproxmoxhostname.com

2) In Proxmox > Mail proxy > Relaying, I need to add smarthost hostname and port. I presume this would be WHM hostname and port? Or what would the actual data here would be?

3) In Proxmox > Mail proxy > Relay domains, I need to add all the domain from Cpanel. This needs a custom job as there is no way of automating this out of the box. I know that WHM have API and I can use API to either call something like this below:

Code:
whmapi1 listaccts |grep domain

Or, I can read the domain list using the command below.

Code:
cat /etc/trueuserdomains
ls /etc/valiases/

I presume I need some cron setup for either solution above but I can't really get my head around it yet. Any advice?

4) In WHM, I believe I need to set Mail Routing Settings to Local exchanger in order for this to work? Am I right?

5) In WHM, I need to make the MX record (that are managed by WHM) to send the email to PMG instead. Not sure how to enable this globally for current and future clients.

I would really need some help in getting this to work. This is my first time getting PMG to work. I can't find any tutorial related to using it with WHM. Please help.
 
  • Like
Reactions: EDSON MARIO
I have no experience with WHM/CPanel - but will still try to give a few hints...
Maybe try to ask the questions in the WHM/Cpanel community (or other support-channels)

1) To use Smarthost features. In WHM, I need to put in the hostname of my PMG as smarthost. This is under Exim Configuration Manager settings. I put in
You need to use the internal port of PMG for outbound scanning (the default internal port is 26) instead of the default smtp port 25

2) In Proxmox > Mail proxy > Relaying, I need to add smarthost hostname and port. I presume this would be WHM hostname and port? Or what would the actual data here would be?
The smarthost setting in PMG is for outbound mail - if you configure it PMG will send all mail with an external destination to the smarthost
I guess you want to set your default relay (this is used for inbound mail) to the WHM/Cpanel hostname

3) In Proxmox > Mail proxy > Relay domains, I need to add all the domain from Cpanel. This needs a custom job as there is no way of automating this out of the box. I know that WHM have API and I can use API to either call something like this below:
There is no integration in PMG for CPanel, but you can use the API of PMG to add domains see:
* https://pmg.proxmox.com/pmg-docs/api-viewer/index.html (the api viewer providing a documentation of the API endpoints)
* https://pve.proxmox.com/wiki/Proxmox_VE_API (the wiki-page from the PVE wiki shows how to connect to the API (PVE and PMG are quite similar regarding this)

Regarding 4 and 5 - this is probably a question for the WHM support

Apart from that - check out the reference documentation for PMG - https://pmg.proxmox.com/pmg-docs/pmg-admin-guide.html

I hope this helps!
 
Here's how I was able to make PMG smart host for the cPanel/WHM. Now all my outbound emails from cPanel/WHM is being forwarded to the PMG and the email is sent out after my validation/check routine is done.

1. Log into the WHM
2. Navigate to Home > Service Configuration > Exim Configuration Manager and then click on the Advanced Editor Tab
3. Search for POSTMAILCOUNT and enter the following in the text field box

send_via_smart_host:
driver = manualroute
domains = !+local_domains
transport = remote_smtp
route_list = * your_pmg_FQDN::26

Note:
+ "send_via_smart_host" can be anything you like if you want to change it.
+ Change "your_pmg_FQDN" to your PMG host. You can also enter the PMG host's IP Address instead.
+ wildcard allows all emails to be forwarded to your PMG host using the port 26
 
Here's how I was able to make PMG smart host for the cPanel/WHM. Now all my outbound emails from cPanel/WHM is being forwarded to the PMG and the email is sent out after my validation/check routine is done.

1. Log into the WHM
2. Navigate to Home > Service Configuration > Exim Configuration Manager and then click on the Advanced Editor Tab
3. Search for POSTMAILCOUNT and enter the following in the text field box

send_via_smart_host:
driver = manualroute
domains = !+local_domains
transport = remote_smtp
route_list = * your_pmg_FQDN::26

Note:
+ "send_via_smart_host" can be anything you like if you want to change it.
+ Change "your_pmg_FQDN" to your PMG host. You can also enter the PMG host's IP Address instead.
+ wildcard allows all emails to be forwarded to your PMG host using the port 26
Hi,

I was able to make WHM to send out via PMG. There was some instructions for it somewhere. Yes the step is almost the same with what you wrote. What I am still not able to do is for incoming. I would love to have PMG filter out spam first, before it reaches WHM. The challenge for this is that the domain name need to be sync/added to PMG on regular basis. I know WHM have API that can do it but I have not yet be able to fully automate those.

If you know how to do it then it would be great too.
 
We are looking to implement as well ,however so far the tests have failed. Looking only to filter out emails coming to the mailbox and not for outgoing.
True that we need stronger hands in setup for cpanel.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!