|
35 | 35 | import java.util.regex.Pattern; |
36 | 36 | import javax.activation.DataHandler; |
37 | 37 | import javax.activation.DataSource; |
| 38 | +import javax.annotation.PostConstruct; |
38 | 39 | import javax.mail.BodyPart; |
39 | 40 | import javax.mail.Message; |
40 | 41 | import javax.mail.Session; |
|
47 | 48 |
|
48 | 49 | import org.apache.log4j.Logger; |
49 | 50 | import org.springframework.core.env.Environment; |
| 51 | +import org.springframework.beans.factory.annotation.Autowired; |
| 52 | +import org.springframework.stereotype.Component; |
50 | 53 |
|
51 | 54 | import com.imageworks.spcue.LayerInterface; |
52 | 55 | import com.imageworks.spcue.SpcueRuntimeException; |
53 | 56 | import com.imageworks.spcue.dispatcher.Dispatcher; |
54 | 57 |
|
| 58 | + |
55 | 59 | /** |
56 | 60 | * CueUtil is set of common methods used throughout the application. |
57 | 61 | */ |
| 62 | +@Component |
58 | 63 | public final class CueUtil { |
59 | 64 |
|
60 | 65 | private static final Logger logger = Logger.getLogger(CueUtil.class); |
| 66 | + private static String smtpHost = ""; |
| 67 | + @Autowired |
| 68 | + private Environment env; |
61 | 69 |
|
62 | 70 | /** |
63 | 71 | * Commonly used macros for gigabyte values in KB. |
@@ -88,6 +96,11 @@ public final class CueUtil { |
88 | 96 | */ |
89 | 97 | public static final int ONE_HOUR = 3600; |
90 | 98 |
|
| 99 | + @PostConstruct |
| 100 | + public void init() { |
| 101 | + CueUtil.smtpHost = this.env.getRequiredProperty("smtp_host", String.class); |
| 102 | + } |
| 103 | + |
91 | 104 | /** |
92 | 105 | * Return true if the given name is formatted as a valid |
93 | 106 | * allocation name. Allocation names should be facility.unique_name. |
@@ -157,7 +170,7 @@ public static int findChunk(List<Integer> dependOnFrames, int dependErFrame) { |
157 | 170 | public static void sendmail(String to, String from, String subject, StringBuilder body, Map<String, byte[]> images) { |
158 | 171 | try { |
159 | 172 | Properties props = System.getProperties(); |
160 | | - props.put("mail.smtp.host", "smtp"); |
| 173 | + props.put("mail.smtp.host", CueUtil.smtpHost); |
161 | 174 | Session session = Session.getDefaultInstance(props, null); |
162 | 175 | Message msg = new MimeMessage(session); |
163 | 176 | msg.setFrom(new InternetAddress(from)); |
@@ -189,6 +202,8 @@ public static void sendmail(String to, String from, String subject, StringBuilde |
189 | 202 | msg.setContent(mimeMultipart); |
190 | 203 | msg.setHeader("X-Mailer", "OpenCueMailer"); |
191 | 204 | msg.setSentDate(new Date()); |
| 205 | + Transport transport = session.getTransport("smtp"); |
| 206 | + transport.connect(CueUtil.smtpHost, null, null); |
192 | 207 | Transport.send(msg); |
193 | 208 | } |
194 | 209 | catch (Exception e) { |
|
0 commit comments