Discussion:
Resend emails from a Maildir
(too old to reply)
Patric Falinder
2010-10-18 09:56:28 UTC
Permalink
Hi,

I'm not really sure if this has to do with Postifx so just tell me if
I'm wrong.

Is it possible to resend emails that are in a Maildir already?
The reason for this is that a user changed server so I had to change the
transport for that domain and there are something like 50 mails in the
old Maildir that I need to "resend" to the new server.

Is that possible?


Thanks,
-Patric
a***@isac.gov.in
2010-10-18 10:05:20 UTC
Permalink
Run, sendmail -q

Regards,
ANANT.
Post by Patric Falinder
Hi,
I'm not really sure if this has to do with Postifx so just tell me
if I'm wrong.
Is it possible to resend emails that are in a Maildir already?
The reason for this is that a user changed server so I had to change
the transport for that domain and there are something like 50 mails
in the old Maildir that I need to "resend" to the new server.
Is that possible?
Thanks,
-Patric
Ralf Hildebrandt
2010-10-18 12:43:34 UTC
Permalink
Post by Patric Falinder
Hi,
I'm not really sure if this has to do with Postifx so just tell me if
I'm wrong.
Is it possible to resend emails that are in a Maildir already?
Yes.

#!/bin/sh

#
# verschickt die gesamte Mail eines Benutzers an $1
#
USAGE="usage: $0 ***@domain"

if test $# != 1
then
echo $USAGE
exit 1
fi

if ! grep @ <<STOP > /dev/null
$1
STOP
then
echo $USAGE
echo No @ in Mail-address
exit 1
fi

if ! test -d new -a -d cur -a tmp
then
echo You are not in Maildir
echo there is no new cur tmp
exit 1
fi


find cur new tmp -type f | xargs --replace /usr/local/scripts/send_mail $1 {}


----
/usr/local/scripts/send_mail
----
#!/bin/sh
/usr/local/sbin/mini_sendmail -syour.mail.host -p25 -***@charite.de $1 < $2 && rm -f $2
--
Ralf Hildebrandt
Geschäftsbereich IT | Abteilung Netzwerk
Charité - Universitätsmedizin Berlin
Campus Benjamin Franklin
Hindenburgdamm 30 | D-12203 Berlin
Tel. +49 30 450 570 155 | Fax: +49 30 450 570 962
***@charite.de | http://www.charite.de
Michael Tokarev
2010-10-18 13:02:40 UTC
Permalink
18.10.2010 16:43, Ralf Hildebrandt wrote:
[]
$1
STOP
then
Now that's interesting construct ;)

case "$1" in
?*@?*) ;;
*) echo "No @ in Mail-address" >&2; exit 1;;
esac

/mjt
Patric Falinder
2010-10-18 13:03:25 UTC
Permalink
Post by Ralf Hildebrandt
Post by Patric Falinder
Hi,
I'm not really sure if this has to do with Postifx so just tell me if
I'm wrong.
Is it possible to resend emails that are in a Maildir already?
Yes.
#!/bin/sh
#
# verschickt die gesamte Mail eines Benutzers an $1
#
if test $# != 1
then
echo $USAGE
exit 1
fi
$1
STOP
then
echo $USAGE
exit 1
fi
if ! test -d new -a -d cur -a tmp
then
echo You are not in Maildir
echo there is no new cur tmp
exit 1
fi
find cur new tmp -type f | xargs --replace /usr/local/scripts/send_mail $1 {}
----
/usr/local/scripts/send_mail
----
#!/bin/sh
Thanks a lot, will try that! :)

-Patric
mouss
2010-10-18 21:37:18 UTC
Permalink
Post by Patric Falinder
Hi,
I'm not really sure if this has to do with Postifx so just tell me if
I'm wrong.
Is it possible to resend emails that are in a Maildir already?
The reason for this is that a user changed server so I had to change
the transport for that domain and there are something like 50 mails in
the old Maildir that I need to "resend" to the new server.
Is that possible?
if it's maildir at both sides, the simple thing is to copy the files
(cp, scp, rync, ... etc.)

if you believe smtp is the right transport, then:
- you'll need to make sure the "Delivered-To" header does not match the
next destination address (otherwise, Mr postfix will "think" this is a loop)
- get the MAIL FROM address from the "Return-Path" header. with this you
can do: sendmail -f $returnpath yourdestinationemail
Roberto Scattini
2010-10-19 11:07:58 UTC
Permalink
Hi,
I'm not really sure if this has to do with Postifx so just tell me if I'm
wrong.
Is it possible to resend emails that are in a Maildir already?
The reason for this is that a user changed server so I had to change the
transport for that domain and there are something like 50 mails in the old
Maildir that I need to "resend" to the new server.
Is that possible?
Thanks,
-Patric
maybe imapsync?
--
Roberto Scattini
___ _
))_) __ )L __
((__)(('(( ((_)
Victor Duchovni
2010-10-19 19:22:42 UTC
Permalink
Post by mouss
- get the MAIL FROM address from the "Return-Path" header. with this you
can do: sendmail -f $returnpath yourdestinationemail
Make that:

sendmail -i -f "$returnpath" -- "$destpath" < msgfile

The returnpath can have all kinds of interesting characters. If using
Perl, it is highly advisable to entirely bypass shell argument parsing:

$prog = "/usr/sbin/sendmail";
@rcpts = ( q{***@example.com} );
@args = qw(sendmail -i);
push(@args, "-f", "$envsender");
push(@args, "--", @rcpts);
system { $prog } @args;
if (($code = $?) ne 0) {
# handle errors
}
--
Viktor.
mouss
2010-10-20 21:16:51 UTC
Permalink
Post by mouss
- get the MAIL FROM address from the "Return-Path" header. with this you
can do: sendmail -f $returnpath yourdestinationemail
sendmail -i -f "$returnpath" -- "$destpath"< msgfile
The returnpath can have all kinds of interesting characters.
indeed.
If using
$prog = "/usr/sbin/sendmail";
@rcpts = ( q{***@example.com} );
@args = qw(sendmail -i);
if (($code = $?) ne 0) {
# handle errors
}
Loading...