Tcl Library Source Code
Check-in [9c0c77acf0]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2018 Conference, Houston/TX, US, Oct 15-19
Send your abstracts to tclconference@googlegroups.com
or submit via the online form by Aug 20.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:mime / smtp <B> Ticket [d9be31a488] Simplify how `smtp::initialize` iterates over -servers and -ports. Updated the documentation. Version bumped to 1.4.6. Thanks to boegge for the report of the problem with the old code.
Timelines: family | ancestors | smtp-init-tkt-d9be31a488
Files: files | file ages | folders
SHA3-256:9c0c77acf0b1364c4b4d42698856278bbfe2a5cd3dfd415f1b49fe7382bbada0
User & Date: aku 2018-05-18 04:31:58
References
2018-05-18
04:34 Ticket [d9be31a488] smtp::initialize fails with "<-- 421 4.3.2 Service not available" status still Open with 3 other changes artifact: 156f1fe203 user: aku
Context
2018-05-18
04:31
mime / smtp <B> Ticket [d9be31a488] Simplify how `smtp::initialize` iterates over -servers and -ports. Updated the documentation. Version bumped to 1.4.6. Thanks to boegge for the report of the problem with the old code. Leaf check-in: 9c0c77acf0 user: aku tags: smtp-init-tkt-d9be31a488
04:15
log / log <EF> Ticket [19607f927b] Merged new `logsubst` command to prevent execution of expensive message construction until actually needed. Version bumped to 1.4. Thanks to Harald for idea and implementation. check-in: ea802e332b user: aku tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to modules/mime/smtp.man.

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
27
28
29
30
31
32
33







34
35
36



37
38
39
40
41
42
43
[comment {-*- tcl -*- doctools manpage}]

[manpage_begin smtp n 1.4.5]
[see_also ftp]
[see_also http]
[see_also mime]
[see_also pop3]
[copyright {1999-2000 Marshall T. Rose and others}]
[moddesc   {smtp client}]
[titledesc {Client-side tcl implementation of the smtp protocol}]
[category  Networking]
[require Tcl]
[require mime [opt 1.5.4]]
[require smtp [opt 1.4.5]]
[description]
[para]

The [package smtp] library package provides the client side of the
Simple Mail Transfer Protocol (SMTP) (1) (2).

[list_begin definitions]
................................................................................

[list_begin definitions]

[def [option -servers]]

A list of SMTP servers. The default is [const localhost].








[def [option -ports]]

A list of SMTP ports. The default is [const 25].




[def [option -client]]

The name to use as our hostname when connecting to the server. By
default this is either localhost if one of the servers is localhost,
or is set to the string returned by [cmd "info hostname"].


>
|










|







 







>
>
>
>
>
>
>



>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
[comment {-*- tcl -*- doctools manpage}]
[vset VERSION 1.4.6]
[manpage_begin smtp n [vset VERSION]]
[see_also ftp]
[see_also http]
[see_also mime]
[see_also pop3]
[copyright {1999-2000 Marshall T. Rose and others}]
[moddesc   {smtp client}]
[titledesc {Client-side tcl implementation of the smtp protocol}]
[category  Networking]
[require Tcl]
[require mime [opt 1.5.4]]
[require smtp [opt [vset VERSION]]]
[description]
[para]

The [package smtp] library package provides the client side of the
Simple Mail Transfer Protocol (SMTP) (1) (2).

[list_begin definitions]
................................................................................

[list_begin definitions]

[def [option -servers]]

A list of SMTP servers. The default is [const localhost].

[para] If multiple servers are specified they are tried in sequence.

Note that the [option -ports] are iterated over in tandem with the
servers. If there are not enough ports for the number of servers the
default port (see below) is used. If there are more ports than servers
the superfluous ports are ignored.

[def [option -ports]]

A list of SMTP ports. The default is [const 25].

[para] See option [option -servers] above regardig the behaviour for
then multiple servers and ports are specified.

[def [option -client]]

The name to use as our hostname when connecting to the server. By
default this is either localhost if one of the servers is localhost,
or is set to the string returned by [cmd "info hostname"].

Changes to modules/mime/smtp.tcl.

619
620
621
622
623
624
625
626
627


628
629
630
631
632
633
634
635
636
637
638
639
640
...
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
....
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
                            -username {} -password {}]
    array set options $args
    set state(options) [array get options]

    # Iterate through servers until one accepts a connection (and responds
    # nicely).
   
    set index 0 
    foreach server $options(-servers) {


	set state(readable) 0
        if {[llength $options(-ports)] >= $index} {
            set port [lindex $options(-ports) $index]
        } else {
            set port 25
        }
        if {$options(-debug)} {
            puts stderr "Trying $server..."
            flush stderr
        }

        if {[info exists state(sd)]} {
            unset state(sd)
................................................................................
            }
        }

        set r [initialize_ehlo $token]
        if {$r != {}} {
            return $r
        }
        incr index
    }

    # None of the servers accepted our connection, so close everything up and
    # return an error.
    finalize $token -close drop

    return -code $code -errorinfo $einfo -errorcode $ecode $result
................................................................................
            error "unknown boolean value: $value"
        }
    }
}

# -------------------------------------------------------------------------

package provide smtp 1.4.5

# -------------------------------------------------------------------------
# Local variables:
# indent-tabs-mode: nil
# End:







<
|
>
>

<
<
<
|
|







 







<







 







|





619
620
621
622
623
624
625

626
627
628
629



630
631
632
633
634
635
636
637
638
...
668
669
670
671
672
673
674

675
676
677
678
679
680
681
....
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
                            -username {} -password {}]
    array set options $args
    set state(options) [array get options]

    # Iterate through servers until one accepts a connection (and responds
    # nicely).
   

    foreach server $options(-servers) port $options(-ports) {
        if {$server == ""} continue

	set state(readable) 0



        if {$port == ""} { set port 25 }
        
        if {$options(-debug)} {
            puts stderr "Trying $server..."
            flush stderr
        }

        if {[info exists state(sd)]} {
            unset state(sd)
................................................................................
            }
        }

        set r [initialize_ehlo $token]
        if {$r != {}} {
            return $r
        }

    }

    # None of the servers accepted our connection, so close everything up and
    # return an error.
    finalize $token -close drop

    return -code $code -errorinfo $einfo -errorcode $ecode $result
................................................................................
            error "unknown boolean value: $value"
        }
    }
}

# -------------------------------------------------------------------------

package provide smtp 1.4.6

# -------------------------------------------------------------------------
# Local variables:
# indent-tabs-mode: nil
# End: