initial commit
This commit is contained in:
commit
8b040eb0fe
|
@ -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*
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>p_0</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="module" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>smtpplz</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
|
@ -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
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue