Teevity / ice

AWS Usage Tool
2.86k stars 435 forks source link

Weekly Cost Email BCC not sent #180

Open mike-mathers opened 9 years ago

mike-mathers commented 9 years ago

com.netflix.ice.basic.BasicWeeklyCostEmailService.sendEmail()

    SendRawEmailRequest rawEmailRequest = new SendRawEmailRequest(rawMessage);
    rawEmailRequest.setDestinations(Lists.<String>newArrayList(toEmail));
    rawEmailRequest.setSource(fromEmail);
    logger.info("sending email to " + toEmail + " " + body.toString());
    emailService.sendRawEmail(rawEmailRequest);

rawEmailRequest.setDestinations must also include the BCC to actually send. The previous,

    if (!test && !StringUtils.isEmpty(bccEmail)) {
        mimeMessage.addRecipients(Message.RecipientType.BCC, bccEmail);
    }

isn't sufficient to have it sent to the BCC.

Per AWS JavaDoc

/**
 * A list of destinations for the message, consisting of To:, CC:, and
 * BCC: addresses.
 *
 * @param destinations A list of destinations for the message, consisting of To:, CC:, and
 *         BCC: addresses.
 */
public void setDestinations(java.util.Collection<String> destinations) {
mike-mathers commented 9 years ago

Diff

492a493
>         List<String> destinations = Lists.<String>newArrayList(toEmail);
494a496
>             destinations.add(bccEmail);
510c512
<         rawEmailRequest.setDestinations(Lists.<String>newArrayList(toEmail));
---
>         rawEmailRequest.setDestinations(destinations);