sending ftp file list to mail???

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Oct 7 05:28:28 EDT 2011


En Fri, 07 Oct 2011 03:23:57 -0300, selahattin ay <selahattin_ay at msn.com>  
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




More information about the Python-list mailing list