So I'm trying to utilize the smtp, mime, and tls packages for Tcl to be able to allow my program to send e-mails via external mail servers such as the gmail server (smtp.gmail.com) and yahoo server (smtp.mail.yahoo.com). I have an issue arising:
Sending email via the gmail server gives me the following error:
handshake failed: resource temporarily unavailable
while executing
"::tls::handshake $state(sd)"
I am using the smtp information found here: http://email.about.com/od/accessinggmail/f/Gmail_SMTP_Settings.htm
and my code looks like this:
tls::init -tls1 1;
set token [mime::initialize -canonical text/plain -string $body];
mime::setheader $token Subject "Test Email";
smtp::sendmessage $token -recipients "<my email address here>" -servers "smtp.gmail.com" -ports 587 -username "<my other email address here>" -password "<my password here>" -usetls true -debug 1;
mime::finalize $token;
Google automatically sent my gmail account an email saying:
We recently blocked a sign-in attempt to your Google Account <my email here>
And it gave me the option to change the security settings for "less secure apps" to allow my program to utilize the mail server. So I did, then my code worked just fine. What I don't understand is why gmail is blocking my attempts to send an e-mail; why it considers my attempt "less secure" thereby forcing me to lower the security settings on the e-mail account prior to sending emails from it. Perhaps my understanding is off, but I believe I'm using tls? And isn't tls more secure than ssl? Why does gmail have tls port if I can't connect to it anyway?
EDIT: Also I tried changing tls::init -tls1 1;
to tls::init -ssl3 1;
and using port 465 instead of 587, still to no avail.
When I try accessing the yahoo mail server (information retrieved from: http://www.serversmtp.com/en/smtp-yahoo), I get the following error:
premature end-of-file from server
while executing
"smtp::sendmessage $token -recipients "<my email here>" -servers "smtp.mail.yahoo.com" -ports 465 -username "my other email here" -password "<my password>" -usetls true -debug 1;..."
UPDATE I learned that for yahoo, the account you want to use has to be a Yahoo Mail Plus account to let you do smtp mail sending.