# e-mail woes

## Xamot

I want to setup my home PC to send and receive e-mail. Unfortunately I am on a Dynamic IP (DSL). All my e-mail gets dropped off to my ISP POP account. Following the Desktop setup guide I got postfix running and local mail is delivered fine. Running a seperate POP client I can get all my POP mail. But what if I want everything in the same place?  Fetchmail you say? I'll work on setting that up.

But that is just half the battle. What about Sending e-mail? I can send mail locally, but externally most SMTP servers won't acknowledge a machine that doesn't reverse DNS. Can I just have postfix send everything to my ISP's SMTP? And have it rewrite the address so instead of xamot@gourami it is xamot@myisp.net?

Should I stay with postfix or is there a better MTA for this?

Thanks,

XamotLast edited by Xamot on Tue Jun 04, 2002 9:42 pm; edited 1 time in total

----------

## alec

You can get an easily-updatable hostname pretty easily - check out http://www.dns.org or maybe hammernode at http://www.hn.org - this might fix your reverse-dns problem.  My supposedly dynamic IP DSL has not changed in over a year, so I've felt safe using the 'static' option - if yours actually changes, you might want to try the more easily updatable ones.  There are clients you can run on boot that will fix things up, just check the provider's site.

Fetchmail might be what you're looking for on the recieving side - I've got my fetchmail pulling from my ISP and just tossing it in with the rest of my local mail.  If you've got a box with X on it, consider using 'fetchmailconf' - it's a graphical setup tool that comes if you have tcltk in your USE variable.

As far as MTAs are concerned, I use exim on the box that does the e-mail handling but have postfix installed on my desktop for sending.  I need to figure out that exim config to let me use it without opening it up as a relay :)

----------

## Noldar

postfix can be configured to use the mta of your ISP for outgoing mail:

relayhost = 1.2.3.4

Where 1.2.3.4 is obviously the IP of your ISPs MTA

----------

## mb

in order to receive mail on our box, you need a so called MX entry in the isp dns server....

the mx record points to a mail-server, responsible for your domain...

#mb

[edit]

or username@[ur.ip.adr.here]  <- but this is not part of the rfc imho

----------

## Xamot

 *mb wrote:*   

> in order to receive mail on our box, you need a so called MX entry in the isp dns server....
> 
> the mx record points to a mail-server, responsible for your domain...
> 
> #mb

 

Right. I have a Dyndns.org setup, and could easly add an MX record for my DNS. If I did that I'd still need to re-write the FROM: headers, from xamot@gourami.mydomain.net to xamot@mydomain.net.  How do I do that?

But I don't want to change my e-mail address YET again. Thus I will continue to get mail at my ISP's POP server. (I have no idea how to get them to forward) I hear Fetchmail works beautifully for grabbing from a POP and delivering locally. I'm setting it up right now.

----------

## opello

you don't actually need an MX record to receive mail ... if you don't have one in your DNS record, it will use the ip that it would have if you had tried to ping it, or some other event that would require resolution to an ip ...

but my problem ...

I cannot send/receive mail between local users ... I'm using postfix and pine to do this.  When I type root into pine, it changes it to <root@opello.cjb.net> and the message return sent successfully (in pine).  In my /var/log/mail I get entries like this:

```

Jul 14 13:51:36 [postfix/qmgr] 072C572441: from=<root@opello.cjb.net>, size=544, nrcpt=1 (queue active)

Jul 14 13:51:36 [postfix/qmgr] 072C572441: to=<root@opello.cjb.net>, relay=none, delay=140677, status=deferred (unknown mail transport error)

```

I am posting my main.cf file so someone can hopefully tell me what I have wrong (comments stripped off for politeness):

```

transport_maps = hash:/etc/postfix/transport

#soft_bounce = no

queue_directory = /var/spool/postfix

command_directory = /usr/sbin

daemon_directory = /usr/lib/postfix

mail_owner = postfix

#default_privs = nobody

myhostname = opello.cjb.net

mydomain = opello.cjb.net

myorigin = $mydomain

inet_interfaces = all

mydestination = $myhostname

#local_recipient_maps = $alias_maps unix:passwd.byname

alias_database = hash:/etc/mail/aliases

# recipient_delimiter = +

home_mailbox = .maildir/

# mail_spool_directory = /var/mail

# mail_spool_directory = /var/spool/mail

#mailbox_command = /some/where/procmail

#mailbox_command = /some/where/procmail -a "$EXTENSION"

#mailbox_transport = lmtp:unix:/file/name

#mailbox_transport = cyrus

#fallback_transport = lmtp:unix:/file/name

#fallback_transport = cyrus

#fallback_transport =

# luser_relay = $user@other.host

# luser_relay = $local@other.host

# luser_relay = admin+$local

#header_checks = regexp:/etc/postfix/filename

#header_checks = pcre:/etc/postfix/filename

#relay_domains = $mydestination

mynetworks_style = host

#fast_flush_domains = $relay_domains

#fast_flush_domains =

#smtpd_banner = $myhostname ESMTP $mail_name

#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)

local_destination_concurrency_limit = 2

default_destination_concurrency_limit = 10

debug_peer_level = 2

# debug_peer_list = 127.0.0.1

# debug_peer_list = some.domain

debugger_command =

    PATH=/usr/bin:/usr/X11R6/bin

    xxgdb $daemon_directory/$process_name $process_id & sleep 5

```

