Fixing Exim error “the account or domain may not exist, they may be blacklisted”

If you have ever ran into the error

The mail server could not deliver mail to XXX The
account or domain may not exist, they may be blacklisted, or missing the
proper dns entries.

The first instinct is to think the domain name does not exist or does not have a MX record. Many times this is the case. A quick check with a dig will show the error

dig mx domain.com

For example

Code:
dig mx test.com

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-20.P1.el5_8.2 <<>> mx test.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 65271
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;test.com.                      IN      MX

;; Query time: 19 msec
;; SERVER: 64.20.34.50#53(64.20.34.50)
;; WHEN: Thu Aug 16 11:35:49 2012
;; MSG SIZE  rcvd: 26

This has no mx record. Here is an example with one

Code:
dig mx is.cc

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-20.P1.el5_8.2 <<>> mx is.cc
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48908
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;is.cc.                         IN      MX

;; ANSWER SECTION:
is.cc.                  14400   IN      MX      0 mx.interserver.net.

;; Query time: 104 msec
;; SERVER: 64.20.34.50#53(64.20.34.50)
;; WHEN: Thu Aug 16 11:36:26 2012
;; MSG SIZE  rcvd: 57

If you checked and there is no MX record, nothing further can be done. That means the remote domain does not expect mail. Nothing you can do there. But lets say you get something else back like an IP address. Here is a remote mail server that came back with an IP address

Code:
dig mx bene-care.com

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-20.P1.el5_8.2 <<>> mx bene-care.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57894
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;bene-care.com.                 IN      MX

;; ANSWER SECTION:
bene-care.com.          900     IN      MX      10 97.107.162.211.

;; Query time: 538 msec
;; SERVER: 64.20.34.50#53(64.20.34.50)
;; WHEN: Thu Aug 16 11:33:47 2012
;; MSG SIZE  rcvd: 61

Whats the difference you say? The IP address is not a valid MX record. Now, some mail software will deliver to the above address but if properly configured and following the RFC for mail email will fail. Obviously your clients probably want mail delivered to the server even if the remote mail server is misconfigured.

To allow exim to deliver to a mail server on an IP using a misconfigured MX record add

Code:
allow_mx_to_ip = yes

to /etc/exim.conf
And then restart exim. On cpanel you can use the exim configuration editor to add this in.

 

Cpanel:

Goto Exim configuration in Cpanel => Advance Editor => Add Additional Setting

allow_mx_to_ip = yes

Leverage browser caching

What is browser caching?

Every time a browser loads a webpage it has to download all the web files to properly display the page. This includes all the HTML, CSS, javascript and images.

Some pages might only consist of a few files and be small in size – maybe a couple of kilobytes. For others however there may be a lot of files, and these may add up to be several megabytes large. Twitter.com for example is 2mb+.

The issue is two fold.

  1. These large files take longer to load and can be especially painful if you’re on a slow internet connection (or a mobile device).
  2. Each file makes a separate request to the server. The more requests your server gets simultaneously the more work it needs to do, only further reducing your page speed.

Browser caching can help by storing some of these files locally in the user’s browser. Their first visit to your site will take the same time to load, however when that user revisits your website, refreshes the page, or even moves to a different page of your site, they already have some of the files they need locally.

This means the amount of data the user’s browser has to download is less, and fewer requests need to be made to your server. The result? Decreased page load times.

How does it work?

Browser caching works by marking certain pages, or parts of pages, as being needed to be updated at different intervals. Your logo on your website, for instance, is unlikely to change from day to day. By caching this logo image, we can tell the user’s browser to only download this image once a week. Every visit that user makes within a week would not require another download of the logo image.

By the webserver telling the browser to store these files and not download them when you come back saves your users time and your web server bandwidth.

Why is it important?

The main reason why browser caching is important is because it reduces the load on your web server, which ultimately reducing the load time for your users.

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##

Enable gzip compression

What is gzip compression?

When a user hits your website a call is made to your server to deliver the requested files.

The bigger these files are the longer it’s going to take for them to get to your browser and appear on the screen.

Gzip compresses your webpages and style sheets before sending them over to the browser. This drastically reduces transfer time since the files are much smaller.

In terms of cost versus benefit, gzip compression should be near the top of your page speed optimizations if you don’t have it setup already.

How does it work?

Gzip is actually a fairly simple idea that is extremely powerful when put to good use. Gzip locates similar strings within a text file and replaces those strings temporarily to make the overall file size smaller.

The reason gzip works so well in a web environment is because CSS files and HTML files use a lot of repeated text and have loads of whitespace. Since gzip compresses common strings, this can reduce the size of pages and style sheets by up to 70%!

