return;
}
- EmailProvider.getInstance().sendMail(to.getEmail(), "[Find Agent] " + subject, body, to.getEmail(), null, null, null, null, false);
+ EmailProvider.getInstance().sendMail(to.getEmail(), "[Find Agent] " + subject, body, null, null, null, null, false);
}
}
}
public abstract class EmailProvider {
- public abstract void sendMail(String to, String subject, String message, String from, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException;
+ public abstract void sendMail(String to, String subject, String message, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException;
private static EmailProvider instance;
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 {
-
- String[] bits = from.split(",");
-
+ public void sendMail(String to, String subject, String message, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
+ String from = "support@" + ServerConstants.getWwwHostName().replaceAll("^www.", "");
try (Socket smtp = new Socket(targetHost, targetPort); PrintWriter out = new PrintWriter(new OutputStreamWriter(smtp.getOutputStream(), "UTF-8")); BufferedReader in = new BufferedReader(new InputStreamReader(smtp.getInputStream(), "UTF-8"));) {
readSMTPResponse(in, 220);
out.print("HELO www.cacert.org\r\n");
out.flush();
readSMTPResponse(in, 250);
- out.print("MAIL FROM:<returns@cacert.org>\r\n");
+ out.print("MAIL FROM: <" + from + ">\r\n");
out.flush();
readSMTPResponse(in, 250);
- bits = to.split(",");
+ String[] bits = to.split(",");
for (String user : bits) {
out.print("RCPT TO:<" + user.trim() + ">\r\n");
out.flush();
} else {
out.print("Reply-To: " + from + "\r\n");
}
- out.print("From: support@" + ServerConstants.getWwwHostName().replaceAll("^www.", "") + "\r\n");
+ out.print("From: " + from + "\r\n");
out.print("To: " + to + "\r\n");
if (NON_ASCII.matcher(subject).matches()) {
String body = runTemplate(this, l, vars);
String subject = runTemplate(subjectBlock, l, vars);
- SendMail.getInstance().sendMail(to, SUBJECT_TAG + subject, body, "support@cacert.org", null, null, null, null, false);
+ SendMail.getInstance().sendMail(to, SUBJECT_TAG + subject, body, null, null, null, null, false);
}
private static String runTemplate(Outputable toRun, Language l, Map<String, Object> vars) {
String subj = "subj-" + createUniqueName();
String msg = "msg-" + createUniqueName();
- EmailProvider.getInstance().sendMail(succmail, subj, msg, "system@cacert.org", "system@cacert.org", "Testtarget", "Testsender", null, false);
+ EmailProvider.getInstance().sendMail(succmail, subj, msg, "system@cacert.org", "Testtarget", "Testsender", null, false);
try (Socket s = SSLSocketFactory.getDefault().createSocket(imap, 993);//
PrintWriter pw = new PrintWriter(new OutputStreamWriter(s.getOutputStream(), "UTF-8"), true);//
}
@Override
- public void sendMail(String to, String subject, String message, String from, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
- TestMail tm = new TestEmailReceiver.TestMail(to, subject, message, fromname, replyto) {
+ public void sendMail(String to, String subject, String message, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
+ TestMail tm = new TestEmailReceiver.TestMail(to, subject, message, replyto) {
@Override
public void verify() throws IOException {
String message;
- String from;
-
String replyto;
- public TestMail(String to, String subject, String message, String from, String replyto) {
+ public TestMail(String to, String subject, String message, String replyto) {
this.to = to;
this.subject = subject;
this.message = message;
- this.from = from;
this.replyto = replyto;
}
return message;
}
- public String getFrom() {
- return from;
- }
-
public String getReplyto() {
return replyto;
}
String to = dis.readUTF();
String subject = dis.readUTF();
String message = dis.readUTF();
- String from = dis.readUTF();
String replyto = dis.readUTF();
- mails.add(new TestMail(to, subject, message, from, replyto));
+ mails.add(new TestMail(to, subject, message, replyto));
} else if (type.equals("challengeAddrBox")) {
String email = dis.readUTF();
dos.writeUTF(quickEmailCheck(email));
}
@Override
- public void sendMail(String to, String subject, String message, String from, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
- mails.add(new TestMail(to, subject, message, from, replyto));
+ public void sendMail(String to, String subject, String message, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
+ mails.add(new TestMail(to, subject, message, replyto));
}
}
public CommandlineEmailProvider(Properties p) {}
@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 replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
synchronized (System.out) {
System.out.println("== MAIL ==");
System.out.println("To: " + to);
System.out.println("Subject: " + subject);
- System.out.println("From: " + from);
System.out.println("Errors-To: " + errorsto);
System.out.println("Extra: " + extra);
System.out.println(message);
}
@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 replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
if (target != null) {
- target.sendMail(to, subject, message, from, replyto, toname, fromname, errorsto, extra);
+ target.sendMail(to, subject, message, replyto, toname, fromname, errorsto, extra);
}
}
}
@Override
- public synchronized void sendMail(String to, String subject, String message, String from, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
+ public synchronized void sendMail(String to, String subject, String message, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
while (true) {
if ( !ensureLocalConnection() && getTarget() != null) {
- super.sendMail(to, subject, message, from, replyto, toname, fromname, errorsto, extra);
+ super.sendMail(to, subject, message, replyto, toname, fromname, errorsto, extra);
return;
}
try {
write(to);
write(subject);
write(message);
- write(from);
write(replyto);
out.flush();
return;
}
@Override
- public synchronized void sendMail(String to, String subject, String message, String from, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
+ public synchronized void sendMail(String to, String subject, String message, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
HashMap<String, LinkedList<String>> mails = Manager.getInstance().emails;
LinkedList<String> hismails = mails.get(to);
if (hismails == null) {
hismails.addFirst(subject + "\n" + message);
for (int i = 0; i < toForward.length; i++) {
if (toForward[i].matcher(to).matches()) {
- super.sendMail(to, subject, message, from, replyto, toname, fromname, errorsto, extra);
+ super.sendMail(to, subject, message, replyto, toname, fromname, errorsto, extra);
return;
}
}