Skip to content

Commit e80be6e

Browse files
committed
Mail header code translation working
1 parent a9f3912 commit e80be6e

File tree

8 files changed

+75
-89
lines changed

8 files changed

+75
-89
lines changed

mail-examples/src/main/groovy/io/vertx/example/mail/mail_headers.groovy

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import io.vertx.groovy.ext.mail.MailClient
2-
import io.vertx.groovy.core.MultiMap
32
// Start a local STMP server, remove this line if you want to use your own server.
43
// It just prints the sent message to the console
54
io.vertx.example.mail.LocalSmtpServer.start(2528)
@@ -12,20 +11,19 @@ def mailClient = MailClient.createShared(vertx, mailConfig)
1211

1312
def email = [
1413
15-
14+
15+
headers:[
16+
X-Mailer:"Vert.x Mail-Client 3.3.0-SNAPSHOT",
17+
Message-ID:"[email protected]",
18+
Reply-To:"[email protected]",
19+
Received:[
20+
"by vertx mail service",
21+
"from [192.168.1.1] by localhost"
22+
]
23+
],
24+
text:"This message should have a custom Message-ID"
1625
]
1726

18-
def headers = MultiMap.caseInsensitiveMultiMap()
19-
20-
headers.add("X-Mailer", "Vert.x Mail-Client 3.3.0-SNAPSHOT")
21-
headers.add("Message-ID", "[email protected]")
22-
headers.add("Reply-To", "[email protected]")
23-
headers.add("Received", "by vertx mail service")
24-
headers.add("Received", "from [192.168.1.1] by localhost")
25-
26-
email.headers = headers
27-
email.text = "This message should have a custom Message-ID"
28-
2927
mailClient.sendMail(email, { result ->
3028
if (result.succeeded()) {
3129
println(result.result())

mail-examples/src/main/groovy/io/vertx/example/mail/mail_images.groovy

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import io.vertx.groovy.ext.mail.MailClient
2-
import io.vertx.groovy.core.MultiMap
32
// Start a local STMP server, remove this line if you want to use your own server.
43
// It just prints the sent message to the console
54
io.vertx.example.mail.LocalSmtpServer.start(2526)
@@ -16,15 +15,17 @@ def email = [
1615
html:"visit vert.x <a href=\"http://vertx.io/\"><img src=\"cid:[email protected]\"></a>"
1716
]
1817

18+
def attachment = [
19+
data:vertx.fileSystem().readFileBlocking("logo-white-big.png"),
20+
contentType:"image/png",
21+
name:"logo-white-big.png",
22+
disposition:"inline",
23+
headers:[
24+
Content-ID:"<[email protected]>"
25+
]
26+
]
27+
1928
def list = []
20-
def attachment = [:]
21-
attachment.data = vertx.fileSystem().readFileBlocking("logo-white-big.png")
22-
attachment.contentType = "image/png"
23-
attachment.name = "logo-white-big.png"
24-
attachment.disposition = "inline"
25-
def headers = MultiMap.caseInsensitiveMultiMap()
26-
headers.add("Content-ID", "<[email protected]>")
27-
attachment.headers = headers
2829
list.add(attachment)
2930
email.inlineAttachment = list
3031

mail-examples/src/main/java/io/vertx/example/mail/MailHeaders.java

+7-14
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package io.vertx.example.mail;
22

33
import io.vertx.core.AbstractVerticle;
4-
import io.vertx.core.MultiMap;
5-
import io.vertx.core.http.CaseInsensitiveHeaders;
64
import io.vertx.example.util.Runner;
75
import io.vertx.ext.mail.MailConfig;
86
import io.vertx.ext.mail.MailMessage;
@@ -37,18 +35,13 @@ public void start() {
3735

3836
MailMessage email = new MailMessage()
3937
.setFrom("[email protected]")
40-
41-
42-
MultiMap headers = MultiMap.caseInsensitiveMultiMap();
43-
44-
headers.add("X-Mailer", "Vert.x Mail-Client 3.3.0-SNAPSHOT");
45-
headers.add("Message-ID", "[email protected]");
46-
headers.add("Reply-To", "[email protected]");
47-
headers.add("Received", "by vertx mail service");
48-
headers.add("Received", "from [192.168.1.1] by localhost");
49-
50-
email.setHeaders(headers);
51-
email.setText("This message should have a custom Message-ID");
38+
39+
.addHeader("X-Mailer", "Vert.x Mail-Client 3.3.0-SNAPSHOT")
40+
.addHeader("Message-ID", "[email protected]")
41+
.addHeader("Reply-To", "[email protected]")
42+
.addHeader("Received", "by vertx mail service")
43+
.addHeader("Received", "from [192.168.1.1] by localhost")
44+
.setText("This message should have a custom Message-ID");
5245

5346
mailClient.sendMail(email, result -> {
5447
if (result.succeeded()) {

mail-examples/src/main/java/io/vertx/example/mail/MailImages.java

+7-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import java.util.List;
55

66
import io.vertx.core.AbstractVerticle;
7-
import io.vertx.core.MultiMap;
87
import io.vertx.example.util.Runner;
98
import io.vertx.ext.mail.MailAttachment;
109
import io.vertx.ext.mail.MailClient;
@@ -38,15 +37,14 @@ public void start() {
3837
.setText("full message is readable as html only")
3938
.setHtml("visit vert.x <a href=\"http://vertx.io/\"><img src=\"cid:[email protected]\"></a>");
4039

40+
MailAttachment attachment = new MailAttachment()
41+
.setData(vertx.fileSystem().readFileBlocking("logo-white-big.png"))
42+
.setContentType("image/png")
43+
.setName("logo-white-big.png")
44+
.setDisposition("inline")
45+
.addHeader("Content-ID", "<[email protected]>");
46+
4147
List<MailAttachment> list=new ArrayList<>();
42-
MailAttachment attachment = new MailAttachment();
43-
attachment.setData(vertx.fileSystem().readFileBlocking("logo-white-big.png"));
44-
attachment.setContentType("image/png");
45-
attachment.setName("logo-white-big.png");
46-
attachment.setDisposition("inline");
47-
MultiMap headers = MultiMap.caseInsensitiveMultiMap();
48-
headers.add("Content-ID", "<[email protected]>");
49-
attachment.setHeaders(headers);
5048
list.add(attachment);
5149
email.setInlineAttachment(list);
5250

mail-examples/src/main/js/io/vertx/example/mail/mail_headers.js

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
var MailClient = require("vertx-mail-js/mail_client");
2-
var MultiMap = require("vertx-js/multi_map");
32
// Start a local STMP server, remove this line if you want to use your own server.
43
// It just prints the sent message to the console
54
Java.type("io.vertx.example.mail.LocalSmtpServer").start(2528);
@@ -12,20 +11,19 @@ var mailClient = MailClient.createShared(vertx, mailConfig);
1211

1312
var email = {
1413
"from" : "[email protected]",
15-
14+
15+
"headers" : {
16+
"X-Mailer" : "Vert.x Mail-Client 3.3.0-SNAPSHOT",
17+
"Message-ID" : "[email protected]",
18+
"Reply-To" : "[email protected]",
19+
"Received" : [
20+
"by vertx mail service",
21+
"from [192.168.1.1] by localhost"
22+
]
23+
},
24+
"text" : "This message should have a custom Message-ID"
1625
};
1726

18-
var headers = MultiMap.caseInsensitiveMultiMap();
19-
20-
headers.add("X-Mailer", "Vert.x Mail-Client 3.3.0-SNAPSHOT");
21-
headers.add("Message-ID", "[email protected]");
22-
headers.add("Reply-To", "[email protected]");
23-
headers.add("Received", "by vertx mail service");
24-
headers.add("Received", "from [192.168.1.1] by localhost");
25-
26-
email.headers = headers;
27-
email.text = "This message should have a custom Message-ID";
28-
2927
mailClient.sendMail(email, function (result, result_err) {
3028
if (result_err == null) {
3129
console.log(result);

mail-examples/src/main/js/io/vertx/example/mail/mail_images.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
var MailClient = require("vertx-mail-js/mail_client");
2-
var MultiMap = require("vertx-js/multi_map");
32
// Start a local STMP server, remove this line if you want to use your own server.
43
// It just prints the sent message to the console
54
Java.type("io.vertx.example.mail.LocalSmtpServer").start(2526);
@@ -16,16 +15,17 @@ var email = {
1615
"html" : "visit vert.x <a href=\"http://vertx.io/\"><img src=\"cid:[email protected]\"></a>"
1716
};
1817

19-
var list = [];
2018
var attachment = {
19+
"data" : vertx.fileSystem().readFileBlocking("logo-white-big.png"),
20+
"contentType" : "image/png",
21+
"name" : "logo-white-big.png",
22+
"disposition" : "inline",
23+
"headers" : {
24+
"Content-ID" : "<[email protected]>"
25+
}
2126
};
22-
attachment.data = vertx.fileSystem().readFileBlocking("logo-white-big.png");
23-
attachment.contentType = "image/png";
24-
attachment.name = "logo-white-big.png";
25-
attachment.disposition = "inline";
26-
var headers = MultiMap.caseInsensitiveMultiMap();
27-
headers.add("Content-ID", "<[email protected]>");
28-
attachment.headers = headers;
27+
28+
var list = [];
2929
list.push(attachment);
3030
email.inlineAttachment = list;
3131

mail-examples/src/main/rb/io/vertx/example/mail/mail_headers.rb

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require 'vertx-mail/mail_client'
2-
require 'vertx/multi_map'
32
# Start a local STMP server, remove this line if you want to use your own server.
43
# It just prints the sent message to the console
54
Java::IoVertxExampleMail::LocalSmtpServer.start(2528)
@@ -12,20 +11,19 @@
1211

1312
email = {
1413
'from' => "[email protected]",
15-
14+
15+
'headers' => {
16+
'X-Mailer' => "Vert.x Mail-Client 3.3.0-SNAPSHOT",
17+
'Message-ID' => "[email protected]",
18+
'Reply-To' => "[email protected]",
19+
'Received' => [
20+
"by vertx mail service",
21+
"from [192.168.1.1] by localhost"
22+
]
23+
},
24+
'text' => "This message should have a custom Message-ID"
1625
}
1726

18-
headers = Vertx::MultiMap.case_insensitive_multi_map()
19-
20-
headers.add("X-Mailer", "Vert.x Mail-Client 3.3.0-SNAPSHOT")
21-
headers.add("Message-ID", "[email protected]")
22-
headers.add("Reply-To", "[email protected]")
23-
headers.add("Received", "by vertx mail service")
24-
headers.add("Received", "from [192.168.1.1] by localhost")
25-
26-
email['headers'] = headers
27-
email['text'] = "This message should have a custom Message-ID"
28-
2927
mailClient.send_mail(email) { |result_err,result|
3028
if (result_err == nil)
3129
puts result

mail-examples/src/main/rb/io/vertx/example/mail/mail_images.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require 'vertx-mail/mail_client'
2-
require 'vertx/multi_map'
32
# Start a local STMP server, remove this line if you want to use your own server.
43
# It just prints the sent message to the console
54
Java::IoVertxExampleMail::LocalSmtpServer.start(2526)
@@ -16,16 +15,17 @@
1615
'html' => "visit vert.x <a href=\"http://vertx.io/\"><img src=\"cid:[email protected]\"></a>"
1716
}
1817

19-
list = Array.new
2018
attachment = {
19+
'data' => $vertx.file_system().read_file_blocking("logo-white-big.png"),
20+
'contentType' => "image/png",
21+
'name' => "logo-white-big.png",
22+
'disposition' => "inline",
23+
'headers' => {
24+
'Content-ID' => "<[email protected]>"
25+
}
2126
}
22-
attachment['data'] = $vertx.file_system().read_file_blocking("logo-white-big.png")
23-
attachment['contentType'] = "image/png"
24-
attachment['name'] = "logo-white-big.png"
25-
attachment['disposition'] = "inline"
26-
headers = Vertx::MultiMap.case_insensitive_multi_map()
27-
headers.add("Content-ID", "<[email protected]>")
28-
attachment['headers'] = headers
27+
28+
list = Array.new
2929
list.push(attachment)
3030
email['inlineAttachment'] = list
3131

0 commit comments

Comments
 (0)