Showing posts with label qmail. Show all posts
Showing posts with label qmail. Show all posts

Sunday, March 22, 2020

Change outbound connections IP for Mail

Hello admins, the server will start to send the Spam mails due to malicious code or compromised mailbox. In that case, our outgoing IP address will get blocked by several spam filters including Gmail and other mail services.

In this case, we have to wait for a long time to get whitelisted or have to pay to be whitelisted. But if you have secondary IP addresses for your server, we can do this trick to send emails and let the main IP to whitelist automatically.

This means we will change to outbound connections from the main IP to the secondary IP address.

Important: Before proceeding with this, make sure that you have fixed the compromised code or application or mailbox. Else, your secondary IP address will also get blocked on Spam filters.

Default IP for outgoing connections can be set using ‘ip’ utility.
First of all, check how routing is configured on the server:

You can check this by the following command: -
# /sbin/ip route
159.8.30.64/28 dev bond1 proto kernel scope link src 159.8.30.66
10.105.124.128/26 dev bond0 proto kernel scope link src 10.105.124.130
169.254.0.0/16 dev bond0 scope link metric 1006
169.254.0.0/16 dev bond1 scope link metric 1007
10.0.0.0/8 via 10.105.124.129 dev bond0
default via 159.8.30.65 dev bond1
If no ‘src’ listed in ‘ip’ output for the default route, then the main IP on the interface is used for outgoing connections. You can change it using:
# /sbin/ip route change default via 159.8.30.65 dev bond1 src 5.153.43.25
Now:
# /sbin/ip route
192.168.50.0/24 dev eth1 proto kernel scope link src 192.168.50.53
169.254.0.0/16 dev eth1 scope link
default via 192.168.50.254 dev eth1 src 192.168.50.100

Note: be careful, if you set the wrong IP as the source, you lose the connection to the server.

Tuesday, October 21, 2014

Create mail account and alias by command line with parallel plesk panel

Following command is used to create mail account by Linux command line for parallel plesk panel

/usr/local/psa/bin/mail --create name@domain.com -mailbox true -passwd Pa55w0rd -antivirus in


Following command is used to create mail account by Linux command line for parallel plesk panel

/usr/local/psa/bin/mail -u name@domain.com -aliases add:alias1,alias2,alias3,alias4,alias5,alias6


Note : Change bold place as your requirement


You can use this line multiple time for create more mail accounts / alias accounts, Need to work some more for get input from text file and create mails and alias. I'll try to update soon with script.

Disabling local mail for a domain on parallel plesk panel

When we migrate mail servers with parallel plesk panel, We can use plesk migration manager.

But some case, we migrate server manualy,

Last time I faced following issue,

Server 1 : Current server
Server 2 : New Server

We had around 50 domain / subscription in our server. We planned to switch Server 1 to Server 2 one by one.

By commands & scripts, we've created all domains and mail accounts to Server 2. But we didn't change all domain MX to server 2. That means first 20 domains run in Server 2 and another 30 domains in Server 1.

In this case we got issue for deliver emails from Server 1 to Server 2 and vise-versa.

In this case problem with resolving domain

Any mail server first try to check whether domain in local server or not. If it in local server, it'll deliver mail to mail box directly. In our case both server have all 50 domains and their mail box. So it trying to deliver mails with in server. So it not reach to real location of mail box.

Solution !!! It's not a good idea to remove domains and mail account which is not usable. I've tried with disabling mail box in plesk panel. No use of it. Because it'll just stop sending mail to mail box. But local domain resolvation  won't be stop.

So I've to stop mail service for that domain, following command helped to do that.

/usr/local/psa/bin/mail --off domain.com

If you want to enable domain again, use following command

/usr/local/psa/bin/mail --on domain.com



Force Qmail to process all mails in the queue

Some times qmail not deliver mails, due to connection issue, in that case we can force qmail to send mails forcefully with following command.

This will send alarm signal to mail send.


 kill -ALRM `ps ax | grep [q]mail-send | awk '{print $1}'`


Source : Plesk support