Send mail to gepafin or sviluppumbria based on hub email

This commit is contained in:
harish
2024-11-13 23:56:52 +05:30
parent 39d4384e71
commit 49e157dd6e
3 changed files with 4 additions and 88 deletions

View File

@@ -97,9 +97,6 @@ public class ApplicationDao {
@Value("${default_System_Receiver_Email}") @Value("${default_System_Receiver_Email}")
private String defaultSystemReceiverEmail; private String defaultSystemReceiverEmail;
@Value("${gepafin_email}")
private String gepafinEmail;
@Value("${rinaldo_email}") @Value("${rinaldo_email}")
private String rinaldoEmail; private String rinaldoEmail;
@@ -845,7 +842,7 @@ public class ApplicationDao {
// mailUtil.sendByMailGun(subject, body, List.of(carloEmail), null); // mailUtil.sendByMailGun(subject, body, List.of(carloEmail), null);
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(carloEmail)); emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(carloEmail));
} }
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(gepafinEmail)); emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(hub.getEmail()));
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(defaultSystemReceiverEmail)); emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(defaultSystemReceiverEmail));
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(rinaldoEmail)); emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(rinaldoEmail));

View File

@@ -1,78 +0,0 @@
package net.gepafin.tendermanagement.util;
import java.util.Arrays;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import com.mailgun.api.v3.MailgunMessagesApi;
import com.mailgun.client.MailgunClient;
@Component
public class MailUtil {
@Value("${apiKey}")
private String apiKeyValue;
@Value("${mailGun_user}")
private String mailGunUser;
@Value("${mailGun_apiKey}")
private String mailGunApiKey;
@Value("${mailGun_domainName}")
private String mailGunDomainName;
@Value("${mailGun_base_url}")
private String mailGunBaseUrl;
@Value("${isMailSendingEnabled}")
private String isEmailSendingEnabled;
@Autowired
private Environment environment;
public Boolean isTestProfileActivated() {
String[] activeProfiles = environment.getActiveProfiles();
return Arrays.stream(activeProfiles).anyMatch("test"::equals);
}
public void sendMailByMailGunAPI(List<String> recipents, List<String> CC, List<String> BCC, String subject,
String body, String replyTo) {
if (Boolean.FALSE.equals(Boolean.parseBoolean(isEmailSendingEnabled))) {
return;
}
MailgunMessagesApi mailgunMessagesApi = MailgunClient.config(mailGunBaseUrl, mailGunApiKey)
.createApi(MailgunMessagesApi.class);
String mailFrom = mailGunUser;
com.mailgun.model.message.Message.MessageBuilder temp = com.mailgun.model.message.Message.builder()
.replyTo(replyTo).from(mailFrom).to(recipents).subject(subject).html(body);
if (Boolean.FALSE.equals(CollectionUtils.isEmpty(CC))) {
temp.cc(CC);
}
if (Boolean.FALSE.equals(CollectionUtils.isEmpty(BCC))) {
temp.bcc(BCC);
}
if (Boolean.FALSE.equals(isTestProfileActivated())) {
com.mailgun.model.message.Message message = temp.build();
mailgunMessagesApi.sendMessage(mailGunDomainName, message);
}
}
public void sendByMailGun(String subject, String body, List<String> receiverEmails, String replyTo) {
sendMailByMailGunAPI(receiverEmails, null, null, subject, body, replyTo);
}
}

View File

@@ -53,13 +53,10 @@ vatCheckNewToken: 66026bd891a51044e90e08c4
spid.ipd.base.url=https://federatest.umbriadigitale.it spid.ipd.base.url=https://federatest.umbriadigitale.it
active.profile.folder=dev active.profile.folder=dev
# MailGun API Key # MailGun API
mailGun_apiKey= 398e3dea1911fe941af261906ec99362-07e2c238-8094421f
mailGun_user=comunicazione@paghiamoci.ai
mailGun_domainName=paghiamoci.ai
mailGun_base_url=https://api.eu.mailgun.net/ mailGun_base_url=https://api.eu.mailgun.net/
# SendinBlue API key
apiKey=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
api.pecUrl=https://ws.pecmassiva.com api.pecUrl=https://ws.pecmassiva.com
#senderEmail=mailer@bflows.net #senderEmail=mailer@bflows.net