Re: dated-mailer.py

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

Re: dated-mailer.py

kfogel
Did you mean to send this to svn-breakage@ ? :-)

-Karl

[hidden email] writes:

> #!/usr/bin/env python
>
> import smtplib
> import sys
> import base64
> import os
> import time
>
> # Usage:  mail-nightly-build.py SUBJECT FILENAME
> #           mails the contents of FILENAME to svn-breakage@ list.
>
> # Adjust these globals as needed:
>
> to_address   = "[hidden email]"
> # to_address   = "[hidden email]"
> from_address = "[hidden email]"
> # SMTP_server  = "smtp.tigris.org"
> SMTP_server  = "contact"
> # SMTP_server  = "localhost"
>
> # The huuuuuuuuuuge program:
>
> if len(sys.argv) < 3:
>   print "Usage:  %s SUBJECT FILENAME [ATTACHMENT ...]" % sys.argv[0]
>   sys.exit(1)
>
> subject  = sys.argv[1]
> filename = sys.argv[2]
> mime_boundary = "----------------=_NEXT_PART_123456789"
>
>
> msg = "MIME-Version: 1.0\n" \
>       "Content-Type: multipart/mixed; boundary=\"%s\"\n" \
>       "From: %s\nTo: %s\nSubject: %s\n" \
>       "Date: %s\n\n" \
>       "--%s\nContent-Type: text/plain; charset=us-ascii\n" \
>       "Content-Transfer-Encoding: 8bit\nContent-Disposition: inline\n\n" \
>       % (mime_boundary, \
> from_address, to_address, subject, \
> time.strftime('%c'), \
> mime_boundary)
>
> fp = open(filename, 'r')
> contents = fp.read()
> fp.close()
>
> msg += contents + "\n--%s\n" % mime_boundary
>
> for arg in sys.argv[3:]:
>   fp = open(arg, 'rb')
>   contents = fp.read()
>   fp.close()
>   msg += "Content-Type: application/x-gzip\n" \
>          "Content-Disposition: attachment; filename=\"%s\"\n" \
>          "Content-Transfer-Encoding: base64\n\n" \
>          "%s\n\n--%s\n" % (os.path.basename(arg), \
>                              base64.encodestring(contents), mime_boundary)
>
> server = smtplib.SMTP(SMTP_server)
> server.sendmail(from_address, to_address, msg)
> server.quit()

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: dated-mailer.py

Erik Huelsmann-2
On 04 Jun 2005 15:17:49 -0500, [hidden email] <[hidden email]> wrote:
> Did you mean to send this to svn-breakage@ ? :-)

No, he meant to send to me, but it mistakenly turned up in breakage. Sorry.


bye,

Erik.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: dated-mailer.py

Carl Karsten
In reply to this post by kfogel
No - but I needed to send it somewhere, and it was the the closestest thing to a
mail client, so I edited it, changed the to_address, ran it, changed the
to_address back, saved it, exited the editor.  (notice the lack of "save" before
run.)  Doh!

Carl K

[hidden email] wrote:

> Did you mean to send this to svn-breakage@ ? :-)
>
> -Karl
>
> [hidden email] writes:
>
>>#!/usr/bin/env python
>>
>>import smtplib
>>import sys
>>import base64
>>import os
>>import time
>>
>># Usage:  mail-nightly-build.py SUBJECT FILENAME
>>#           mails the contents of FILENAME to svn-breakage@ list.
>>
>># Adjust these globals as needed:
>>
>>to_address   = "[hidden email]"
>># to_address   = "[hidden email]"
>>from_address = "[hidden email]"
>># SMTP_server  = "smtp.tigris.org"
>>SMTP_server  = "contact"
>># SMTP_server  = "localhost"
>>
>># The huuuuuuuuuuge program:
>>
>>if len(sys.argv) < 3:
>>  print "Usage:  %s SUBJECT FILENAME [ATTACHMENT ...]" % sys.argv[0]
>>  sys.exit(1)
>>
>>subject  = sys.argv[1]
>>filename = sys.argv[2]
>>mime_boundary = "----------------=_NEXT_PART_123456789"
>>
>>
>>msg = "MIME-Version: 1.0\n" \
>>      "Content-Type: multipart/mixed; boundary=\"%s\"\n" \
>>      "From: %s\nTo: %s\nSubject: %s\n" \
>>      "Date: %s\n\n" \
>>      "--%s\nContent-Type: text/plain; charset=us-ascii\n" \
>>      "Content-Transfer-Encoding: 8bit\nContent-Disposition: inline\n\n" \
>>      % (mime_boundary, \
>> from_address, to_address, subject, \
>> time.strftime('%c'), \
>> mime_boundary)
>>
>>fp = open(filename, 'r')
>>contents = fp.read()
>>fp.close()
>>
>>msg += contents + "\n--%s\n" % mime_boundary
>>
>>for arg in sys.argv[3:]:
>>  fp = open(arg, 'rb')
>>  contents = fp.read()
>>  fp.close()
>>  msg += "Content-Type: application/x-gzip\n" \
>>         "Content-Disposition: attachment; filename=\"%s\"\n" \
>>         "Content-Transfer-Encoding: base64\n\n" \
>>         "%s\n\n--%s\n" % (os.path.basename(arg), \
>>                             base64.encodestring(contents), mime_boundary)
>>
>>server = smtplib.SMTP(SMTP_server)
>>server.sendmail(from_address, to_address, msg)
>>server.quit()
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]