Resend emails from a Maildir

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Resend emails from a Maildir

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
Reply | Threaded
Open this post in threaded view
|

Re: Resend emails from a Maildir

Anant Athavale
Run, sendmail -q

Regards,
ANANT.

Quoting Patric Falinder <[hidden email]>:

> 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
>



------------------------------------------------------------------------------
Confidentiality Notice: This e-mail message, including any attachments, is for
the sole use of the intended recipient(s) and may contain confidential and
privileged information. Any unauthorized review, use, disclosure or
distribution is prohibited. If you are not the intended recipient, please
contact the sender by reply e-mail and destroy all copies of the original
message.
------------------------------------------------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: Resend emails from a Maildir

Ralf Hildebrandt
In reply to this post by Patric Falinder
* Patric Falinder <[hidden email]>:
> 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 user@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 -[hidden email] $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
  [hidden email] | http://www.charite.de
           
Reply | Threaded
Open this post in threaded view
|

Re: Resend emails from a Maildir

Michael Tokarev
18.10.2010 16:43, Ralf Hildebrandt wrote:
[]
> if  ! grep @ <<STOP > /dev/null
> $1
> STOP
> then

Now that's interesting construct ;)

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

/mjt
Reply | Threaded
Open this post in threaded view
|

Re: Resend emails from a Maildir

Patric Falinder
In reply to this post by Ralf Hildebrandt
Ralf Hildebrandt skrev 2010-10-18 14:43:

> * Patric Falinder<[hidden email]>:
>> 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 user@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 -[hidden email] $1<  $2&&  rm -f $2
>
Thanks a lot, will try that! :)

-Patric
Reply | Threaded
Open this post in threaded view
|

Re: Resend emails from a Maildir

mouss-4
In reply to this post by Patric Falinder
  Le 18/10/2010 11:56, Patric Falinder a écrit :

> 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


Reply | Threaded
Open this post in threaded view
|

Re: Resend emails from a Maildir

Roberto Scattini
In reply to this post by Patric Falinder

On Mon, Oct 18, 2010 at 6:56 AM, Patric Falinder <[hidden email]> wrote:
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 __
((__)(('(( ((_)
Reply | Threaded
Open this post in threaded view
|

Re: Resend emails from a Maildir

Victor Duchovni
In reply to this post by mouss-4
On Mon, Oct 18, 2010 at 11:37:18PM +0200, mouss wrote:

> - 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{[hidden email]} );
        @args = qw(sendmail -i);
        push(@args, "-f", "$envsender");
        push(@args, "--", @rcpts);
        system { $prog } @args;
        if (($code = $?) ne 0) {
            # handle errors
        }

--
        Viktor.
Reply | Threaded
Open this post in threaded view
|

Re: Resend emails from a Maildir

mouss-4
  Le 19/10/2010 21:22, Victor Duchovni a écrit :
> On Mon, Oct 18, 2010 at 11:37:18PM +0200, mouss wrote:
>
>> - 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.

indeed.

>   If using
> Perl, it is highly advisable to entirely bypass shell argument parsing:
>
> $prog = "/usr/sbin/sendmail";
> @rcpts = ( q{[hidden email]} );
> @args = qw(sendmail -i);
> push(@args, "-f", "$envsender");
> push(@args, "--", @rcpts);
> system { $prog } @args;
> if (($code = $?) ne 0) {
>    # handle errors
> }
>