HTML Email - do not repeat subject in message body.
This commit is contained in:
parent
16c60adc49
commit
2fcdbafd6d
|
@ -68,7 +68,7 @@ import com.sun.mail.smtp.SMTPMessage;
|
||||||
public final class EMail implements Serializable
|
public final class EMail implements Serializable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -2526338392563042117L;
|
private static final long serialVersionUID = -2526338392563042117L;
|
||||||
//use in server bean
|
//use in server bean
|
||||||
|
@ -81,12 +81,12 @@ public final class EMail implements Serializable
|
||||||
* @param subject Subject of message
|
* @param subject Subject of message
|
||||||
* @param message The message
|
* @param message The message
|
||||||
*/
|
*/
|
||||||
public EMail (MClient client, String from, String to,
|
public EMail (MClient client, String from, String to,
|
||||||
String subject, String message)
|
String subject, String message)
|
||||||
{
|
{
|
||||||
this (client.getCtx(), client.getSMTPHost(), from, to, subject, message);
|
this (client.getCtx(), client.getSMTPHost(), from, to, subject, message);
|
||||||
} // EMail
|
} // EMail
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Full Constructor
|
* Full Constructor
|
||||||
* @param client the client
|
* @param client the client
|
||||||
|
@ -96,7 +96,7 @@ public final class EMail implements Serializable
|
||||||
* @param message The message
|
* @param message The message
|
||||||
* @param html
|
* @param html
|
||||||
*/
|
*/
|
||||||
public EMail (MClient client, String from, String to,
|
public EMail (MClient client, String from, String to,
|
||||||
String subject, String message, boolean html)
|
String subject, String message, boolean html)
|
||||||
{
|
{
|
||||||
this (client.getCtx(), client.getSMTPHost(), from, to, subject, message, html);
|
this (client.getCtx(), client.getSMTPHost(), from, to, subject, message, html);
|
||||||
|
@ -111,12 +111,12 @@ public final class EMail implements Serializable
|
||||||
* @param subject Subject of message
|
* @param subject Subject of message
|
||||||
* @param message The message
|
* @param message The message
|
||||||
*/
|
*/
|
||||||
public EMail (Properties ctx, String smtpHost, String from, String to,
|
public EMail (Properties ctx, String smtpHost, String from, String to,
|
||||||
String subject, String message)
|
String subject, String message)
|
||||||
{
|
{
|
||||||
this(ctx, smtpHost, from, to, subject, message, false);
|
this(ctx, smtpHost, from, to, subject, message, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Full Constructor
|
* Full Constructor
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
|
@ -127,7 +127,7 @@ public final class EMail implements Serializable
|
||||||
* @param message The message
|
* @param message The message
|
||||||
* @param html html email
|
* @param html html email
|
||||||
*/
|
*/
|
||||||
public EMail (Properties ctx, String smtpHost, String from, String to,
|
public EMail (Properties ctx, String smtpHost, String from, String to,
|
||||||
String subject, String message, boolean html)
|
String subject, String message, boolean html)
|
||||||
{
|
{
|
||||||
setSmtpHost(smtpHost);
|
setSmtpHost(smtpHost);
|
||||||
|
@ -209,9 +209,9 @@ public final class EMail implements Serializable
|
||||||
props.put("mail.store.protocol", "smtp");
|
props.put("mail.store.protocol", "smtp");
|
||||||
props.put("mail.transport.protocol", "smtp");
|
props.put("mail.transport.protocol", "smtp");
|
||||||
props.put("mail.host", m_smtpHost);
|
props.put("mail.host", m_smtpHost);
|
||||||
//Timeout for sending the email defaulted to 20 seconds
|
//Timeout for sending the email defaulted to 20 seconds
|
||||||
props.put("mail.smtp.timeout", 20000);
|
props.put("mail.smtp.timeout", 20000);
|
||||||
|
|
||||||
if (CLogMgt.isLevelFinest())
|
if (CLogMgt.isLevelFinest())
|
||||||
props.put("mail.debug", "true");
|
props.put("mail.debug", "true");
|
||||||
//
|
//
|
||||||
|
@ -226,7 +226,7 @@ public final class EMail implements Serializable
|
||||||
props.put("mail.smtp.port", "587");
|
props.put("mail.smtp.port", "587");
|
||||||
props.put("mail.smtp.starttls.enable", "true");
|
props.put("mail.smtp.starttls.enable", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
session = Session.getInstance(props, m_auth);
|
session = Session.getInstance(props, m_auth);
|
||||||
session.setDebug(CLogMgt.isLevelFinest());
|
session.setDebug(CLogMgt.isLevelFinest());
|
||||||
}
|
}
|
||||||
|
@ -331,7 +331,7 @@ public final class EMail implements Serializable
|
||||||
{
|
{
|
||||||
sb.append(" - Invalid Username/Password - " + m_auth);
|
sb.append(" - Invalid Username/Password - " + m_auth);
|
||||||
}
|
}
|
||||||
else // other MessagingException
|
else // other MessagingException
|
||||||
{
|
{
|
||||||
String msg = ex.getLocalizedMessage();
|
String msg = ex.getLocalizedMessage();
|
||||||
if (msg == null)
|
if (msg == null)
|
||||||
|
@ -360,7 +360,7 @@ public final class EMail implements Serializable
|
||||||
ex = ((MessagingException)ex).getNextException();
|
ex = ((MessagingException)ex).getNextException();
|
||||||
else
|
else
|
||||||
ex = null;
|
ex = null;
|
||||||
}
|
}
|
||||||
while (ex != null); // error loop
|
while (ex != null); // error loop
|
||||||
//
|
//
|
||||||
if (CLogMgt.isLevelFinest())
|
if (CLogMgt.isLevelFinest())
|
||||||
|
@ -391,7 +391,7 @@ public final class EMail implements Serializable
|
||||||
{
|
{
|
||||||
return m_sentMsg;
|
return m_sentMsg;
|
||||||
} // getSentMsg
|
} // getSentMsg
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Was sending the Msg OK
|
* Was sending the Msg OK
|
||||||
* @return msg == OK
|
* @return msg == OK
|
||||||
|
@ -400,7 +400,7 @@ public final class EMail implements Serializable
|
||||||
{
|
{
|
||||||
return m_sentMsg != null && SENT_OK.equals(m_sentMsg);
|
return m_sentMsg != null && SENT_OK.equals(m_sentMsg);
|
||||||
} // isSentOK
|
} // isSentOK
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump Message Info
|
* Dump Message Info
|
||||||
*/
|
*/
|
||||||
|
@ -664,7 +664,7 @@ public final class EMail implements Serializable
|
||||||
return m_replyTo;
|
return m_replyTo;
|
||||||
} // getReplyTo
|
} // getReplyTo
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Set Subject
|
* Set Subject
|
||||||
* @param newSubject Subject
|
* @param newSubject Subject
|
||||||
|
@ -757,16 +757,15 @@ public final class EMail implements Serializable
|
||||||
{
|
{
|
||||||
m_subject = subject;
|
m_subject = subject;
|
||||||
StringBuffer sb = new StringBuffer("<HTML>\n")
|
StringBuffer sb = new StringBuffer("<HTML>\n")
|
||||||
.append("<HEAD>\n")
|
.append("<HEAD>\n")
|
||||||
.append("<TITLE>\n")
|
.append("<TITLE>\n")
|
||||||
.append(subject + "\n")
|
.append(subject + "\n")
|
||||||
.append("</TITLE>\n")
|
.append("</TITLE>\n")
|
||||||
.append("</HEAD>\n");
|
.append("</HEAD>\n");
|
||||||
sb.append("<BODY>\n")
|
sb.append("<BODY>\n")
|
||||||
.append("<H2>" + subject + "</H2>" + "\n")
|
.append(message)
|
||||||
.append(message)
|
.append("\n")
|
||||||
.append("\n")
|
.append("</BODY>\n");
|
||||||
.append("</BODY>\n");
|
|
||||||
sb.append("</HTML>\n");
|
sb.append("</HTML>\n");
|
||||||
m_messageHTML = sb.toString();
|
m_messageHTML = sb.toString();
|
||||||
} // setMessageHTML
|
} // setMessageHTML
|
||||||
|
@ -792,7 +791,7 @@ public final class EMail implements Serializable
|
||||||
m_attachments = new ArrayList<DataSource>();
|
m_attachments = new ArrayList<DataSource>();
|
||||||
m_attachments.add(new FileDataSource(file));
|
m_attachments.add(new FileDataSource(file));
|
||||||
} // addAttachment
|
} // addAttachment
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a collection of attachments
|
* Add a collection of attachments
|
||||||
* @param files collection of files
|
* @param files collection of files
|
||||||
|
@ -932,7 +931,7 @@ public final class EMail implements Serializable
|
||||||
} // multi=part
|
} // multi=part
|
||||||
} // setContent
|
} // setContent
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Set SMTP Host or address
|
* Set SMTP Host or address
|
||||||
* @param newSmtpHost Mail server
|
* @param newSmtpHost Mail server
|
||||||
|
@ -972,10 +971,10 @@ public final class EMail implements Serializable
|
||||||
{
|
{
|
||||||
if (!recheck)
|
if (!recheck)
|
||||||
return m_valid;
|
return m_valid;
|
||||||
|
|
||||||
// From
|
// From
|
||||||
if (m_from == null
|
if (m_from == null
|
||||||
|| m_from.getAddress().length() == 0
|
|| m_from.getAddress().length() == 0
|
||||||
|| m_from.getAddress().indexOf(' ') != -1)
|
|| m_from.getAddress().indexOf(' ') != -1)
|
||||||
{
|
{
|
||||||
log.warning("From is invalid=" + m_from);
|
log.warning("From is invalid=" + m_from);
|
||||||
|
@ -990,7 +989,7 @@ public final class EMail implements Serializable
|
||||||
}
|
}
|
||||||
for (int i = 0; i < ias.length; i++)
|
for (int i = 0; i < ias.length; i++)
|
||||||
{
|
{
|
||||||
if (ias[i] == null
|
if (ias[i] == null
|
||||||
|| ias[i].getAddress().length() == 0
|
|| ias[i].getAddress().length() == 0
|
||||||
|| ias[i].getAddress().indexOf(' ') != -1)
|
|| ias[i].getAddress().indexOf(' ') != -1)
|
||||||
{
|
{
|
||||||
|
@ -1005,7 +1004,7 @@ public final class EMail implements Serializable
|
||||||
log.warning("SMTP Host is invalid" + m_smtpHost);
|
log.warning("SMTP Host is invalid" + m_smtpHost);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subject
|
// Subject
|
||||||
if (m_subject == null || m_subject.length() == 0)
|
if (m_subject == null || m_subject.length() == 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue