|
1 # |
|
2 # Copyright 2004-2006 Intel Corporation |
|
3 # |
|
4 # Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 # you may not use this file except in compliance with the License. |
|
6 # You may obtain a copy of the License at |
|
7 # |
|
8 # http://www.apache.org/licenses/LICENSE-2.0 |
|
9 # |
|
10 # Unless required by applicable law or agreed to in writing, software |
|
11 # distributed under the License is distributed on an "AS IS" BASIS, |
|
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 # See the License for the specific language governing permissions and |
|
14 # limitations under the License. |
|
15 # |
|
16 |
|
17 # |
|
18 # test script that runs an smtp daemon within the bundle daemon |
|
19 # |
|
20 |
|
21 proc smtpd_deliver_mime {token} { |
|
22 set sender [lindex [mime::getheader $token From] 0] |
|
23 set recipients [lindex [mime::getheader $token To] 0] |
|
24 set mail "From $sender [clock format [clock seconds]]" |
|
25 append mail "\n" [mime::buildmessage $token] |
|
26 puts $mail |
|
27 |
|
28 # mail inject $to $body |
|
29 } |
|
30 |
|
31 proc smtpd_start {port {deliver_mime smtpd_deliver_mime}} { |
|
32 package require smtp |
|
33 package require smtpd |
|
34 package require mime |
|
35 |
|
36 smtpd::configure -deliverMIME $deliver_mime |
|
37 smtpd::start 0 $port |
|
38 } |
|
39 |
|
40 proc send_test_mail {} { |
|
41 global smtp_port |
|
42 |
|
43 set token [mime::initialize -canonical text/plain \ |
|
44 -string "this is a test"] |
|
45 mime::setheader $token To "test@test.com" |
|
46 mime::setheader $token Subject "test subject" |
|
47 smtp::sendmessage $token \ |
|
48 -recipients test@test.com -servers localhost -ports $smtp_port |
|
49 mime::finalize $token |
|
50 } |