I have used the script below to send email to my students via gmail: #! /bin/sh #| exec racket -t "$0" ${1+"$@"} |#
#lang racket ;; ----------------------------------------------------------------------------- ;; send graded solutions located in _directory_ and label them _subject_ (define directory "PCode/") ;; ----------------------------------------------------------------------------- (require net/smtp net/dns openssl/mzssl net/head) (define subject "grade for final project, take 2") (define (main) (parameterize ([current-directory directory]) (for ((f (directory-list)) #:when (regexp-match "\\.rkt" (path->string f))) (define c (file->lines f)) (displayln `(doing ,f ,(second c))) (define to (string-split (substring (second c) 3) ", ")) ; (displayln `(running ,f ,to)) (send to (list* "" "*** do not reply to this message ***" "" c)) (printf "done: ~a\n" f)))) (define (send to file) (smtp-send-message (dns-get-address (dns-find-nameserver) "smtp.gmail.com") "matth...@ccs.neu.edu" to (standard-message-header "matth...@ccs.neu.edu" to '() '("matth...@ccs.neu.edu") subject) file #:port-no 465 ; for gmail don't include the @gmail.com #:auth-user "matthias.f@" #:auth-passwd "XYZ XYZ" ; gmail special password that bypasses dual verification #:tcp-connect ssl-connect)) ;; http://en.wikipedia.org/wiki/MIME#Multipart_messages ;; attaching files? (module+ main (main)) On May 8, 2013, at 8:39 PM, Kejia柯嘉 wrote: > hello all, > > i am trying to use ``smtp-send-message" to send emails via gmail. my > code is following: > `` > #! /usr/local/bin/racket > > #lang racket > > (require net/head net/smtp) > > (smtp-send-message > "smtp.gmail.com" > "w1 <theu...@gmail.com>" > '("w2 <w...@hotmail.com>") > (standard-message-header > "w1 <theu...@gmail.com>" > '("w2 <w...@hotmail.com>") > '() ; CC > '() ; BCC > "Subject") > '("Hello World!") > #:port-no 587 > #:auth-user "theu...@gmail.com" > #:auth-passwd "theauthpassword") > '' > the code does not work. the similar config works for a python program. > anyone knows how to do this job with racket? > > ---------------------- > daniel > > ☵☯☲ > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users ____________________ Racket Users list: http://lists.racket-lang.org/users