# [solved]need a working exim.conf

## maverick6664

Hi,

I am trying to use exim as the mta.   However, I cannot make a working exim.conf.  Anyone help me?

Mail messages are coming in, but no mail messages go out..  :Sad: 

----------

## Sysa

 *maverick6664 wrote:*   

> Hi,
> 
> I am trying to use exim as the mta.   However, I cannot make a working exim.conf.  Anyone help me?
> 
> Mail messages are coming in, but no mail messages go out.. 

 http://www.exim-new-users.co.uk/content/view/135/39/

----------

## maverick6664

Thank you, but it doesn't reach my yahoo account.   In the log

```
2011-02-09 07:54:34 1PmwSA-0007MZ-Qs <= xxxxxx@xxx.sytes.net U=tetsuji P=local S=348

2011-02-09 07:54:35 1PmwSA-0007MZ-Qs == xxxxxxxxxx@yahoo.com R=dnslookup T=remote_smtp defer (-53): retry time not reached for any host
```

Any idea?

Thanks!

----------

## maverick6664

Current my exim.conf is as follows:

```
# start of /etc/exim/exim.conf

######################################################################

#                       EXIM CONFIGURATION                           #

######################################################################

acl_smtp_rcpt   =       acl_check_rcpt

######################################################################

#                       ACL CONFIGURATION                            #

######################################################################

begin acl

acl_check_rcpt:

 

  accept  domains       = xxx.sytes.net : maverick

  endpass

  verify        = recipient

  accept  hosts         = 127.0.0.1 : 10.0.0.0/8 : 192.168.0.0/16

  deny    message       = relay not permitted

######################################################################

#                      ROUTERS CONFIGURATION                         #

######################################################################

begin routers

dnslookup:

  driver = dnslookup

  domains = ! xxx.sytes.net:!maverick

  transport = remote_smtp

  ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8

  no_more

localuser:

  driver = accept

  check_local_user

  transport = local_delivery

  cannot_route_message = Unknown user

######################################################################

#                      TRANSPORTS CONFIGURATION                      #

######################################################################

begin transports

remote_smtp:

  driver = smtp

local_delivery:

  driver = appendfile

  file = /var/spool/mail/$local_part

  delivery_date_add

  envelope_to_add

  return_path_add

  group = mail

  mode = 0660

######################################################################

#                      RETRY CONFIGURATION                           #

######################################################################

begin retry

# Address or Domain    Error       Retries

# -----------------    -----       -------

*                      *           F,2h,15m; G,16h,1h,1.5; F,4d,6h

# end of /etc/exim/exim.conf
```

(some parts are hidden by xxx).

----------

## gerdesj

Try the following:

exim -bV 

This will verify the state of your configuration file ie it checks for consistency eg typos etc.  Always use it after a config change.

exim -bhc 1.1.1.1

This will startup a dummy smtp session pretending to come from outside.  Type in the following and read the output carefully.  You need to set a real internal address in the rcpt to.  The helo is not a typo - there is only one L.  You can use anything instead of "me".  The mail from address can be anything at all. There is a dot at the end of the data - period or full stop depending on your variety of English  :Cool: 

```

helo me

mail from:any-old-person@example.co.uk

rcpt to:a-valid-internal-address@yourdomain.co.uk

data

hello me

.

```

Next do the same again but this time use a valid internal ip address after -bhc and you can also try -bhc 127.0.0.1 to test mail coming from the box itself.  Make sure you use the addresses in the correct order, now you are testing outgoing mail, you need to use internal mail addresses as the mail from:.  You can also deliberately use invalid internal addresses in these tests to see what Exim does with invalid addresses.   

This command is a really useful way of testing an Exim config before you commit it.  Once you are happy it is working, then you restart Exim.

From your log posting it looks like either Yahoo is not accepting your mail or your DNS is not working or someone is filtering port 25 somewhere.

Run:

#dig yahoo.com MX

And check the output.

If you don't have it installed then emerge bind-tools

