-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestjruby.rb
More file actions
executable file
·86 lines (65 loc) · 2.05 KB
/
testjruby.rb
File metadata and controls
executable file
·86 lines (65 loc) · 2.05 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
class Test
include Java
Dir["jars/\*.jar"].each { |jar| require jar }
Dir["jars/mahout/\*.jar"].each { |jar| require jar }
Dir["jars/mahout/hadoop/\*.jar"].each { |jar| require jar }
ArrayList = java.util.ArrayList;
Properties = java.util.Properties;
Message = javax.mail.Message;
RecipientType = javax.mail.Message::RecipientType;
MessagingException = javax.mail.MessagingException;
PasswordAuthentication = javax.mail.PasswordAuthentication;
Session = javax.mail.Session;
Transport = javax.mail.Transport;
InternetAddress = javax.mail.internet.InternetAddress;
MimeMessage = javax.mail.internet.MimeMessage;
Authenticator = javax.mail.Authenticator;
s = String.new
class MyAuthenticator < Authenticator
attr_accessor :username, :password
def getPasswordAuthentication
return PasswordAuthentication.new(username, password);
end
end
def test
a = ArrayList.new;
a.add(10);
p a.get(0)
props = Properties.new();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.port", "587");
username = "admin@truespider.com";
password = "trueSpider123";
auth = MyAuthenticator.new();
auth.username = username;
auth.password = password;
session = Session.getInstance(props,auth);
host = "smtp.gmail.com";
to = "prashant@truespider.com";
from = "admin@truespider.com";
subject = "My First Email";
messageText = "I am sending a message using the"
begin
message = MimeMessage.new(session);
message.setFrom(InternetAddress.new("admin@truespider.com"));
message.setRecipients(RecipientType::TO,
InternetAddress.parse("niket@truespider.com"));
message.setSubject("Testing Subject");
message.setText("Dear Mail Crawler,\n\n No spam to my email, please!");
Transport.send(message);
puts("Done");
rescue Exception => e
throw e
end
end
end
Test.new().test()
#Test.new().print_name();
Test.class_eval do
def print_name
puts "Prashant"
end
end
Test.new().print_name();