Bug 1115815 - [Enhancement] An email sent from RHQ Server using custom java mail server is not delivered because setFrom() is not set in RHQ MimeMessage
Summary: [Enhancement] An email sent from RHQ Server using custom java mail server is ...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: RHQ Project
Classification: Other
Component: Core Server
Version: 4.9
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified vote
Target Milestone: ---
: RHQ 4.12
Assignee: Heiko W. Rupp
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks: 1115813
TreeView+ depends on / blocked
 
Reported: 2014-07-03 07:51 UTC by bkramer
Modified: 2014-12-15 11:35 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-12-15 11:35:55 UTC


Attachments (Terms of Use)

Description bkramer 2014-07-03 07:51:28 UTC
Description of problem:
An email sent from RHQ Server using custom java mail server is not delivered because setFrom() is not set in RHQ MimeMessage

Version-Release number of selected component (if applicable):
RHQ 4.9

How reproducible:
Always

Steps to Reproduce:
1. When RHQ sends an email, From address is not set [1] and it should be according to the javadoc of javax.mail package [2].
2. Custom SMTP server, will not deliver email where From address is not set.
3.

Actual results:
When custom SMTP server is used, emails from RHQ server will not be delivered.

Expected results:
Emails from RHQ server are properly delivered when custom SMTP server is used.

Additional info:
[1]
**************************************************************************
public Collection<String> sendEmail(Collection<String> toAddresses, String messageSubject, String messageBody) {

        MimeMessage mimeMessage = new MimeMessage(mailSession);
        try {
            mimeMessage.setSubject(messageSubject);
            mimeMessage.setContent(messageBody, "text/plain");
        } catch (MessagingException e) {
            e.printStackTrace(); // TODO: Customise this generated block
            return toAddresses;
        }

        Exception error = null;
        Collection<String> badAdresses = new ArrayList<String>(toAddresses.size());

        // Send to each recipient individually, do not throw exceptions until we try them all
        for (String toAddress : toAddresses) {
            try {
                LOG.debug("Sending email [" + messageSubject + "] to recipient [" + toAddress + "]");
                InternetAddress recipient = new InternetAddress(toAddress);
                Transport.send(mimeMessage, new InternetAddress[] { recipient });
            } catch (Exception e) {
                LOG.error("Failed to send email [" + messageSubject + "] to recipient [" + toAddress + "]: "
                    + e.getMessage());
                badAdresses.add(toAddress);

                // Remember the first error - in case its due to a session initialization problem,
                // we don't want to lose the first error.
                if (error == null) {
                    error = e;
                }
            }
        }

        if (error != null) {
            LOG.error("Sending of emails failed for this reason: " + error.getMessage());
        }

        return badAdresses;
    }
**************************************************************************


[2] http://docs.oracle.com/javaee/6/api/javax/mail/package-summary.html

Comment 1 Heiko W. Rupp 2014-07-03 10:05:21 UTC
master 48c6a2e9

Comment 2 Heiko W. Rupp 2014-12-15 11:35:55 UTC
Bulk close of items fixed in RHQ 4.12

If you think this is not solved, then please open a *new* BZ and link to this one.


Note You need to log in before you can comment on or make changes to this bug.