mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 18:14:26 +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.commons.cli.PosixParser;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
|
import org.dspace.core.Email;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -75,48 +76,16 @@ public class DailyReportEmailer
|
|||||||
* @throws javax.mail.MessagingException
|
* @throws javax.mail.MessagingException
|
||||||
* if message cannot be sent.
|
* if message cannot be sent.
|
||||||
*/
|
*/
|
||||||
public void sendReport(File attachment, int numberOfBitstreams)
|
public void sendReport(File attachment, int numberOfBitstreams)
|
||||||
throws IOException, javax.mail.MessagingException
|
throws IOException, javax.mail.MessagingException
|
||||||
{
|
{
|
||||||
// Get the mail configuration properties
|
Email email = new Email();
|
||||||
String server = ConfigurationManager.getProperty("mail.server");
|
email.setSubject("Checksum checker Report - " + numberOfBitstreams + " Bitstreams found with POSSIBLE issues");
|
||||||
|
email.setContent("report is attached ...");
|
||||||
// Set up properties for mail session
|
email.addAttachment(attachment, "checksum_checker_report.txt");
|
||||||
Properties props = System.getProperties();
|
email.addRecipient(ConfigurationManager.getProperty("mail.admin"));
|
||||||
props.put("mail.smtp.host", server);
|
email.send();
|
||||||
|
}
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows users to have email sent to them. The default is to send all
|
* 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.
|
* Create a new email message.
|
||||||
*/
|
*/
|
||||||
Email()
|
public Email()
|
||||||
{
|
{
|
||||||
arguments = new ArrayList<Object>(50);
|
arguments = new ArrayList<Object>(50);
|
||||||
recipients = new ArrayList<String>(50);
|
recipients = new ArrayList<String>(50);
|
||||||
@@ -160,7 +160,7 @@ public class Email
|
|||||||
* @param cnt
|
* @param cnt
|
||||||
* the content of the message
|
* the content of the message
|
||||||
*/
|
*/
|
||||||
void setContent(String cnt)
|
public void setContent(String cnt)
|
||||||
{
|
{
|
||||||
content = cnt;
|
content = cnt;
|
||||||
arguments = new ArrayList<Object>();
|
arguments = new ArrayList<Object>();
|
||||||
@@ -172,7 +172,7 @@ public class Email
|
|||||||
* @param s
|
* @param s
|
||||||
* the subject of the message
|
* the subject of the message
|
||||||
*/
|
*/
|
||||||
void setSubject(String s)
|
public void setSubject(String s)
|
||||||
{
|
{
|
||||||
subject = s;
|
subject = s;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user