79517329

Date: 2025-03-18 11:58:15
Score: 0.5
Natty:
Report link

I am using DSpace version 8

  1. Modify Java Source Code Navigate to the Java source code: C:\dspace\dspace-api\src\main\java\org\dspace\core\Email.java

Inside the public void send() method, replace the following 3 lines:

            if (attachments.isEmpty() && moreAttachments.isEmpty()) {
                // If a character set has been specified, or a default exists
                if (charset != null) {
                    // message.setText(fullMessage, charset);
                    message.setContent(fullMessage, "text/html; charset=" + charset);
                } else {
                    // message.setText(fullMessage);
                    message.setContent(fullMessage, "text/html; charset=UTF-8");
                }
            } else {
                Multipart multipart = new MimeMultipart();
                // create the first part of the email
                BodyPart messageBodyPart = new MimeBodyPart();
                // messageBodyPart.setText(fullMessage);
                messageBodyPart.setContent(fullMessage, "text/html; charset=" + charset);
                multipart.addBodyPart(messageBodyPart);
            }
  1. Modify Email Template Open the register email template from this path: C:\dspace\config\emails\register

Add the following HTML code:

            #set($subject = "${config.get('dspace.name')} Account Registration")
            #set($phone = ${config.get('mail.message.helpdesk.telephone')})
            <html>
              <head>
                <style>
                  body {
                    font-family: Arial, sans-serif;
                    font-size: 14px;
                    line-height: 1.6;
                  }
                  .highlight {
                    color: #007bff;
                    font-weight: bold;
                  }
                </style>
              </head>
              <body>
                <p>Dear User,</p>
                <p>To complete registration for a <strong><i>${config.get('dspace.name')}</i></strong> account, please click the link below:</p>
                <p><a href="${params[0]}" class="highlight">${params[0]}</a></p>
                <p>If you need assistance with your account, please email <a href="mailto:${config.get('mail.helpdesk')}">${config.get('mail.helpdesk')}</a></p>
                #if( $phone )
                <p>Or call us at ${phone}.</p>
                #end
                <p>The ${config.get('dspace.name')} Team</p>
              </body>
            </html>
  1. Build and Deploy Run the following commands after modifying the .java or .vm files:

cd C:\dSpace mvn package

cd C:\dspace\target\dspace-installer ant fresh_install Note: After running the above commands, replace the dspace.cfg and local.cfg files with your previous backup as the commands may override the email settings.

  1. Deploy the WebApp Copy the webapps folder from: C:\dspace\webapps to C:\Program Files\Apache Software Foundation\Tomcat 10.1\webapps

  2. Restart Services Stop and restart Solr:

solr stop -p 8983 solr start -p 8983 Stop and restart the Tomcat service:

  1. Check Logs For error logs and additional information, check the DSpace log file: C:\dspace\log\dspace.log
Reasons:
  • Blacklisted phrase (1): the link below
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Milind S. Patil.