Thanks!

----------

## shiftzero

exactly the same problem...  :Confused: 

Almost the same here: https://forums.gentoo.org/viewtopic.php?t=66300

----------

## theFred

I had fun at first trying to get this set up.  I ended up with a slightly different combination, but it all works, and I'm also on a dynamic IP. The only real difference is that I own my own domain name which my pop accts are hosted on.  Here is what I got working for my home network.

Exim + getMail + Solid Pop3 (not in portage and required XinetD, although can be compiled as a standalone service)+procmail (really only to ease spam filtering) and of course SpamAssassin.

Exim was chosen simply because it was just as easy to get running as Sendmail even though I'd never used it before, and it supported the maildir format which I prefer over the mbox file format.

exim.conf (only pertinant sections, the rest can be considered as left at default)

------------------------------------------------------------------------------------------------

# Specify your host's canonical name here. This should normally be the fully

# qualified "official" name of your host. If this option is not set, the

# uname() function is called to obtain the name. In many cases this does

# the right thing and you need not set anything explicitly.

primary_hostname = localhost

# The next three settings create two lists of domains and one list of hosts.

# These lists are referred to later in this configuration using the syntax

# +local_domains, +relay_to_domains, and +relay_from_hosts, respectively. They

# are all colon-separated lists:

domainlist local_domains = @:localhost

domainlist relay_to_domains =

hostlist   relay_from_hosts = [wrapped text] @:localhost:192.168.5.1:192.168.0.1:127.0.0.1:192.168.5.5

------------------------------------------------------------------------------------------------

getmail I set up as a cron job, while I could have had one for each user I chose to have user:mail run them all for me from one cron job.  for this I have a i single getmailrc file under /etc/getmail  (not standard), however it made adding or change accounts a little easier as I don't have to log in as each user  (I know about su, but I"m having console problems with it and X right now so this was less of a fight)

getmailrc (whole thing)

[default]

verbose=1

[user1@mydomain.com]

username=user1

password="xxxxxx"

server=mail.mydomain.com

postmaster="|/usr/bin/procmail -d user1 2>/dev/null"

delete=1

[user2@mydomain.com]

username=user2

password="xxxxxx"

server=mail.mydomain.com

postmaster="|/usr/bin/procmail -d user2 2>/dev/null"

delete=1

-----------------------------------------------------------------------

my cron job for user mail runs once every 60 seconds it looks like this

* * * * * /usr/bin/getmail -r /etc/getmail/getmailrc

(you can adjust if you want mail checked less often)

now the postmaster above looks a little different than you may have seen before even in examples of piping mail to procmail.  Its just written that way to get around a bug I was having where procmail wouldn't return true, and it threw things out of whack and prevented getmail from feeling warm and fuzzy about deleting my emails from the server, this was the best way I could find to fix it.

now in each user directory I have a <dot>procmailrc which looks like this:

MAILDIR=$HOME/.maildir

SPAMDIR=$MAILDIR/SPAM/

DEFAULT=$MAILDIR/new

LOGFILE=$MAILDIR/procmail.log

VERBOSE=off

SHELL=/bin/bash

#Let's put announcements from the mailer-daemon in a special folder

:0:

* ^From:.*MAILER-DAEMON

$MAILDIR/Returned.mail

#

# Begin letting known good mail through

#

# Rule to catch my Mailing Lists and acceptable Commercial Mail

:0:

* ^(TO|CC).(*@perl.org|\

	(perl-beginner|cold_fusion|colderfusion)@yahoogroups.com|\

	cgi-list@jann.com|\

	*@listserv.ActiveState.com|\

	cfug@hostingplace.net|\

	cfguru@granularity.net|\

	*@houseoffusion.com|\

	*@freelancersdirect.com|\

	*@emoonlighter.com|\

	*route.monster.com|\

	*@nettemps.com|\

	*@exhedra.com|\

	*@email.caareerbuilder.com|\

	*@JAVA.SUN.COM|\

	qformsapi@yahoogroups.com)