If you get a response back with DNS names then try this:

#telnet m.mx.mail.yahoo.com 25

Trying 66.94.238.147...

Connected to m.mx.mail.yahoo.com.

Escape character is '^]'.

220 mta1458.mail.mud.yahoo.com ESMTP YSmtp service ready

That should get you on track.

Cheers

Jon

----------

## maverick6664

gerdesj,

Thank you for descriptions.  My exim partially works; I can receive email from outside.   I cannot send email to outside.   Internal email (within this box) is possible.  

exim -bV

works fine.

exim -bhc (my ip address)

also works fine.  Instead it looks like this

```
**** SMTP testing session as if from host xxx.xxx.xxx.xxx

**** but without any ident (RFC 1413) callback.

**** This is not for real!

>>> host in hosts_connection_nolog? no (option unset)

>>> host in host_lookup? no (option unset)

>>> host in host_reject_connection? no (option unset)

>>> host in sender_unqualified_hosts? no (option unset)

>>> host in recipient_unqualified_hosts? no (option unset)

>>> host in helo_verify_hosts? no (option unset)

>>> host in helo_try_verify_hosts? no (option unset)

>>> host in helo_accept_junk_hosts? no (option unset)

220 xxxx.xxxxx.net ESMTP Exim 4.74 Mon, 14 Feb 2011 09:01:11 +0900

```

Is this good?

and in addition,

telnet m.mail.yahoo.com 25

works fine.

----------

## gerdesj

How are you getting on with this?

Did you do the whole exim -bhc thing, you only posted the output from the first part. It will actually tell you exactly what it will do to the email but there is rather a lot of output! 

Cheers

Jon

----------

## maverick6664

To tell the truth, I'm stuck.   I have already been able to send email to my box.

But I'm at a loss how I can test if exim can relay email to other email addresses....  :Sad: 

----------

## maverick6664

Here's what I did.

```

$ exim -bh 127.0.0.1     

**** SMTP testing session as if from host 127.0.0.1

**** but without any ident (RFC 1413) callback.

**** This is not for real!

>>> host in hosts_connection_nolog? no (option unset)

>>> host in host_lookup? no (option unset)

>>> host in host_reject_connection? no (option unset)

>>> host in sender_unqualified_hosts? no (option unset)

>>> host in recipient_unqualified_hosts? no (option unset)

>>> host in helo_verify_hosts? no (option unset)

>>> host in helo_try_verify_hosts? no (option unset)

>>> host in helo_accept_junk_hosts? no (option unset)

220 xxxx.sytes.net ESMTP Exim 4.74 Wed, 16 Feb 2011 13:52:57 +0900

HELO xxxx.sytes.net

>>> xxxx.sytes.net in helo_lookup_domains? yes (matched "@")

>>> looking up host name for 127.0.0.1

>>> IP address lookup yielded localhost

>>> gethostbyname2 looked up these IP addresses:

>>>   name=xxxx.sytes.net address=::1

>>>   name=xxxx.sytes.net address=127.0.0.1

>>> checking addresses for localhost

>>>   ::1

>>>   127.0.0.1 OK

250 xxxxx.sytes.net Hello localhost [127.0.0.1]

MAIL FROM: xxxxxxxxxxxxx@xxxx.sytes.net

250 OK

RCPT TO: xxxxxxxxxxxxxxx@yahoo.com

>>> using ACL "acl_check_rcpt"

>>> processing "accept"

>>> check domains = xxxx.sytes.net : maverick

>>> yahoo.com in "xxxx.sytes.net : maverick"? no (end of list)

>>> accept: condition test failed

>>> processing "accept"

>>> check hosts = 127.0.0.1 : 10.0.0.0/8 : 192.168.0.0/16

>>> host in "127.0.0.1 : 10.0.0.0/8 : 192.168.0.0/16"? yes (matched "127.0.0.1")

>>> accept: condition test succeeded

250 Accepted

DATA test

501 unexpected argument data   (This must be my mistake)

DATA

354 Enter message, ending with "." on a line by itself

test

test

>>> host in ignore_fromline_hosts? no (option unset)

.

LOG: 1PpZU7-0000bE-4V <= xxxxxxxxxx@xxxx.sytes.net H=localhost (xxxx.sytes.net) [127.0.0.1] P=smtp S=231

250 OK id=1PpZU7-0000bE-4V

**** SMTP testing: that is not a real message id!

quit

221 xxxx.sytes.net closing connection

```

But I didn't receive this email...I see nothing wrong in the above session.  And as a matter of course, this session isn't logged.

----------

## gerdesj

I note you had a little trouble with the data part - you end an email with a "." on its own line - really that's what a mail server actually does! So after typing the content of the "email" hit enter, then type a . and then enter again.  

If you want to create a subject header then after typing in data (enter) type in subject:  then the subject followed by enter and then the body of the message.  That way you can test any rules that you put in relating to subject lines.

Now let's see what is happening.   If I run a similar test on my production mail system, I get the same as you logged at the end.  So all that seems fine.

So you have tested that your email would be received by Exim.  The -bhc obviously cannot test the remote mail system.

Could you now try this:

```

exim -bt user@yahoo.com

```

I get:

```

exim -bt user@yahoo.com

user@yahoo.com

  router = external, transport = smtp_ext

  host c.mx.mail.yahoo.com [206.190.54.127] MX=1

  host b.mx.mail.yahoo.com [74.6.136.65]    MX=1

  host h.mx.mail.yahoo.com [66.94.236.34]   MX=1

  host d.mx.mail.yahoo.com [209.191.88.254] MX=1

  host e.mx.mail.yahoo.com [67.195.168.230] MX=1

  host j.mx.mail.yahoo.com [66.94.237.64]   MX=1

  host f.mx.mail.yahoo.com [98.137.54.237]  MX=1

  host l.mx.mail.yahoo.com [74.6.136.244]   MX=1

  host a.mx.mail.yahoo.com [67.195.168.31]  MX=1

  host g.mx.mail.yahoo.com [98.137.54.238]  MX=1

  host i.mx.mail.yahoo.com [74.6.140.64]    MX=1

  host m.mx.mail.yahoo.com [66.94.238.147]  MX=1

  host k.mx.mail.yahoo.com [98.139.54.60]   MX=1

```

That tests the routers in your configuration.  Do you get the same?  My routers and transports have different names to yours.  Please post the output.

Is your user name on your local machine the same as the one in Yahoo?  

Do you have another external email account you can test with eg (shudder) Hotmail or GMail?

You are nearly there - honest!

Cheers

Jon

----------

## maverick6664

Thanks for your help gerdesj.

My result is

```
$ exim -bt xxxxxxxx@yahoo.com

xxxxxxxx@yahoo.com

  router = dnslookup, transport = remote_smtp

  host m.mx.mail.yahoo.com [66.94.238.147]  MX=1

  host a.mx.mail.yahoo.com [67.195.168.31]  MX=1

  host k.mx.mail.yahoo.com [98.139.54.60]   MX=1

  host c.mx.mail.yahoo.com [206.190.54.127] MX=1

  host h.mx.mail.yahoo.com [66.94.236.34]   MX=1

  host l.mx.mail.yahoo.com [74.6.136.244]   MX=1

  host g.mx.mail.yahoo.com [98.137.54.238]  MX=1

  host j.mx.mail.yahoo.com [66.94.237.64]   MX=1

  host e.mx.mail.yahoo.com [67.195.168.230] MX=1

  host d.mx.mail.yahoo.com [209.191.88.254] MX=1

  host i.mx.mail.yahoo.com [74.6.140.64]    MX=1

  host f.mx.mail.yahoo.com [98.137.54.237]  MX=1

  host b.mx.mail.yahoo.com [74.6.136.65]    MX=1
```

