Fetchmail->Postfix->Spammassassin->Postfix->Exchange

Discussion in 'Installation/Configuration' started by Madlew2007, Feb 25, 2007.

  1. Madlew2007

    Madlew2007 New Member

    Being a M$ engineer, I'm new to this game but want to learn.

    I have followed the guide entitled Virtual Users And Domains With Postfix, Courier And MySQL (+ SMTP-AUTH, Quota, SpamAssassin, ClamAV) and all is good with recieving mail and having it forwarded to my exchange server all nice and spam free.

    I have been testing this using a Windows app called POPcon which downloaded POP emails and converts it to SMTP to an exchange server. I use this so I can test Sophos PureMessage anti-spam as it only scans SMTP.

    What I would like to do is use FetchMail to do the same. I have my /etc/fetchmailrc file polling like this:

    Code:
    # Daemon configuration
    # These two are set in /etc/default/fetchmail
    set daemon        900                # Pool every 5 minutes
    set syslog                        # log through syslog facility
    set postmaster  root
    
    set no bouncemail                # avoid loss on 4xx errors
                                    # on the other hand, 5xx errors get
                                    # more dangerous...
    
    ##########################################################################
    # Hosts to pool
    ##########################################################################
    
    # Defaults ===============================================================
    # Set antispam to -1, since it is far safer to use that together with
    # no bouncemail
    defaults:
    timeout 300
    antispam -1
    batchlimit 100
    
    poll MY.POP.COM protocol POP3 user "MYUSERNAME" password "MYPASSWORD"
    
    
    This downloaded the emails great, 400+, but it put them into the local mailbox for fetchmail and didnt use my postfix relaying rules.

    Code:
    Feb 25 14:16:35 king amavis[26956]: (26956-06) Passed, (?) -> <fetchmail@localhost>, Message-ID: <[email protected]>, Hits: 3.011
    Feb 25 14:16:35 king postfix/smtp[27270]: 4A09429C6A1: to=<fetchmail@localhost>, relay=127.0.0.1[127.0.0.1], delay=12, status=sent (250 2.6.0 Ok, id=26956-06, from MTA: 250 Ok: queued as 3536929C6D0)
    Feb 25 14:16:35 king postfix/qmgr[16564]: 4A09429C6A1: removed
    Feb 25 14:16:35 king postfix/local[27285]: 3536929C6D0: to=<fetchmail@localhost>, relay=local, delay=0, status=sent (delivered to maildir)
    Feb 25 14:16:35 king postfix/qmgr[16564]: 3536929C6D0: removed
    Any ideas why and how I fix this :confused:
     
  2. falko

    falko Super Moderator Howtoforge Staff

  3. Madlew2007

    Madlew2007 New Member

    Thanks for the reply Falko.

    I don't want it to go to a local user. I want it to lookup the domain in the transport sql table and relay to that.

    As all the emails are now in the local user mailbox for Fetchmail, is there a way I can relay these message to the entry in the transport table?

    Many thanks for your time.
     
  4. falko

    falko Super Moderator Howtoforge Staff

    If you don't want the domain of the original emails change to localhost after they have been fetched by fetchmail, you can use this in fetchmailrc:

    Code:
    poll MY.POP.COM protocol POP3 [B][COLOR="Red"]localdomains yourdomain.com[/COLOR][/B] user "MYUSERNAME" password "MYPASSWORD"
    I don't know if this helps...
     
  5. Madlew2007

    Madlew2007 New Member

    Tried that but still no luck :(

    Have had a look and will try
    Code:
    poll MY.POP.COM protocol POP3 localdomains yourdomain.com user "MYUSERNAME" password "MYPASSWORD" smtphost yourdomain.com
     
  6. Madlew2007

    Madlew2007 New Member

    Now I get the message in my logs and a NDR with this:

    relay=none, delay=0, status=bounced (mail for mydomain.com loops back to myself)

    Anyone else have this sort of setup that can help?
     
  7. falko

    falko Super Moderator Howtoforge Staff

    Please add mydomain.com to the mydestination line in /etc/postfix/main.cf OR to the domains table.
     
  8. Madlew2007

    Madlew2007 New Member

    The domain is listed in the domains and transport tables.

    Changed my poll command to this and re-run, this is what it looks like now.

    Code:
    set daemon        900
    set syslog
    set postmaster  root
    set no bouncemail
    timeout 300
    antispam -1
    batchlimit 100
    
    poll mail.popserver.com protocol POP3 localdomains mydomain.com user "[email protected]" password "********" smtphost mydomain.com
    
    Now messages get delivered to the fetchmail ~maildir instead of forwarding it using the transport rules. This is the entry in the log:

    Code:
    Mar  6 15:56:37 king postfix/smtpd[20442]: connect from localhost.localdomain[127.0.0.1]
    Mar  6 15:56:37 king postfix/smtpd[20442]: B426529C573: client=localhost.localdomain[127.0.0.1]
    Mar  6 15:56:37 king postfix/cleanup[20432]: B426529C573: message-id=<000f01c75ef2$6ea3e5c0$1502fac9@daniel>
    Mar  6 15:56:37 king postfix/qmgr[16564]: B426529C573: from=<[email protected]>, size=44539, nrcpt=1 (queue active)
    Mar  6 15:56:37 king amavis[19708]: (19708-04) Passed, <[email protected]> -> <[email protected]>, quarantine spam-ced0e91e723729d046fb3b672699a010-20070306-155637-19708-04, Message-ID: <000f01c75ef2$6ea3e5c0$1502fac9@daniel>, Hits: 8.646
    Mar  6 15:56:37 king postfix/smtp[20433]: 3402D29C51B: to=<[B][email protected][/B]>, relay=127.0.0.1[127.0.0.1], delay=11, status=sent (250 2.6.0 Ok, id=19708-04, from MTA: 250 Ok: queued as B426529C573)
    Mar  6 15:56:37 king postfix/qmgr[16564]: 3402D29C51B: removed
    Mar  6 15:56:37 king postfix/smtpd[20442]: disconnect from localhost.localdomain[127.0.0.1]
    
    Thanks again for your time.
     
  9. Madlew2007

    Madlew2007 New Member

    Oh, tell a lie, they are now queueing awaiting delivery to the Exchange server.

    This is what webmin says:
    Code:
    Mail ID		Sent			From 				To 				Size 	Status
    B426529C573 	Tue Mar 6 15:56:37 	[email protected] 	[email protected] 	44 kB 	delivery temporarily suspended: connect to xx.xx.xx.xx[xx.xx.xx.xx]: Connection timed out
    
    But why are they going to fetchmail@mydomain.com
     
  10. falko

    falko Super Moderator Howtoforge Staff

    I think this is the default user if you don't specify a user in the fetchmailrc file.
     
  11. Hyperlord

    Hyperlord New Member

    Hi,

    how did this go on? I have the same problem over here ... :-\
     

Share This Page