Tcl Library Source Code

Changes On Branch smtp-init-tkt-d9be31a488
Login

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

Changes In Branch smtp-init-tkt-d9be31a488 Excluding Merge-Ins

This is equivalent to a diff from ea802e332b to 9c0c77acf0

2018-06-19
04:08
mime / smtp <B> Ticket [d9be31a488] Fixed operation of smtp::initialize when both server- and port-list contain more than one element. Bumped to 1.4.6 check-in: f8b74f465b user: aku tags: trunk
2018-05-18
04:42
json / json <D> Ticket [868b8ebe79] json / json::write <D> Extended the documentation of both packages to refer to the other. No version changes. Regenerated the online documentation. check-in: e2d7b04944 user: aku tags: trunk
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. Closed-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
2018-05-07
17:06
Regenerated web docs. check-in: 2d4eba9c29 user: aku tags: trunk
2018-02-20
11:09
Fixed list error Closed-Leaf check-in: 259321213b user: oehhar tags: rfe-19607f927b-logeval

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
21
22
23
24
25
26
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]

[call [cmd ::smtp::sendmessage] [arg token] [arg option]...]

This command sends the MIME part (see package [package mime])
represented by [arg token] to an SMTP server. [arg options] is a list
of options and their associated values.  The recognized options are:

[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
22
23
24
25
26
27
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]

[call [cmd ::smtp::sendmessage] [arg token] [arg option]...]

This command sends the MIME part (see package [package mime])
represented by [arg token] to an SMTP server. [arg options] is a list
of options and their associated values.  The recognized options are:

[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
                            -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)







<
|
>
>

<
<
<
|
|







619
620
621
622
623
624
625

626
627
628
629



630
631
632
633
634
635
636
637
638
                            -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)
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
            }
        }

        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







<







668
669
670
671
672
673
674

675
676
677
678
679
680
681
            }
        }

        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
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
            error "unknown boolean value: $value"
        }
    }
}

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

package provide smtp 1.4.5

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







|





1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
            error "unknown boolean value: $value"
        }
    }
}

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

package provide smtp 1.4.6

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