$DEFAULT

###    Friends & Family    ###

:O

* ^FROM.(friend1@hotmail.com|\

	friend2@hotmail.com|\

	 friend3@hotmail.com)

$DEFAULT

### End Friends and Family ###

#

# Begin Spam Filtering and ORBS checks

#

### ORBS check isn't working from in here, trying SpamAssassin's ORBS search ###

### For now at least, I'd like to put it back in here later to cut processing time down ###

### Blacklist

:0

* ^From.(*@artists-server|\

	 *@art-server)

/dev/null

#

# spam-assassin check for inbox

#

DROPPRIVS=yes

:0fw

* < 256000

| /usr/bin/spamc

:0

* ^X-Spam-Flag:*YES*

$SPAMDIR

# Work around procmail bug: any output on stderr will cause the "F" in "From"

# to be dropped.  This will re-add it.

:0

* ^^rom[ ]

{

  LOG="*** Dropped F off From_ header! Fixing up. "

  :0 fhw

  | sed -e '1s/^/F/'

}

--------------------------------------------------------------------------------------------------------

Solid Pop 3 Server, while it wasn't in the portage tree, it was very easy to setup, and compiles with out any problems, but it did need to be added to inetd, which if I didn't already have setup, I probably would have compiled it to run stand a lone instead.

Its only there because I didn't want to setup imap, and it gave my other family member who refuse to let go of windows a way to pull their mail locally as well, otherwise I wouldn't have bothered.

here's my xinetd.conf file with the pop-3 service showing enabled  

defaults

{

	only_from      = localhost

	instances      = 60

	log_type       = SYSLOG authpriv info

	log_on_success = HOST PID

	log_on_failure = HOST

	cps            = 25 30

}

includedir /etc/xinetd.d

service pop-3

{

	port = 110

	socket_type = stream

	protocol = tcp

	user = root

	server = /usr/local/sbin/spop3d

	server_args = -t maildir -n /home/%s/.maildir

	type = UNLISTED

	wait = no

	only_from = 192.168.5.5 127.0.0.1

}

Final things off the top of my head.

each user that is receiving email (this could probably be changed but its good enough for me) needs their own home dir in that directory they need their own maildir I've named them <dot>maildir and like a real maildir they need the three "cur" "new" "tmp" directories.

Hope this gives you some ideas on how you want to get things to work, in my research to see how others did it, I discovered there really isn't one right way, this was just the easiest for me, sinse I didn't want to use sendmail anymore, and postfix just wouldn't play well.

Have Fun,

theFred

----------

## Senso

I have a similar problem. I am, too, on dynamic DSL and my email address is pacu@somehost.ca. I'm using mail/mailx to send emails. If I send an email to another address in the same domain (my ISP allows 5 addresses), I get it but there's a problem: they're coming FROM: <root@somehost.ca> or <zutroi@somehost.ca>. 

As you can see, my username is not the same as the username in my email address. Internally it works (inside my ISP's network) but I can't get it to send to an external address - I've tried to email myself at my job, I don't get anything - I guess my ISP blocks the outgoing email from root@somehost.ca... 

I didn't try to setup a new user named the same as my email ('pacu') because I'm used to my current username and I don't wanna go all through the permissions and the like. But is it the only solution? the /etc/ssmtp/ssmtp.conf doesn't seem to include a way to rewrite the username, only the hostname.

At least, are there other MTA/apps which can rewrite the username to whatever you want?

----------

## dogghaus

I can probably help you with the postfix issues, but I had a little trouble following the posts.  Here are a few things to look up that might solve your problems though:

Postfix (I highly recommend it over other mta's) has several files that are not enabled (not even present) by default.  These come in the form of blank_canonical.  You can have recipient_canonical, sender_canonical, etc (you might want to also investigate transport mapping).  What they do is look for matches in the address header (incoming or outgoing, respectively) and either send them to a local mailbox or appear as if they are coming from a separate domain.  I am using sender_canonical for virtual domains on my home network.  I'm not near one of my linux boxes, but look for a samples directory, I think it's /etc/postfix/samples.  You'll find some examples in there.

I'm sure postfix will be able to do what you want, I've never had trouble making it do non-standard things.  Once you find the file type you need, add a line in the main.cf file to load it.  Example (if memory serves me correctly):

 === snip /etc/postfix/main.cf

sender_canonical_map = hash:/etc/postfix/sender_canonical

 === end snip

postfix reload

----------

