我正在尝试使用tcltk开发一个程序,该程序可以从任何Windows或UNIX计算机发送电子邮件。我编写了以下过程,虽然它是从Windows 2012 R2服务器运行的,而且Debian也不能从Windows 10运行,但它始终显示错误-
530: 5.5.1 Authentication Required. key message-id not in header while executing "error "key $mixed not in header"" (procedure "::mime::getheader line 24) invoked from within "::mime::getheader $part ${message-idL} ........
我尝试运行的代码是..
package require tls
package require smtp
package require mime
proc send_email {to subject body} {
set opts {}
lappend opts -servers "smtp.gmail.com"
lappend opts -ports 587
lappend opts -username "abcd@gmail.com"
lappend opts -password "pass"
lappend opts -header [list "Subject" $subject]
lappend opts -header [list "From" "abcd@gmail.com"]
lappend opts -header [list "To" $to]
set mime_msg [mime::initialize -canonical "text/plain" -encoding "7bit" -string $body]
smtp::sendmessage $mime_msg {*}$opts -usetls 1
mime::finalize $mime_msg
}
send_email "xyz@gmail.com" "test" "this is a test email"
有人可以帮忙吗?