aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/traccar/notification
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-03-31 22:35:39 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2019-03-31 22:35:39 -0700
commit59416923dcb3a756eaf532cc4259f2f6625c0762 (patch)
tree9082dae6616deac8fda432b7bfd80e4a52b6d9dc /src/test/java/org/traccar/notification
parent79a129dd6327d932133d6b9a50190d3f4927bff9 (diff)
downloadtrackermap-server-59416923dcb3a756eaf532cc4259f2f6625c0762.tar.gz
trackermap-server-59416923dcb3a756eaf532cc4259f2f6625c0762.tar.bz2
trackermap-server-59416923dcb3a756eaf532cc4259f2f6625c0762.zip
Convert project to gradle
Diffstat (limited to 'src/test/java/org/traccar/notification')
-rw-r--r--src/test/java/org/traccar/notification/NotificiationMailTest.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/test/java/org/traccar/notification/NotificiationMailTest.java b/src/test/java/org/traccar/notification/NotificiationMailTest.java
new file mode 100644
index 000000000..b82bec02e
--- /dev/null
+++ b/src/test/java/org/traccar/notification/NotificiationMailTest.java
@@ -0,0 +1,59 @@
+package org.traccar.notification;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import javax.mail.Message;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+import java.util.Properties;
+
+public class NotificiationMailTest {
+
+ private static final String FROM = "notification@traccar.org";
+ private static final String TO = "anton@traccar.org";
+
+ private static final String BODY = "Test email body.";
+ private static final String SUBJECT = "Test";
+
+ private static final String SMTP_USERNAME = "username";
+ private static final String SMTP_PASSWORD = "password";
+
+ private static final String HOST = "email-smtp.us-west-2.amazonaws.com";
+
+ private static final int PORT = 25;
+
+ @Ignore
+ @Test
+ public void test() throws Exception {
+
+ Properties props = System.getProperties();
+ props.put("mail.transport.protocol", "smtps");
+ props.put("mail.smtp.port", PORT);
+
+ props.put("mail.smtp.auth", "true");
+ props.put("mail.smtp.starttls.enable", "true");
+ props.put("mail.smtp.starttls.required", "true");
+
+ Session session = Session.getInstance(props);
+
+ MimeMessage msg = new MimeMessage(session);
+ msg.setFrom(new InternetAddress(FROM));
+ msg.setRecipient(Message.RecipientType.TO, new InternetAddress(TO));
+ msg.setSubject(SUBJECT);
+ msg.setContent(BODY, "text/plain");
+
+ Transport transport = session.getTransport();
+
+ try {
+ transport.connect(HOST, SMTP_USERNAME, SMTP_PASSWORD);
+ transport.sendMessage(msg, msg.getAllRecipients());
+ } finally {
+ transport.close();
+ }
+
+ }
+
+}