public class Sendmail extends EmailProvider {
protected Sendmail(Properties props) {
}
- private static final Pattern NON_ASCII = Pattern
- .compile("[^a-zA-Z0-9 .-\\[\\]!_@]");
+
+ private static final Pattern NON_ASCII = Pattern.compile("[^a-zA-Z0-9 .-\\[\\]!_@]");
@Override
- public void sendmail(String to, String subject, String message,
- String from, String replyto, String toname, String fromname,
- String errorsto, boolean extra) throws IOException {
+ public void sendmail(String to, String subject, String message, String from, String replyto, String toname,
+ String fromname, String errorsto, boolean extra) throws IOException {
String[] bits = from.split(",");
Socket smtp = new Socket("dogcraft.de", 25);
PrintWriter out = new PrintWriter(smtp.getOutputStream());
- BufferedReader in = new BufferedReader(new InputStreamReader(
- smtp.getInputStream()));
+ BufferedReader in = new BufferedReader(new InputStreamReader(smtp.getInputStream()));
readResponse(in);
out.print("HELO www.cacert.org\r\n");
out.flush();
// out.print("X-OriginatingIP: ".$_SERVER["REMOTE_ADDR"]."\r\n");
// }
// TODO
- SimpleDateFormat emailDate = new SimpleDateFormat(
- "E, d MMM yyyy HH:mm:ss ZZZZ (z)", Locale.ENGLISH);
- out.print("Date: "
- + emailDate.format(new Date(System.currentTimeMillis()))
- + "\r\n");
+ SimpleDateFormat emailDate = new SimpleDateFormat("E, d MMM yyyy HH:mm:ss ZZZZ (z)", Locale.ENGLISH);
+ out.print("Date: " + emailDate.format(new Date(System.currentTimeMillis())) + "\r\n");
out.print("Sender: " + errorsto + "\r\n");
out.print("Errors-To: " + errorsto + "\r\n");
if (replyto != null) {
out.print("To: " + to + "\r\n");
if (NON_ASCII.matcher(subject).matches()) {
- out.print("Subject: =?utf-8?B?"
- + Base64.getEncoder().encodeToString(subject.getBytes())
- + "?=\r\n");
+ out.print("Subject: =?utf-8?B?" + Base64.getEncoder().encodeToString(subject.getBytes()) + "?=\r\n");
} else {
out.print("Subject: " + subject + "\r\n");
}
// $message)))."\r\n.\r\n");
message = message + "\r\n";
- String sendM = message.replace("\r", "").replace("\n.\n", "\n")
- .replace("\n.\n", "\n").replace("\n", "\r\n")
- + ".\r\n";
+ String sendM = message.replace("\r", "").replace("\n.\n", "\n").replace("\n.\n", "\n").replace("\n", "\r\n")
+ + ".\r\n";
out.print(sendM);
out.flush();
readResponse(in);
readResponse(in);
smtp.close();
}
+
private static void readResponse(BufferedReader in) throws IOException {
String line;
while ((line = in.readLine()) != null && line.matches("\\d+-")) {