{"id":2770,"date":"2015-10-20T04:13:54","date_gmt":"2015-10-20T04:13:54","guid":{"rendered":"https:\/\/qbytes.cloud\/?p=2770"},"modified":"2015-10-20T04:13:54","modified_gmt":"2015-10-20T04:13:54","slug":"email-administration-for-postfix-plesk-and-qmail","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2015\/10\/20\/email-administration-for-postfix-plesk-and-qmail\/","title":{"rendered":"Email Administration for Postfix , Plesk and Qmail"},"content":{"rendered":"<p>Basics<br \/>\nrDNS (Reverse DNS)<\/p>\n<p>The Reverse DNS for an IP should be set to the EHLO value that is sent in the outgoing mail header. This is generally the HostName of the computer.<\/p>\n<p>This value should also match the outgoing IP address used to send the mail.<\/p>\n<p>On a multi-IP server, if the sending IP does not match the EHLO domain, you may be sending from Postfix. Switching to Qmail may cause the sending IP to match the primary IP on the server, which should correct any mis-matched IP\/EHLO issues.<\/p>\n<p><!--more--><\/p>\n<p>SPF (Sender Policy Framework)<\/p>\n<p>SPF (actual TXT) records are used to verify that an email was actually sent by the email address reported. This system is used to help prevent spoofing.<\/p>\n<p>Example:<\/p>\n<p>yourwebdomain.com IN TXT &#8220;v=spf1 a mx ip4:1.2.3.4 include:thirdpartyespdomain.com -all&#8221;<\/p>\n<p>ip4: Use the IP of the server. Mismached IPs can result in errors such as the reverse domain does not match.<br \/>\nSPF for Managed Mail<\/p>\n<p>Try something like this:<\/p>\n<p>domain.com. IN TXT &#8220;v=spf1 mx include:domain.com ~all&#8221;<\/p>\n<p>or<\/p>\n<p>domain.com. IN TXT &#8220;v=spf1 mx ip4:64.150.179.75 include:domain.com ~all&#8221;<\/p>\n<p>Generally speaking, the EHLO should be the Hostname of the server. One way to discover the Hostname is to telnet into the server using Port 25<\/p>\n<p>telnet IP.AD.DR.ESS 25<\/p>\n<p>Plesk<br \/>\nMail Queue<\/p>\n<p>\/usr\/local\/psa\/admin\/bin\/mailqueuemng -s<\/p>\n<p>To see the messages<\/p>\n<p>\/usr\/local\/psa\/admin\/bin\/mailqueuemng -l<\/p>\n<p>Postfix Mail Queue<\/p>\n<p>To clear the mail queue (Postfix)<\/p>\n<p>postsuper -d ALL<\/p>\n<p>Qmail Mail Queue<\/p>\n<p>To clear the outgoing Qmail mail queue<\/p>\n<p>\/usr\/local\/psa\/admin\/bin\/mailqueuemng -D<\/p>\n<p>Qmail Delete sender\/recipt<\/p>\n<p>qmail-remove -r -p xyz.com<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"UNzYuPh6T3\"><p><a href=\"https:\/\/geeksterminal.com\/qmail-commands-logs-plesk-server\/580\/\">Qmail commands and logs in Plesk Linux server<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Qmail commands and logs in Plesk Linux server&#8221; &#8212; Geeks Terminal\" src=\"https:\/\/geeksterminal.com\/qmail-commands-logs-plesk-server\/580\/embed\/#?secret=UNzYuPh6T3\" data-secret=\"UNzYuPh6T3\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p>** Install qmail-remove<\/p>\n<p>yum install gcc gcc-c++<\/p>\n<p>wget http:\/\/www.linuxmagic.com\/opensource\/qmail\/qmail-remove\/qmail-remove-0.95.tar.gz<br \/>\ntar -zxvf qmail-remove-0.95.tar.gz<br \/>\ncd qmail-remove-0.95<br \/>\nmake<br \/>\nmake install<br \/>\ncp qmail-remove \/usr\/bin\/<br \/>\nmkdir \/var\/qmail\/queue\/yanked<\/p>\n<p>Mail Log<\/p>\n<p>cat \/usr\/local\/psa\/var\/log\/maillog | less<\/p>\n<p>cat \/var\/log\/maillog<\/p>\n<p>Passwords<\/p>\n<p>\/usr\/local\/psa\/admin\/bin\/mail_auth_view<br \/>\nmysql -uadmin -p`cat \/etc\/psa\/.psa.shadow ` psa -e &#8216;select m.mail_name,a.password,d.name from mail m,accounts a,domains d where m.account_id=a.id and m.dom_id=d.id;&#8217;<\/p>\n<p>Which script is sending mail<\/p>\n<p>http:\/\/kb.parallels.com\/1711<\/p>\n<p>Rebuild and repair mail configuration files<\/p>\n<p>Use mchk utility to repair\/rebuild all mail configuration files and restore settings for all mailboxes created in Parallels Plesk Panel.<\/p>\n<p>Usage:<\/p>\n<p>\/usr\/local\/psa\/admin\/sbin\/mchk &#8211;help<br \/>\nRestore settings for all mailboxes.<br \/>\nUsage: \/usr\/local\/psa\/admin\/sbin\/mchk [OPTION]<\/p>\n<p>OPTIONS:<br \/>\n&#8211;without-spam restore all settings except for SpamAssassin configuration<br \/>\n&#8211;with-spam restore all settings (Recommended)<br \/>\n&#8211;spam-only restore only SpamAssassin settings<br \/>\n~#<\/p>\n<p>This utility rebuilds mail server control files\u2019 mailboxes settings (including alternative servers such as Postfix in modern Plesk versions). It also sets appropriate permissions for all the related files.<\/p>\n<p>Usage example:<\/p>\n<p>\/usr\/local\/psa\/admin\/sbin\/mchk &#8211;with-spam<\/p>\n<p>Plesk Mail Folders<\/p>\n<p>The Plesk mail directories (Plesk mail directory, Plesk mail folder) are located at:<\/p>\n<p>cd \/var\/qmail\/mailnames\/<\/p>\n<p>cPanel<br \/>\nMail Log<\/p>\n<p>cat \/var\/log\/exim_mainlog | less<\/p>\n<p>Email Trace<\/p>\n<p>Exim<br \/>\nMail Log<\/p>\n<p>\/var\/log\/exim_mainlog<\/p>\n<p>Mail Queue<\/p>\n<p>\/usr\/sbin\/exim -bp<\/p>\n<p>Exim Mail Queue Count<\/p>\n<p>exim -bpc<\/p>\n<p>Clear Mail Queue<\/p>\n<p>exim -bp | awk &#8216;\/^ *[0-9]+[mhd]\/{print &#8220;exim -Mrm &#8221; $3}&#8217; | bash<\/p>\n<p>Change Sending IP<\/p>\n<p>In WHM, make sure that mailips is enabled:<\/p>\n<p>WHM &gt; Exim Configuration Manager &gt; Reference \/etc\/mailips for outgoing SMTP connections = On<\/p>\n<p>Create or edit \/etc\/mailips by logging in with SSH.<\/p>\n<p>nano \/etc\/mailips<\/p>\n<p>Set the IP for the desired domain<\/p>\n<p>domain.com: ip.add.re.ss<\/p>\n<p>Now, set the rDNS for the IP by editing \/etc\/mailhelo<\/p>\n<p>nano \/etc\/mailhelo<\/p>\n<p>domain1.com: mail.domain1.com<br \/>\nsub.domain1.com: mail.domain1.com<br \/>\ndomain2.com: mail.domain2.com<br \/>\n*: host.name.com<\/p>\n<p>To activate these changes, restart Exim<\/p>\n<p>service exim restart<\/p>\n<p>Postfix<br \/>\nMail Queue<\/p>\n<p>mailq<\/p>\n<p>Postfix Mail Queue Count<\/p>\n<p>find \/var\/spool\/postfix\/deferred\/. ! -name &#8216;?&#8217; -print | wc -l<\/p>\n<p>Disable Undeliverable and Bounced messaging<\/p>\n<p>To stop Postfix from sending Undeliverable and other bounced messages, edit the \/etc\/postfix\/master.cf file<\/p>\n<p>nano \/etc\/postfix\/master.cf<br \/>\n#bounce unix &#8211; &#8211; n &#8211; 0 bounce<br \/>\nbounce unix &#8211; &#8211; n &#8211; 0 discard<\/p>\n<p>service postfix restart<\/p>\n<p>Set the primary sending IP<\/p>\n<p>To set the primary sending IP in Postfix, you will need to edit the Postfix configuration file and add the following line<\/p>\n<p>nano \/etc\/postfix\/main.cf<\/p>\n<p>smtp_bind_address = IP.ADD.RE.SS<\/p>\n<p>service postfix restart<\/p>\n<p>\u2026 or \u2026<\/p>\n<p>nano \/etc\/postfix\/master.cf<\/p>\n<p>DOM.AIN.IP.ADD- unix &#8211; n n &#8211; &#8211; smtp -o smtp_bind_address=SEN.DIN.GIP.ADD -o smtp_bind_address6= -o smtp_address_preference=ipv4<br \/>\nDOM.AIN.2IP.ADD- unix &#8211; n n &#8211; &#8211; smtp -o smtp_bind_address=SEN.DIN.GIP.ADD -o smtp_bind_address6= -o smtp_address_preference=ipv4<\/p>\n<p>Support<br \/>\nMail not listening on Port 25<\/p>\n<p>The mailserver is able to send mail, but cannot receive. You can telnet out on port 25, but you cannot telnet in. Checking netstat -a|grep :25 shows nothing is listening. The mailserver is running and restarting it does not help.<br \/>\nSolution:<\/p>\n<p>Check that the mail server is able to connect to the port.<\/p>\n<p>In this example, filenames had been changed and needed to be corrected:<\/p>\n<p>ls -la \/etc\/xinetd.d<\/p>\n<p>smtp.psa<br \/>\nsmtps.psa<br \/>\nsubmission.psa<\/p>\n<p>Each of these needed to be renamed:<\/p>\n<p>smtp_psa<br \/>\nsmtps_psa<br \/>\nsubmission_psa<\/p>\n<p>Issue: telnet localhost 25 telnet: connect to address 127.0.0.1: Connection refused<\/p>\n<p>Cannot connect to port 25 on localhost even though Postfix is running.<br \/>\nSolution<\/p>\n<p>Postfix is broken. Let Plesk repair it<\/p>\n<p>\/usr\/local\/psa\/admin\/sbin\/mchk<\/p>\n<p>Mail not sending from Primary IP<br \/>\nIf mail is not sending out of the primary IP, there is a good chance the Plesk Version is 10.4.4+ and the mail MTA is set to Postfix. To send from the Primary IP (which should match the Hostname\/EHLO), you can change the MTA to Qmail.<br \/>\n1. Backup the Plesk Server Settings: Tools &gt; Backups<br \/>\n2. Run the Plesk AutoInstaller<\/p>\n<p>\/usr\/local\/psa\/admin\/bin\/autoinstaller<\/p>\n<p>3. Keep the version the same, the next options should allow you to select Qmail.<br \/>\nNote: Last time I installed Qmail via the AutoInstaller, it was 900MB, so it takes some time.<br \/>\nMax Connections to IMAP Server<\/p>\n<p>The server returned the error: The attempt to read data from the server \u201cmail.domain.com\u201d failed.<\/p>\n<p>or<\/p>\n<p>You may have exceeded the maximum number of connections to this server.<\/p>\n<p>Solution:<\/p>\n<p>nano \/etc\/courier-imap\/imapd<br \/>\nMAXDAEMONS=120<br \/>\nMAXPERIP=60<\/p>\n<p>nano \/etc\/courier-imap\/imapd-ssl<br \/>\nMAXDAEMONS=120<br \/>\nMAXPERIP=60<\/p>\n<p>service courier-imapd restart<br \/>\nservice courier-imaps restart<br \/>\nMax Emails Per Day<br \/>\nIf a client receives a message saying:<br \/>\n\u201cIP address blocked, max # of msgs per day reached, all outgoing blocked to prevent spam.\u201d<br \/>\nor<br \/>\n\u201cMessage denied. Your IP address has sent the maximum number of messages per day. Your outgoing messages have been blocked.\u201d<\/p>\n<p>nano \/var\/www\/atmail\/libs\/Atmail\/Config.php<br \/>\nfilter_max_msgs = &#8216;0&#8217;<\/p>\n<p>Mail Stuck in Queue<\/p>\n<p>Example from mail log: Connected_to_206.188.198.64_but_my_name_was_rejected.\/Remote_host_said:_501_5.0.0_Invalid_domain_name\/<br \/>\nSolution:<\/p>\n<p>Check the Hostname and From address. If not correctly configured (not a FQDN) the mail may not deliver.<\/p>\n<p>Postfix Mail Stuck in Queue, IPv6<\/p>\n<p>Postfix might try to send via IPv6. this is not available and messages get stuck in the queue.<br \/>\nSolution:<\/p>\n<p>nano \/etc\/postfix\/main.cf<\/p>\n<p># inet_protocols = all<br \/>\ninet_protocols = ipv4<\/p>\n<p>service postfix restart<\/p>\n<p>* It is OK to set this value by default when in a Postfix server, just in case.<br \/>\nSubdomain EMail Accounts<br \/>\nPlesk<\/p>\n<p>It is possible to setup subdomain email accounts in Plesk, IF you set the subdomain up as a TLD instead of as a subdomain of a TLD.<\/p>\n<p>Domains &gt; Create Domain &gt; sub.domain.com<\/p>\n<p>Email Address blocked by Provider<\/p>\n<p>To test if an IP is blocked by a provider, SSH into the server, then try to telnet into the provider at port 25.<\/p>\n<p>Example: IP 123.45.67.89 cannot send to Verizon.<\/p>\n<p># dig verizon.net mx<\/p>\n<p>;; ANSWER SECTION:<br \/>\nverizon.net. 136 IN MX 0 relay.verizon.net.<\/p>\n<p># dig relay.verizon.net.<\/p>\n<p>;; ANSWER SECTION:<br \/>\nrelay.verizon.net. 113 IN A 206.46.232.11<\/p>\n<p># telnet 206.46.232.11 25<\/p>\n<p>Trying 206.46.232.11&#8230;<br \/>\nConnected to 206.46.232.11.<br \/>\nEscape character is &#8216;^]&#8217;.<br \/>\n571 Email from 123.45.67.89 is currently blocked by Verizon Online&#8217;s anti-spam system. The email sender or Email Service Provider may visit http:\/\/www.verizon.net\/whitelist and request removal of the block. 121227<br \/>\nConnection closed by foreign host.<\/p>\n<p>Emails not receiving in Plesk<br \/>\nIssue: all addresses are not receiving. Able to connect and send without issue<\/p>\n<p>No address is receiving any mail. Checking the logs shows the emails do arrive.<br \/>\nSolution: Re-enable Anti-Virus in Services.<\/p>\n<p>Issue: Mail Quota Exceeded<\/p>\n<p>From the qmail error log:<\/p>\n<p>tail -50 \/usr\/local\/psa\/var\/log\/maillog<br \/>\ndelivery nnnnn: failure: Mail_quota_exceeded.\/<\/p>\n<p>Root Cause<\/p>\n<p>Check the mailbox size allowed in Plesk. Odds are it is NOT set to unlimited.<br \/>\nNow check the email users folder size<\/p>\n<p>du -sch \/var\/qmail\/mailnames\/domain.com\/*<\/p>\n<p>The result from the above is higher than the limit set in Plesk<br \/>\nSolution:<\/p>\n<p>Subscriptions &gt; domain.com &gt; Edit Configuration<br \/>\nScroll down to mail box size and change the limit to a higher value.<\/p>\n<p>Port 587 not responding (Plesk)<\/p>\n<p>Attempts to telnet the server to port 587 fail:<\/p>\n<p>Trying IP.ADD.RE.SS\u2026<br \/>\ntelnet: connect to address IP.ADD.RE.SS: Connection refused<br \/>\ntelnet: Unable to connect to remote host: Connection refused<\/p>\n<p>1. Check that the firewall is not blocking port 587.<\/p>\n<p>2. Tools &amp; Settings &gt; Mail Server Settings &gt; Enable message submission [X] (will be enabled on all IP addresses)<br \/>\nPlesk not sending to External Mail Server<\/p>\n<p>A domain is using an external mail server. Emails sent to domain off the server send fine, but email sent to domains on the server (using the external mail server) are never received.<br \/>\nSolution:<\/p>\n<p>1. If the DNS for the server is stored off the server, make sure the DNS is disabled in Plesk.<\/p>\n<p>2. Disable the mail function of the domain from the command line:<\/p>\n<p>\/usr\/local\/psa\/bin\/domain &#8211;update domain.com -mail_service false<\/p>\n<p>Issue: Postfix keeps stopping. (Incomplete!)<\/p>\n<p>Support site: http:\/\/www.unix.com\/tips-tutorials\/19060-unix-file-permissions.html<\/p>\n<p>Check the mail.err log for \u201cToo many open files\u201d<\/p>\n<p>cat \/var\/log\/mail.err | grep &#8220;Too many open files&#8221;<\/p>\n<p>If you see this, check the \/tmp folder for files created by postfix with 0 bytes and strange permissions:<\/p>\n<p>ls -la \/tmp<br \/>\n-rw-r-sr-t postfix ??? 0 ctmiPaisWB<\/p>\n<p>Issue: Intermittent SMTP connection issues with Postfix<\/p>\n<p>Load average above normal, but not insane. strange ctmilter.bin process running by postfix user using 100% CPU.<br \/>\nSolution:<\/p>\n<p>nano \/etc\/postfix\/main.cf<\/p>\n<p># smtpd_milters = inet:localhost:12768 unix:\/var\/spool\/postfix\/ctmilter\/ctmilter.sock<br \/>\nsmtpd_milters = inet:localhost:12768<\/p>\n<p>service postfix restart<\/p>\n<p>Issue: Qmail not sending from Primary IP<\/p>\n<p>The primary IP of the server was changed. Qmail should be sending out of the new primary IP, but instead is sending out of the old IP<br \/>\nSolution<\/p>\n<p>This is due to the default route still set to the original IP.<\/p>\n<p>system-config-network<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Basics rDNS (Reverse DNS) The Reverse DNS for an IP should be set to the EHLO value that is sent in the outgoing mail header. This is generally the HostName of the computer. This value should also match the outgoing IP address used to send the mail. On a multi-IP server, if the sending IP &#8230; <a title=\"Email Administration for Postfix , Plesk and Qmail\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2015\/10\/20\/email-administration-for-postfix-plesk-and-qmail\/\" aria-label=\"Read more about Email Administration for Postfix , Plesk and Qmail\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,30],"tags":[],"class_list":["post-2770","post","type-post","status-publish","format-standard","hentry","category-administration","category-emal"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/2770","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=2770"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/2770\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=2770"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=2770"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=2770"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}