TomEE 7.0.2 :-
Sending email fails. javamail's Transport.send(...) function throws an
exception. For me looks like some issue with
"geronimo-javamail_1.4_mail-1.9.0-alpha-2.jar" jar.
If I add different mail.jar in lib folder the same code works fine
Attached the 2 jars and the sample code.
Can anyone help me to figure out what is the issue
Thank you,
Dignesh
/**
*
*/
package dignesh.test;
import java.util.Date;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.Multipart;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
/**
* @author dgoyal
*
*/
public class TestEmail
{
/**
* @param args
*/
public static void main(String[] args) throws Exception
{
Properties p = System.getProperties();
// initialize mail properties
p.put("mail.smtp.host", "10.96.132.189"); // email server
p.put("mail.smtp.user", "smtpuser"); // sender's email address, used
for
// connecting to email server
p.put("mail.from", "[email protected]"); // sender's email address,
// displayed in the "from"
// field
p.put("mail.store.protocol", "pop3");
p.put("mail.transport.protocol", "smtp");
p.put("mail.smtp.port", 25);
Session session = null;
session = Session.getInstance(p, new javax.mail.Authenticator()
{
@Override
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication("smtpuser", "smtppassword!");
}
});
session.getProperties().put("mail.smtp.auth", true);
MimeMessage msg = new MimeMessage(session);
msg.setFrom();
InternetAddress addressList[] = new InternetAddress[1];
addressList[0] = new InternetAddress("[email protected]");
msg.setRecipients(Message.RecipientType.TO, addressList);
msg.setSubject("Test", "UTF-8");
Multipart multiPart = new MimeMultipart();
MimeBodyPart bodyPart = new MimeBodyPart();
bodyPart.setText("Hello Test email", "UTF-8");
multiPart.addBodyPart(bodyPart);
msg.setContent(multiPart); // add the multipart to the message
msg.setSentDate(new Date()); // fill in "date sent"
Transport.send(msg); // off it goes...
}
}
geronimo-javamail_1.jar
<http://tomee-openejb.979440.n4.nabble.com/file/n4682494/geronimo-javamail_1.jar>
javax.jar
<http://tomee-openejb.979440.n4.nabble.com/file/n4682494/javax.jar>
--
View this message in context:
http://tomee-openejb.979440.n4.nabble.com/geronimo-javamail-1-4-mail-1-9-0-alpha-2-sending-email-fails-tp4682494.html
Sent from the TomEE Dev mailing list archive at Nabble.com.