I have the below mail program. The problem is mail program runs successfully but it doesn't send me the emails. The logs say it's mailed successfully. Not sure what might be the problem. Do i need to change the Java Program?
I have the below values set in the application.properties
file and these values get read from the program and passed as vector to the send function
mail.smtp.host=excha.testing.com
mail.smtp.techEmail="[email protected]"
mail.smtp.toEmail="[email protected]"
[email protected]
mail.smtp.fromName=Testing test Systems
mailHandler.send(mailingAddress,ccEmailAddress,fromEmailAddress,fromEmailAlias,envName + "::" + " Process", exitMessage + " - " + message))
-----------------------Mail Send Program code pasted below---------
public synchronized boolean send(Vector eMailAddress, Vector ccEmailAddress, String
fromEmailAddress, String fromEmailAlias, String messageSubject, String messageText)
{
try
{
Message msg = new MimeMessage(session);
msg.setSubject(messageSubject);
msg.setText(messageText);
InternetAddress addresses[] = new InternetAddress[eMailAddress.size()];
for (int i = 0; i < eMailAddress.size(); i++ ) {
addresses[i] = new InternetAddress((String)(eMailAddress.elementAt(i)));
}
msg.setRecipients(Message.RecipientType.TO, addresses);
InternetAddress ccAddresses[] = new InternetAddress[ccEmailAddress.size()];
for (int i = 0; i < ccEmailAddress.size(); i++ ) {
ccAddresses[i] = new InternetAddress((String)(ccEmailAddress.elementAt(i)));
}
msg.setRecipients(Message.RecipientType.CC, ccAddresses);
if ((null != fromEmailAddress) && (null != fromEmailAlias))
{
msg.setFrom(new InternetAddress(fromEmailAddress, fromEmailAlias));
}
else if ((null != fromEmailAddress) && (null == fromEmailAlias))
{
msg.setFrom(new InternetAddress(fromEmailAddress));
}
else if ((null == fromEmailAddress) && (null == fromEmailAlias))
{
String smtpFromEmail
= (ApplicationProperties.getApplicationProperties()).getProperty(SMTP_FROM_EMAIL_KEY);
String smtpFromName
= (ApplicationProperties.getApplicationProperties()).getProperty(SMTP_FROM_NAME_KEY);
if (null == smtpFromEmail || "".equals(smtpFromEmail))
{
smtpFromEmail = SENDER_EMAIL;
}
if (null == smtpFromName || "".equals(smtpFromName))
{
smtpFromName = SENDER_NAME;
}
msg.setFrom(new InternetAddress(smtpFromEmail, smtpFromName));
}
Transport.send(msg);
cat.debug("Sent message to " + eMailAddress);
return true;
} catch (Exception e)
{
cat.error("Error sending email", e);
return false;
}
}