Re: sending ftp file list to mail???



En Fri, 07 Oct 2011 03:23:57 -0300, selahattin ay <selahattin_ay@xxxxxxx> escribió:

hi all. I want to get my ftp list and send the list to my mail adress... my codes are

baglanti = FTP("ftp.guncelyorum.org")
baglanti.login("******", "*******")
print baglanti.dir()
posta = MIMEMultipart()
def posta_olustur():
posta['Subject']=konu
posta['From']=gmail_kullanici
posta['To']=kime
posta.attach(MIMEText(baglanti.retrlines("LIST"))) <------ what can I do for here

Ah, I didn't notice that part.
MIMEText expects a string. retrlines, by default, outputs to stdout, isn't very useful. Try this:

def posta_olustur():
...
lines = []
baglanti.retrlines("LIST", lines.append)
text = '\n'.join(lines)
posta.attach(MIMEText(text))



--
Gabriel Genellina

.



Relevant Pages

  • Re: Starting from the beginning
    ... Then, it usses an English-language string in the source code, which is ... possible reasons into the useless and incomprehensible "Unable to open CIP file", ... // more processing will be done here like getting the binary data ... /CIP3PreviewImageHeight 726 def ...
    (microsoft.public.vc.mfc)
  • Taint (like in Perl) as a Python module: taint.py
    ... The following is my first attempt at adding a taint feature to Python ... string to create a safe string from it. ... def replace: ...
    (comp.lang.python)
  • Memory Question
    ... I have wrote a helper to my program which monitors object count, memory utilization and a threshold of 10% to determine how many objects are sticking around and how many are being garbage collected. ... occured right before the original String count). ... def print_threshold_breakers hsh1, hsh2, threshold ... putsf 'Building mem usage', mem_usage ...
    (comp.lang.ruby)
  • Re: [QUIZ] Editing Text (#145)
    ... I start by partially implementing a string class that works equally ... a single "gap" and recirculates unused space better. ... def inspect ... # remove excess trailing space if too much ...
    (comp.lang.ruby)
  • [SUMMARY] DayRange (#92)
    ... A couple of submitters mentioned that this problem isn't quite as simple as it ... def test_english ... This is the heart of the String building process and many solutions landed on ... Array of Arrays with the days divided into groups of start and end days. ...
    (comp.lang.ruby)