Gzip has to be enabled on your webserver which is relatively straight forward.

When a browser visits a webserver it checks to see if the server has gzip enabled and requests the webpage. If it’s enabled it receives the gzip file which is significantly smaller and if it isn’t, it still receives the page, only the uncompressed version which is much larger.

Why Is It Important

The main reason it is important is because it reduces the time it takes for a website to transfer the page files and style sheets which ultimately reduces the load time of your website.

For Apache

You will need to add the following lines to your .htaccess file:

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

Use of nohup command to keep process running even after you logged out

Using Nohup

Use the nohup command to keep a process running in the background after you logout.

$ nohup cmd &

For example, suppose you use the tar command to backup the database dump file from /export directory to a tape, /dev/rmt/0.

$ tar cvf /dev/rmt/0 /export > tar_log &

In this example, standard output is redirected to the file tar_log. If you logout before the command finishes executing, it will stop the process and your backup will not be completed. However, precede the tar command with the nohup command and the backup will finish even if you logout.

$ nohup tar cvf /dev/rmt/0 /docs > tar_log &

This is very useful option if you want to avoid interruption due to network failure.

Enable HTTP Keep-Alive

  1. Keep-Alive is enabled by explicitly requesting it via HTTP header.If you don’t have access to your web server configuration file, you can add HTTP headers yourself by using .htaccess file.

    The .htaccess file is a configuration control file that will take effect when placed in any directory, which is in turn loaded via the Apache server. You may create .htaccess file using any text editor such as a TextPad or gedit (Linux). It’s a method to reconfigure your website without altering the server configuration file. This is done by overriding it’s original configuration without having to restart the web server when changes are made.

    Here is the code:

    <IfModule mod_headers.c>
    Header set Connection keep-alive
    </IfModule>

    Adding this code to your .htaccess file will include Keep-Alive headers to your requests, and doing so will override any higher settings.

    Note: Test your website for errors after editing .htaccess file.

  2. If you are able to access your Apache configuration file (httpd.conf), you can turn on keep-alive there.Keep-Alive must be enabled automatically with every fresh Apache server installation. If it isn’t enabled (for some unexpected reason), there is a way to enable Keep-Alive by just editing few settings in the Apache configuration file as described below.

3 PROPERTIES THAT AFFECT KEEP-ALIVE FUNCTIONALITY

  1. KeepAliveUse “KeepAlive On” to enable it.

    To disable, just use “KeepAlive Off”.

  2. MaxKeepAliveRequests

    It sets the maximum number of requests for every Keep-Alive connection.

    A value of 100 is normally good enough for almost any scenario. This value, however, should be increased depending on the amount of files within a web page that the server is supposed to deliver.

  3. KeepAliveTimeout:

    This setting prevents unused connections from hanging around for too long. It sets how long your server should wait for new requests from clients.

    A value between 7 to 10 seconds is usually ideal. With higher traffic this value can go extremely higher to make sure there is no frequent TCP connection re-initiated. If this value goes down too much, Keep-Alive loses it’s purpose!

Response Header Example

Here’s an example of a Keep-Alive response header:

Message Trace:
-------------------------------------------
~$ curl -I https://www.domain.com/file.html
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
Date: Thu, 15 Jan 2015 16:45:29 GMT
Content-Length: 1845
Keep-Alive: timeout=10, max=20
Server: Apache/2.4.9 (Unix) PHP/5.6.2
-------------------------------------------

The server determines to maintain a persistent connection for 20 more transactions or until it has been idle for 10 seconds.

BENEFITS OF HTTP KEEP-ALIVE

  • Reduced CPU Usage: Creating new TCP connections can take a lot of resources such as CPU and memory usage. Keeping connections alive longer can reduce this usage.
  • Web page speed: The ability to serve multiple files using the same connection can reduce latency and allow web pages to load faster.
  • HTTPS: HTTPS connections (content over Secure Socket Layer) are very resource intensive. So it is highly recommended to enable Keep-Alive for HTTPS connections and maybe spice it a bit with
    SPDY.

CONCLUSION

All modern browsers use persistent connections as long as the server is willing to cooperate. Check your application and proxy server configurations to make sure that they support Keep-Alive. You need to pay close attention to the default behavior of HTTP libraries as well.

You may also use HTTP/1.1, where Keep-Alive is implemented differently and the connections are kept open by default. Unlike HTTP/1.0 keep-alive connections, HTTP/1.1 connections are always active. HTTP/1.1 assumes all connections are persistent unless the response contains a “Connection: close” header. But not sending “Connection: close” does not mean that the server maintains the connection forever and it’s still possible for the connection to be dropped