0

I am trying to develop a procedure using tcltk that sends email from any windows or unix machine. I have written the below procedure and while it runs from Windows 2012 R2 server and also Debian it doesnot run from Windows 10 and it keeps showing the error --

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} ........

The code I tried running is..


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"

Could anyone please help with this?

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
UBan
  • 29
  • 5
  • 1
    Did you read this: [Problem with a tcl script](https://stackoverflow.com/questions/7355727/tcl-email-script-doesnt-deliver-in-activestate-tcl) or this :[Gmail-Authentication](https://stackoverflow.com/questions/17227532/gmail-530-5-5-1-authentication-required-learn-more-at)?. – L. Alejandro M. Jun 20 '18 at 00:08
  • 1
    Hey, thanks for the links adding a SASL package worked. Thank you! – UBan Jun 25 '18 at 13:38

0 Answers0