commit 8b040eb0fede06e07c3e72e54dfcf880fac2b790 Author: surtur Date: Sat Sep 19 19:01:55 2020 +0200 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1f6fbb3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* diff --git a/.project b/.project new file mode 100644 index 0000000..ec5d0a7 --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ + + + p_0 + + + + + + + + diff --git a/smtpplz/.classpath b/smtpplz/.classpath new file mode 100644 index 0000000..d54800d --- /dev/null +++ b/smtpplz/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/smtpplz/.project b/smtpplz/.project new file mode 100644 index 0000000..44aa663 --- /dev/null +++ b/smtpplz/.project @@ -0,0 +1,17 @@ + + + smtpplz + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/smtpplz/.settings/org.eclipse.jdt.core.prefs b/smtpplz/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..f2525a8 --- /dev/null +++ b/smtpplz/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 diff --git a/smtpplz/src/smtpplz/mailthing.java b/smtpplz/src/smtpplz/mailthing.java new file mode 100644 index 0000000..8978909 --- /dev/null +++ b/smtpplz/src/smtpplz/mailthing.java @@ -0,0 +1,20 @@ +package smtpplz; + +import java.io.*; +import java.net.*; + +public class mailthing { + public static void main(String[] args) { + System.out.println("Starting up..."); + try { + thegoodstuff gs = new thegoodstuff("smtp.utb.cz", 25); + gs.send_message("me", "you", "bs", "hey there"); + + } catch (UnknownHostException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + +} diff --git a/smtpplz/src/smtpplz/thegoodstuff.java b/smtpplz/src/smtpplz/thegoodstuff.java new file mode 100644 index 0000000..fd2fca8 --- /dev/null +++ b/smtpplz/src/smtpplz/thegoodstuff.java @@ -0,0 +1,55 @@ +package smtpplz; + +import java.net.*; +import java.io.*; + +public class thegoodstuff { + static InputStream is; + static OutputStream os; + static Socket s; + + public thegoodstuff(String host, int port) throws UnknownHostException, IOException { + Socket s = new Socket(host, port); + is = s.getInputStream(); + os = s.getOutputStream(); + } + + static void send_request(String request) throws IOException { + os.write(request.getBytes()); + os.flush(); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + public static void print_response() throws IOException { + byte allthechars[] = new byte[1024]; + int howmuch = is.read(allthechars); + System.out.write(allthechars, 0, howmuch); + } + + public void send_message(String from, String to, String subject, String text) throws IOException { + + from = "MAIL FROM: " + from + "\r\n"; + to = "RCPT TO: " + to + "\r\n"; + text = "DATA\r\n" + + "Subject: " + subject + "\r\n" + + text +"\r\n" + + ".\r\n"; + String chunk = ""; + String[] request_params = {from, to, text}; + for (int i = 0; i < request_params.length; i++) { + chunk = request_params[i]; + send_request(chunk); + print_response(); + } + } + + public static void close() throws IOException { + send_request("QUIT\r\n"); + print_response(); + s.close(); + } + +}