Category Archives: Mail

Configure Sendmail without DNS

This guide is using Sendmail version 8.13.8 on Redhat Enterprise Linux (RHEL5.2). The smart host is Microsoft Exchange server (running ESMTP service, a.k.a. Extended SMTP or Enhanced SMTP), with IP address 192.168.35.1 and registered as exch01.walkernews.net on official DNS server (though it is not used by Sendmail).

  1. Edit /etc/hosts to add IP-DNS mapping for the smart host. With /etc/hosts file, you can use a different name to refer the smart host IP. For example:
    192.168.35.1   esmtp   esmtp.walkernews.net
    
  2. Create /etc/mail/service.switch, which contains only this line:
    hosts files
    
  3. Edit /etc/mail/sendmail.cf:
    • Locate “DS” and replace it to become (replace the host name with the one you have defined in /etc/hosts file):
      DSesmtp.walkernews.net
      
    • Locate “ServiceSwitchFile” and change it to become as follow (or just add in this following line if there is no ServiceSwitchFile in sendmail.cf yet):
      O ServiceSwitchFile=/etc/mail/service.switch
      
  4. Restart Sendmail service to verify sendmail.cf configuration
    service sendmail restart
    

Now, try to send a test email, using Sendmail to relay to Microsoft Exchange server:

mail -s "Test email" walker@walkernews.net </dev/null

On Microsoft Outlook that connect to Exchange server, just press F9 to synchronize Inbox immediately.

If the Exchange server allows email relay from this particular Linux SMTP server, the test email should be delivered. Otherwise, try to use telnet to connect SMTP server for troubleshooting.

5/ Test Sendmail:

5.a/ Compose text file with the following content:

#vi tmp.txt

To: mywife@email.com

CC: abc@example.com

Subject: Test mail

From: my@email.com

And here goes the email body, test test test

 

5.b/ Then execute the command below:

#sendmail -vt < tmp.txt

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