Send mail by /usr/sbin/sendmail
echo "From: luanvv@gmail.com
To: luanvv@gmail.com
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
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: abc@gmail.com\n");
os.write("To: abc@gmail.com\n");
os.write("CC: abc@gmail.com\n");
os.write("BCC: abc@gmail.com, abcd@gmail.com\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);
}