1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2013 Matthieu Lucas <lucasmatthieu@gmail.com>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Mail sender sample using the Curl module
23 var mail_request
= new CurlMailRequest(curl
)
26 var response
= mail_request
.set_outgoing_server
("smtps://smtp.example.org:465", "user@example.org", "mypassword")
27 if response
isa CurlResponseFailed then
28 print
"Error code : {response.error_code}"
29 print
"Error msg : {response.error_msg}"
33 mail_request
.from
= "Billy Bob"
34 mail_request
.to
= ["user@example.org"]
35 mail_request
.cc
= ["bob@example.org"]
36 mail_request
.bcc
= null
38 var headers_body
= new HeaderMap
39 headers_body
["Content-Type:"] = "text/html; charset=\"UTF-8\
""
40 headers_body
["Content-Transfer-Encoding:"] = "quoted-printable"
41 mail_request
.headers_body
= headers_body
44 mail_request
.body
= "<h1>Here you can write HTML stuff.</h1>"
45 mail_request
.subject
= "Hello From My Nit Program"
48 mail_request
.verbose
= false
51 response
= mail_request
.execute
52 if response
isa CurlResponseFailed then
53 print
"Error code : {response.error_code}"
54 print
"Error msg : {response.error_msg}"
55 else if response
isa CurlMailResponseSuccess then
58 print
"Unknown Curl Response type"