From: ardaliev on
On Apr 23, 6:28 am, yahalom <yahal...(a)gmail.com> wrote:
> I am trying to use smtp package and with different smtp servers I
> fail. Seems like smtp package does not work in the modern spam
> terrified world. my code:
>
> package require tls
> package require mime
> package require smtp
>
> set userName test
> ser password test
>
> set token [::mime::initialize -canonical text/plain -string hello]
> ::mime::setheader $token Subject "This is a test message"
>
> ::smtp::sendmessage $token -debug 1  -usetls 1 -ports 465 -originator
> t...(a)gmail.com -recipients "te...(a)gmail.com" -servers smtp.gawab.com -
> username $userName -password $password
>
> I tried with gmail and got that the service is not available. The same
> account works fine with outlook
>
> I tried with gawab.com and got "553 you have to authenticate"
>
> I tried with are web host and again got "553 you have to authenticate"
>
> and I doing something wrong

The server told you: "You have to authenticate!!" That means , you
need some lib which implements the ESMTP command "AUTH LOGIN" and send
username and pass as 8-bit encoded strings.You can use above code for
sending mails to servers ,that support "smtp-after-pop" (first you
read some mail using POP3 ,then you send.This way you don't have to
authenticate while sending mail).
But the most email servers use ESMTP, including Gmail.

P.S. look at this: http://wiki.tcl.tk/1256
Scroll down to the bottom of the page, there is an example.

set mime_msg [mime::initialize -canonical "text/plain" -encoding
"7bit" \ -string $body]

Notice the "encoding" switch.
From: yahalom on
On Apr 26, 4:46 am, ardaliev <ardal...(a)gmail.com> wrote:
> On Apr 23, 6:28 am, yahalom <yahal...(a)gmail.com> wrote:
>
>
>
> > I am trying to use smtp package and with different smtp servers I
> > fail. Seems like smtp package does not work in the modern spam
> > terrified world. my code:
>
> > package require tls
> > package require mime
> > package require smtp
>
> > set userName test
> > ser password test
>
> > set token [::mime::initialize -canonical text/plain -string hello]
> > ::mime::setheader $token Subject "This is a test message"
>
> > ::smtp::sendmessage $token -debug 1  -usetls 1 -ports 465 -originator
> > t...(a)gmail.com -recipients "te...(a)gmail.com" -servers smtp.gawab.com -
> > username $userName -password $password
>
> > I tried with gmail and got that the service is not available. The same
> > account works fine with outlook
>
> > I tried with gawab.com and got "553 you have to authenticate"
>
> > I tried with are web host and again got "553 you have to authenticate"
>
> > and I doing something wrong
>
> The server told you: "You have to authenticate!!"  That means , you
> need some lib which implements the ESMTP command "AUTH LOGIN" and send
> username and pass as 8-bit encoded strings.You can use above code for
> sending mails to servers ,that support "smtp-after-pop" (first you
> read some mail using POP3 ,then you send.This way you don't have to
> authenticate while sending mail).
> But the most email servers use ESMTP, including Gmail.
>
> P.S. look at this:http://wiki.tcl.tk/1256
> Scroll down to the bottom of the page, there is an example.
>
> set mime_msg [mime::initialize -canonical "text/plain" -encoding
> "7bit" \ -string $body]
>
> Notice the "encoding" switch.

This answer is more what I am looking for. I tried it but still gmail
does not like tcl (and I am also a bit disappointed that we do not
have a magic package that works like a modern email client)
anyway this is my code and the error I get:

proc send_email {from to subject body} {

set opts {}
lappend opts -servers smtp.gmail.com
lappend opts -ports [list 25 465]
lappend opts -username $userName
lappend opts -password $password
lappend opts -header [list "Subject" $subject]
lappend opts -header [list "From" $from]
lappend opts -header [list "To" $to]

set mime_msg [mime::initialize -canonical "text/plain" -encoding
"7bit" -string $body]

smtp::sendmessage $mime_msg {*}$opts -debug 1 -queue false -
atleastone false -usetls false
mime::finalize $mime_msg
}

using the code with debug I get:
Trying smtp.gmail.com...
<-- 220 mx.google.com ESMTP f11sm19020783wai.11
--> EHLO streamer (wait upto 300 seconds)
<-- 250-mx.google.com at your service, [59.99.176.168]
<-- 250-SIZE 35651584
<-- 250-8BITMIME
<-- 250-STARTTLS
<-- 250-ENHANCEDSTATUSCODES
<-- 250 PIPELINING
--> MAIL FROM:<myemail(a)gmail.com> SIZE=295 (wait upto 600 seconds)
<-- 530 5.7.0 Must issue a STARTTLS command first. f11sm19020783wai.11
--> RSET (wait upto 0 seconds)
--> QUIT (wait upto 0 seconds)
key message-id not in header
while executing
"error "key $mixed not in header""
("default" arm line 5)
invoked from within
"switch -- $key {
"" {
set result ""
foreach lower $state(lowerL) mixed $state(mixedL) {
lappend result..."
(procedure "::mime::getheader" line 7)
invoked from within
"::mime::getheader $part ${message-idL} "
invoked from within
"smtp::sendmessage $mime_msg {*}$opts -debug 1 -queue false -
atleastone false -u
setls false "
(procedure "send_email" line 21)
invoked from within
"send_email $from $to "$subject" $body
a test""
(file "checkEmail.tcl" line 82)

so... something is still wrong.

From: Roger O on
I have a function like this that works for me:

proc send_simple_message {mailTo mailFrom smtpServer subject body} {

set token [mime::initialize -canonical text/plain -string
$body]

mime::setheader $token Subject $subject

smtp::sendmessage $token \
-originator $mailFrom \
-recipients $mailTo \
-servers $smtpServer

mime::finalize $token
}
From: Kevin Kenny on
yahalom wrote:
> <-- 530 5.7.0 Must issue a STARTTLS command first. f11sm19020783wai.11

Did you do [package require tls] before doing the smtp::sendmessage ?
The exchange looks as if there's no TLS support loaded.

From http://tcllib.sourceforge.net/doc/smtp.html :

-usetls
This package supports the RFC 3207 TLS extension (3) by default
provided the tls package is available. You can turn this off with this
boolean option.

--
73 de ke9tv/2, Kevin
First  |  Prev  | 
Pages: 1 2
Prev: fickle problem...
Next: wikit on Mac OS 10.5.8