Posted to tcl by nscerqueira at Wed Feb 18 19:00:35 GMT 2015view raw

  1. proc send_simple_message {recipient email_server subject body file} {
  2. package require smtp
  3. package require mime
  4.  
  5. set token [mime::initialize -canonical application/x-csv -file $file \
  6. -header [list Content-Disposition "attachment; filename=\"[file tail $file]\""]]
  7.  
  8.  
  9.  
  10. # create plain text attachment also
  11.  
  12. mime::setheader $token Subject $subject
  13. smtp::sendmessage $token \
  14. -ports 587 \
  15. -debug 1\
  16. -username XXXX \
  17. -password XXXX \
  18. -recipients $recipient -servers $email_server
  19. mime::finalize $token
  20. }
  21.  
  22.  
  23. set file "/Users/nunocerqueira/lixo/job.gz"
  24.  
  25. send_simple_message XXXX smtp.gmail.com \
  26. "This is the subject." "This is the message!" $file