This username isn't the same as the local username.  I tested with gmail.com, but in vain (username is different).

Thanks in advance!

----------

## gerdesj

PM sent with private details in for testing to a mail system I control.

----------

## maverick6664

PM and email messages sent.  Thanks!

----------

## maverick6664

I tested with Yahoo Japan's smtp server.

```
$ telnet smtp.mail.yahoo.co.jp 25

Trying 114.111.99.228...

Connected to smtp.mail.yahoo.co.jp.

Escape character is '^]'.

220 smtp505.mail.kks.yahoo.co.jp ESMTP

helo xxxx.sytes.net

250 smtp505.mail.kks.yahoo.co.jp

mail from: xxxxxxxxxx@xxxx.sytes.net

521 mail not accepted from this domain

Connection closed by foreign host.
```

I got my domain name from www.no-ip.com for free.......but this has MX flag and I can receive email.  I get spams everyday.   What's the problem with this domain?

Thanks in advance.

----------

## maverick6664

oops.  My mistake.   In the above message, it must be from yahoo.co.jp domain.  So my test failed.  So ignore my previous post.

sorry....

----------

## maverick6664

Thanks to gerdesj, he found my ISP gave me a blacklisted address.   So I seem to have to give up (or use free smtp server?).

Anyway thank you gerdesj and all!

----------

## gerdesj

 *maverick6664 wrote:*   

> Thanks to gerdesj, he found my ISP gave me a blacklisted address.   So I seem to have to give up (or use free smtp server?).
> 
> Anyway thank you gerdesj and all!

 

To round off the thread

If you have a static IP address, go here (for example, there are lots of others):

http://www.dnswatch.info/dns/rbl-lookup

Type in the IP address and note down the lists that have you in them.  Nearly all of them have a de-list me option.

Use something like this to check yourself every now and then (it is a Nagios plugin):

```

#!/usr/bin/perl

# Multi-RBL Query tool, developer Vikram <vr@udel.edu>

# Lightly amended by Jon Gerdes

use strict;

use Socket;

my $suspect = $ARGV[1];

my $debug   = $ARGV[2];

die "Syntax: $0 -H <ip address> [-D]\n" unless $suspect;

# Address of list!Return Code!Description

my @rblservers=qw[

        zen.spamhaus.org!127.0.0.2!SBL

        zen.spamhaus.org!127.0.0.3!SBL-CSS

        zen.spamhaus.org!127.0.0.4!XBL-CBL

        zen.spamhaus.org!127.0.0.5!XBL-NJABL

        zen.spamhaus.org!127.0.0.10!PBL-ISP

        zen.spamhaus.org!127.0.0.11!PBL-Spamhaus

        hostkarma.junkemailfilter.com!127.0.0.2!Blacklist

        bl.spamcop.net!127.0.0.2!SpamCop

];

my $spam = 0;

foreach ( @rblservers ) {

        my @rbl = split("!",$_);

        my @s = split('\.',$suspect);

        my $req = "$s[3].$s[2].$s[1].$s[0].".@rbl[0];

        my ($name,$aliases,$addrtype,$length,@addrs) = gethostbyname($req);

if ($debug) {

       print @rbl[0]." ".@rbl[1]." ".@rbl[2]."\n";

}        

        next unless (@addrs);

        

        my $result = inet_ntoa($addrs[0]);

if ($debug) {

        print " Result:".$result."\n";

}        

        if ($result eq @rbl[1]) {

                print "Critical:$suspect is listed in the following RBLS: " if ( $spam == 0 );

                print @rbl[0]." (".@rbl[1].") ".@rbl[2];

                $spam = 2;

        

        }       

}

print "OK:$suspect is not listed in any RBLS" if ( $spam == 0 );

print "\n";

exit( $spam );

```

This will get your external IP address:

```

#!/bin/bash

curl -s http://checkip.dyndns.com | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"

```

----------

## maverick6664

I'm sorry, I have a dynamic address.

Thank you!

----------

