]> git.sven.stormbind.net Git - sven/tclcurl.git/blob - tests/smtp.tcl
releasing package tclcurl version 7.22.0+hg20160822-2
[sven/tclcurl.git] / tests / smtp.tcl
1 package require TclCurl
2
3 # As an example this is contrived, but it works.
4
5 set alreadySent 0
6 set mailToSend \
7 "Date: Mon, 12 Sep 2011 20:34:29 +0200
8 To: fandom@telefonica.net
9 From: andres@verot.com
10 Subject: SMTP example
11
12 The body of the message starts here.
13
14 It could be a lot of lines, could be MIME encoded, whatever.
15 Check RFC5322.
16 "
17
18 proc sendString {size} {
19     global alreadySent mailToSend
20     
21     set toSend       [string range $mailToSend $alreadySent [incr $alreadySent $size]]
22     
23     incr alreadySent [string length $toSend]
24
25     return $toSend
26 }
27
28 set curlHandle [curl::init]
29
30 $curlHandle configure -url "smtp://smtp.telefonica.net:25"
31
32 $curlHandle configure -username "fandom\$telefonica.net"
33 $curlHandle configure -password "XXXXXXXX"
34
35 $curlHandle configure -mailfrom "fandom@telefonica.net"
36 $curlHandle configure -mailrcpt [list "fandom@telefonica.net" "andresgarci@telefonica.net"]
37
38 # You could put the mail in a file and use the '-infile' option
39 $curlHandle configure -readproc sendString
40
41 $curlHandle configure -verbose 1
42
43 $curlHandle perform
44
45 $curlHandle cleanup
46
47
48
49
50
51
52