mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 08:57:12 +02:00
Fix sender email address for invoicing alerts
It was failing to send alert emails because the email address it was constructing did not have permission through GAE to send emails. This switches it over to using the send from email address already in use elsewhere in the app that does successfully send emails. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=219812019
This commit is contained in:
parent
6a870e5820
commit
f59005ad35
6 changed files with 14 additions and 29 deletions
|
@ -44,7 +44,7 @@ class BillingEmailUtils {
|
|||
|
||||
private final SendEmailService emailService;
|
||||
private final YearMonth yearMonth;
|
||||
private final String alertSenderAddress;
|
||||
private final String outgoingEmailAddress;
|
||||
private final String alertRecipientAddress;
|
||||
private final ImmutableList<String> invoiceEmailRecipients;
|
||||
private final String billingBucket;
|
||||
|
@ -56,7 +56,7 @@ class BillingEmailUtils {
|
|||
BillingEmailUtils(
|
||||
SendEmailService emailService,
|
||||
YearMonth yearMonth,
|
||||
@Config("alertSenderEmailAddress") String alertSenderAddress,
|
||||
@Config("gSuiteOutgoingEmailAddress") String outgoingEmailAddress,
|
||||
@Config("alertRecipientEmailAddress") String alertRecipientAddress,
|
||||
@Config("invoiceEmailRecipients") ImmutableList<String> invoiceEmailRecipients,
|
||||
@Config("billingBucket") String billingBucket,
|
||||
|
@ -65,7 +65,7 @@ class BillingEmailUtils {
|
|||
Retrier retrier) {
|
||||
this.emailService = emailService;
|
||||
this.yearMonth = yearMonth;
|
||||
this.alertSenderAddress = alertSenderAddress;
|
||||
this.outgoingEmailAddress = outgoingEmailAddress;
|
||||
this.alertRecipientAddress = alertRecipientAddress;
|
||||
this.invoiceEmailRecipients = invoiceEmailRecipients;
|
||||
this.billingBucket = billingBucket;
|
||||
|
@ -86,7 +86,7 @@ class BillingEmailUtils {
|
|||
new GcsFilename(billingBucket, invoiceDirectoryPrefix + invoiceFile);
|
||||
try (InputStream in = gcsUtils.openInputStream(invoiceFilename)) {
|
||||
Message msg = emailService.createMessage();
|
||||
msg.setFrom(new InternetAddress(alertSenderAddress));
|
||||
msg.setFrom(new InternetAddress(outgoingEmailAddress));
|
||||
for (String recipient : invoiceEmailRecipients) {
|
||||
msg.addRecipient(RecipientType.TO, new InternetAddress(recipient));
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ class BillingEmailUtils {
|
|||
retrier.callWithRetry(
|
||||
() -> {
|
||||
Message msg = emailService.createMessage();
|
||||
msg.setFrom(new InternetAddress(alertSenderAddress));
|
||||
msg.setFrom(new InternetAddress(outgoingEmailAddress));
|
||||
msg.addRecipient(RecipientType.TO, new InternetAddress(alertRecipientAddress));
|
||||
msg.setSubject(String.format("Billing Pipeline Alert: %s", yearMonth.toString()));
|
||||
msg.setText(body);
|
||||
|
|
|
@ -25,7 +25,7 @@ import javax.mail.internet.InternetAddress;
|
|||
/** Static utils for emailing reporting results. */
|
||||
public class ReportingEmailUtils {
|
||||
|
||||
@Inject @Config("alertSenderEmailAddress") String sender;
|
||||
@Inject @Config("gSuiteOutgoingEmailAddress") String sender;
|
||||
@Inject @Config("alertRecipientEmailAddress") String recipient;
|
||||
@Inject SendEmailService emailService;
|
||||
@Inject ReportingEmailUtils() {}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class Spec11EmailUtils {
|
|||
|
||||
private final SendEmailService emailService;
|
||||
private final YearMonth yearMonth;
|
||||
private final String alertSenderAddress;
|
||||
private final String outgoingEmailAddress;
|
||||
private final String alertRecipientAddress;
|
||||
private final String spec11ReplyToAddress;
|
||||
private final String reportingBucket;
|
||||
|
@ -58,7 +58,7 @@ public class Spec11EmailUtils {
|
|||
Spec11EmailUtils(
|
||||
SendEmailService emailService,
|
||||
YearMonth yearMonth,
|
||||
@Config("alertSenderEmailAddress") String alertSenderAddress,
|
||||
@Config("gSuiteOutgoingEmailAddress") String outgoingEmailAddress,
|
||||
@Config("alertRecipientEmailAddress") String alertRecipientAddress,
|
||||
@Config("spec11ReplyToEmailAddress") String spec11ReplyToAddress,
|
||||
@Config("spec11EmailBodyTemplate") String spec11EmailBodyTemplate,
|
||||
|
@ -68,7 +68,7 @@ public class Spec11EmailUtils {
|
|||
Retrier retrier) {
|
||||
this.emailService = emailService;
|
||||
this.yearMonth = yearMonth;
|
||||
this.alertSenderAddress = alertSenderAddress;
|
||||
this.outgoingEmailAddress = outgoingEmailAddress;
|
||||
this.alertRecipientAddress = alertRecipientAddress;
|
||||
this.spec11ReplyToAddress = spec11ReplyToAddress;
|
||||
this.reportingBucket = reportingBucket;
|
||||
|
@ -135,7 +135,7 @@ public class Spec11EmailUtils {
|
|||
msg.setSubject(
|
||||
String.format("Google Registry Monthly Threat Detector [%s]", yearMonth.toString()));
|
||||
msg.setText(body.toString());
|
||||
msg.setFrom(new InternetAddress(alertSenderAddress));
|
||||
msg.setFrom(new InternetAddress(outgoingEmailAddress));
|
||||
msg.addRecipient(RecipientType.TO, new InternetAddress(registrarEmail));
|
||||
msg.addRecipient(RecipientType.BCC, new InternetAddress(spec11ReplyToAddress));
|
||||
emailService.sendMessage(msg);
|
||||
|
@ -147,7 +147,7 @@ public class Spec11EmailUtils {
|
|||
retrier.callWithRetry(
|
||||
() -> {
|
||||
Message msg = emailService.createMessage();
|
||||
msg.setFrom(new InternetAddress(alertSenderAddress));
|
||||
msg.setFrom(new InternetAddress(outgoingEmailAddress));
|
||||
msg.addRecipient(RecipientType.TO, new InternetAddress(alertRecipientAddress));
|
||||
msg.setSubject(subject);
|
||||
msg.setText(body);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue