Thursday, March 10, 2016

Wrapping program with TclApp causes smtp package to stop working properly?

Leave a Comment

So I'm getting a strange issue when trying to send an email from my company's local mail server using Tcl. The problem is I've written code that works, but it doesn't work as soon as I wrap it with TclApp. I believe I've included all the necessary packages.

Code:

package require smtp; package require mime; package require tls;  set body "Hello World, I am sending an email! Hear me roar.";  #mime info set token [mime::initialize -canonical text/plain -string $body];  #mail options set opts {};  #MAIL SERVER + PORT lappend opts -servers "my_server"; lappend opts -ports 25;  tls::init -tls1 1; lappend opts -username "someEmail@example.com"; lappend opts -password "somePasswordExample";  #SUBJECT + FROM + TO  lappend opts -header [list "Subject" "This is a test e-mail, beware!!"]; lappend opts -header [list "From" "theFromEmail@example.com"]; lappend opts -header [list "To" "theToEmail@yahoo.com"];   if {[catch {     smtp::sendmessage $token \     {*}$opts \     -queue false \     -atleastone false \     -usetls false \     -debug 1;      mime::finalize $token;   } msg]} {     set out [open "error_log.txt" w];     puts $out $msg;     close $out; }  puts "Hit enter to continue..."; gets stdin; exit; 

This works when I run it and I successfully get the email sent. But when I wrap it, it doesn't. Here's the output after wrapping and executing the program: enter image description here

For whatever reason, wrapping with TclApp makes my program fail to authenticate.

*Update: I've decided to try to wrap the script with Freewrap to see if I get the same problem and amazingly I do not. Script works if not wrapped or if wrapped by Freewrap, but not TclApp; is this a bug in TclApp or am I simply missing something obvious?

It seems that this is an old problem (last post): https://community.activestate.com/forum/wrapping-package-tls151

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment