2

I've got a problem with my POP3 provider delivering me e-mails with broken Return-Path header. When it's long, it gets wrongly folded into multiple lines, in the middle of e-mail address like this:

Return-Path: <bounce-md_30050491.5f06fc4d.v1-e20857b41e04493380b808e01cb6b51
 e@mailtracking.gitter.im>

Therefore, Postfix returns error and I get bounces from Fetchmail:

fetchmail: SMTP error: 501 5.1.7 Bad sender address syntax

I've read about Fetchmail's -Z option, but I don't want to discard these mails, they are important and not spam.

Is there a possibility to make Postfix treat this special case gracefully and return no error message? Or maybe someone knows a better solution to this problem?

AnFi
  • 6,103
  • 1
  • 14
  • 27

2 Answers2

2

fetchmail: direct delivery mailbox/maildir using procmail/maildrop

You can make fetchamil use procmail (or maildrop) to deliver messages directly to mailbox (mailbox file or maildir) without sending it via SMTP. Your procmail script may even unfold Return-Path:.

see mdaoption in man fetchmail

I have used similar solution with custom per email account procmail scripts.


~/.fetchmailrc

poll pop.provider.net proto pop3
  user "jsmith" with pass "secret1"
  mda /usr/bin/procmail -m .procmailrc-provider.net

~.procmailrc-provider.net

 ########
 # Debugging settings
 ########
 # log all dignostic info to ~/procmail.log
 LOGFILE=procmail.log
 # log abstracts of delivered messages
 # Subject:`,`From:`, size, final destination 
 LOGABSTRACT=all
 # Turn on extended diagnostic
 VERBOSE=on
 ########

 # deliver everttyting to maildir (tailing /) located in directory ~/.maildir 

:0
.maildir/

Debugging:
fetchamil: -v (or even -v -v) command line options
procmail:LOFILE and LOGABSTRACT settings in procmailrc file

AnFi
  • 6,103
  • 1
  • 14
  • 27
  • Thanks. But this method seems to hacky for me. I tried to use Postfix `header_checks` and IGNORE the problematic line with `/^Return-Path: .* / IGNORE`, but after configuring header checks with `postconf -e 'header_checks = regexp:/etc/postfix/header_checks'` and successful test with `postmap -hmq`, I still get an error. Do you think `header_checks` is a good solution and it's a matter of error in my configuration? Or the idea is for some reason totally bad? – Maciej Łoziński Nov 18 '20 at 15:22
  • I am not `postix` expert. I personally prefer making `fetchmail` deliver directly to user's local mailbox without SMTP server. – AnFi Nov 18 '20 at 16:13
  • Actually I think I've found out why Postfix does not do header check, by running `fetchmail -v`: ``` fetchmail: SMTP> MAIL FROM: SIZE=37416 fetchmail: SMTP< 501 5.1.7 Bad sender address syntax fetchmail: SMTP error: 501 5.1.7 Bad sender address syntax ``` – Maciej Łoziński Nov 18 '20 at 22:40
  • Unfortunately, this does not work for me. maybe I have an error somewhere, I don't know. – Maciej Łoziński Nov 19 '20 at 02:24
  • Have you started fetchamil in verbose mode? Do ou want verbose mode hinsts for procmail? – AnFi Nov 19 '20 at 06:07
  • I've figured it out finally. Turned out I was using `$DEFAULT` variable, which is not present, when firing Procmail this way. Having verbose output was also tricky, but [this guide](http://porkmail.org/era/mail/procmail-debug.html) helped me a lot. I actually used `VERBOSE=yes`. Thank you! – Maciej Łoziński Nov 19 '20 at 12:58
0

Another thing to do could be totally bypass fetchmail and just configure pop3 provider to forward all emails to my email address on the server. Unfortunately, my provider does not have this option.