Skip to content
This repository was archived by the owner on Sep 7, 2023. It is now read-only.

Commit 0313d74

Browse files
author
Barry de Graaff
committed
adding option to globally disable welcome email
1 parent 11c767c commit 0313d74

File tree

5 files changed

+77
-28
lines changed

5 files changed

+77
-28
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ Setting up Zimbra
9393
adminpassword=adminPassword
9494
rocketurl=https://rocket.example.org
9595
loginurl=https://zimbra.example.org
96+
enableWelcomeEmail=true
9697

9798
- The `adminuser` and `adminpassword` should have been created
9899
when you first installed Rocket Chat.

extension/.idea/workspace.xml

Lines changed: 62 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

extension/rocket.jar

174 Bytes
Binary file not shown.

extension/src/tk/barrydegraaff/rocket/Rocket.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ public String getPath() {
159159
private String rocketURL;
160160
private String loginurl;
161161
private Boolean isMobile;
162+
private String enableWelcomeEmail;
162163

163164
/**
164165
* Processes HTTP POST requests.
@@ -372,6 +373,7 @@ public Boolean initializeRocketAPI() {
372373
this.adminPassword = prop.getProperty("adminpassword");
373374
this.rocketURL = prop.getProperty("rocketurl");
374375
this.loginurl = prop.getProperty("loginurl");
376+
this.enableWelcomeEmail = prop.getProperty("enableWelcomeEmail"); //may be null
375377
input.close();
376378
} catch (Exception ex) {
377379
ex.printStackTrace();
@@ -551,20 +553,21 @@ public Boolean createUser(Account account) {
551553

552554
private void sendConfirmation(Account account, String username, String password) {
553555
try {
554-
MimeMessage mm = new Mime.FixedMimeMessage(JMSession.getSmtpSession(account));
556+
if (!"false".equals(this.enableWelcomeEmail)) {
557+
MimeMessage mm = new Mime.FixedMimeMessage(JMSession.getSmtpSession(account));
558+
String to = account.getName();
555559

556-
String to = account.getName();
560+
mm.setRecipient(javax.mail.Message.RecipientType.TO, new JavaMailInternetAddress(to));
561+
mm.setContent("Your Rocket.Chat account has been created!<br><br>You must log-on to Rocket.Chat using your Zimbra credentials.<br>For changes to crucial settings inside RocketChat you may need these additional credentials:<br><br>Username: " + username + "<br>Password: " + password, MimeConstants.CT_TEXT_HTML);
562+
mm.setSubject("Welcome to Rocket Chat");
563+
mm.saveChanges();
557564

558-
mm.setRecipient(javax.mail.Message.RecipientType.TO, new JavaMailInternetAddress(to));
559-
mm.setContent("Your Rocket.Chat account has been created!<br><br>You must log-on to Rocket.Chat using your Zimbra credentials.<br>For changes to crucial settings inside RocketChat you may need these additional credentials:<br><br>Username: " + username + "<br>Password: " + password, MimeConstants.CT_TEXT_HTML);
560-
mm.setSubject("Welcome to Rocket Chat");
561-
mm.saveChanges();
565+
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account);
566+
MailSender mailSender = mbox.getMailSender();
562567

563-
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account);
564-
MailSender mailSender = mbox.getMailSender();
565-
566-
mailSender.setSaveToSent(false);
567-
mailSender.sendMimeMessage(null, mbox, mm);
568+
mailSender.setSaveToSent(false);
569+
mailSender.sendMimeMessage(null, mbox, mm);
570+
}
568571

569572
} catch (Exception e) {
570573
e.printStackTrace();

0 commit comments

Comments
 (0)