Last active
June 11, 2018 09:17
-
-
Save luanvuhlu/2841ef77c7e6cdcfdcee9027f4c0ba7e to your computer and use it in GitHub Desktop.
Send mail by /usr/sbin/sendmail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "From: [email protected] | |
To: [email protected] | |
MIME-Version: 1.0 | |
Subject: Test HTML e-mail. | |
Content-Type: text/html | |
<html> | |
<head> | |
<title>HTML E-mail</title> | |
</head> | |
<body> | |
<a href='http://www.google.com'>Click Here</a> | |
</body> | |
</html> | |
" | sendmail -t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
Process p = Runtime.getRuntime().exec(new String[]{ | |
"/usr/sbin/sendmail", | |
"-t" | |
}); | |
try (OutputStreamWriter os = new OutputStreamWriter(p.getOutputStream(), "UTF8")) { | |
os.write("Content-Type: text/html\n"); | |
os.write("From: [email protected]\n"); | |
os.write("To: [email protected]\n"); | |
os.write("CC: [email protected]\n"); | |
os.write("BCC: [email protected], [email protected]\n"); | |
os.write("Subject: This is subject\n"); | |
os.write("\n"); | |
os.write("Dear \n"); | |
os.write("This is just a example \n"); | |
} | |
p.waitFor(); | |
} catch (IOException | InterruptedException e) { | |
log.error(null, e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment