mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
DS-1364 checker-emailer ignores advanced mail configuration
This commit is contained in:

committed by
Ivan Masár

parent
b10be85130
commit
3aa695cadc
@@ -36,6 +36,7 @@ import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Email;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -75,48 +76,16 @@ public class DailyReportEmailer
|
||||
* @throws javax.mail.MessagingException
|
||||
* if message cannot be sent.
|
||||
*/
|
||||
public void sendReport(File attachment, int numberOfBitstreams)
|
||||
throws IOException, javax.mail.MessagingException
|
||||
{
|
||||
// Get the mail configuration properties
|
||||
String server = ConfigurationManager.getProperty("mail.server");
|
||||
|
||||
// Set up properties for mail session
|
||||
Properties props = System.getProperties();
|
||||
props.put("mail.smtp.host", server);
|
||||
|
||||
// Get session
|
||||
Session session = Session.getInstance(props, null);
|
||||
|
||||
MimeMessage msg = new MimeMessage(session);
|
||||
Multipart multipart = new MimeMultipart();
|
||||
|
||||
// create the first part of the email
|
||||
BodyPart messageBodyPart = new MimeBodyPart();
|
||||
messageBodyPart
|
||||
.setText("This is the checksum checker report, see attachment for details \n"
|
||||
+ numberOfBitstreams
|
||||
+ " Bitstreams found with POSSIBLE issues");
|
||||
multipart.addBodyPart(messageBodyPart);
|
||||
|
||||
// add the file
|
||||
messageBodyPart = new MimeBodyPart();
|
||||
|
||||
DataSource source = new FileDataSource(attachment);
|
||||
messageBodyPart.setDataHandler(new DataHandler(source));
|
||||
messageBodyPart.setFileName("checksum_checker_report.txt");
|
||||
multipart.addBodyPart(messageBodyPart);
|
||||
msg.setContent(multipart);
|
||||
msg.setFrom(new InternetAddress(ConfigurationManager
|
||||
.getProperty("mail.from.address")));
|
||||
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(
|
||||
ConfigurationManager.getProperty("mail.admin")));
|
||||
|
||||
msg.setSentDate(new Date());
|
||||
msg.setSubject("Checksum checker Report - " + numberOfBitstreams
|
||||
+ " Bitstreams found with POSSIBLE issues");
|
||||
Transport.send(msg);
|
||||
}
|
||||
public void sendReport(File attachment, int numberOfBitstreams)
|
||||
throws IOException, javax.mail.MessagingException
|
||||
{
|
||||
Email email = new Email();
|
||||
email.setSubject("Checksum checker Report - " + numberOfBitstreams + " Bitstreams found with POSSIBLE issues");
|
||||
email.setContent("report is attached ...");
|
||||
email.addAttachment(attachment, "checksum_checker_report.txt");
|
||||
email.addRecipient(ConfigurationManager.getProperty("mail.admin"));
|
||||
email.send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows users to have email sent to them. The default is to send all
|
||||
|
@@ -130,7 +130,7 @@ public class Email
|
||||
/**
|
||||
* Create a new email message.
|
||||
*/
|
||||
Email()
|
||||
public Email()
|
||||
{
|
||||
arguments = new ArrayList<Object>(50);
|
||||
recipients = new ArrayList<String>(50);
|
||||
@@ -160,7 +160,7 @@ public class Email
|
||||
* @param cnt
|
||||
* the content of the message
|
||||
*/
|
||||
void setContent(String cnt)
|
||||
public void setContent(String cnt)
|
||||
{
|
||||
content = cnt;
|
||||
arguments = new ArrayList<Object>();
|
||||
@@ -172,7 +172,7 @@ public class Email
|
||||
* @param s
|
||||
* the subject of the message
|
||||
*/
|
||||
void setSubject(String s)
|
||||
public void setSubject(String s)
|
||||
{
|
||||
subject = s;
|
||||
}
|
||||
|
Reference in New Issue
Block a user