You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Dignesh <dg...@opentext.com> on 2017/08/29 10:02:57 UTC
geronimo-javamail_1.4_mail-1.9.0-alpha-2: sending email fails
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", "dignesh@test.com"); // 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("dignesh@test.com");
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.
Re: geronimo-javamail_1.4_mail-1.9.0-alpha-2: sending email fails
Posted by Matthew Broadhead <ma...@nbmlaw.co.uk>.
Hi,
i have a working setup. first i put the mail resource in
src/main/webapp/META-INF/context.xml like this
<?xml version="1.0" encoding="UTF-8"?>
<Context reloadable="true">
<Resource id="mail/Session" name="mail/Session" auth="Container"
type="javax.mail.Session" mail.smtp.host="mail.domain.tld"
mail.smtp.port="465" mail.smtp.auth="true"
mail.smtp.user="noreply@domain.tld"
mail.smtp.password="smtppassword" password="smtppassword"
mail.transport.protocol="smtp" mail.smtp.ssl.enable="true" />
</Context>
then i inject the resource like this
@Singleton
public class EmailAsync {
// set in /src/main/webapp/META-INF/context.xml
@Resource(name = "mail/Session")
private Session session;
...
public void sendEmail(EmailMessage emailMessage) {
...
Message msg = new MimeMessage(session);
...
Transport.send(msg);
On 29/08/2017 13:27, Romain Manni-Bucau wrote:
> Hi
>
> what is your mail server?
> can you activate the debug traces?
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> | Blog
> <https://blog-rmannibucau.rhcloud.com> | Old Blog
> <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
> <https://javaeefactory-rmannibucau.rhcloud.com>
>
> 2017-08-29 12:02 GMT+02:00 Dignesh <dg...@opentext.com>:
>
>> 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", "dignesh@test.com"); // 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("dignesh@test.com");
>>
>> 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.
>>
Re: geronimo-javamail_1.4_mail-1.9.0-alpha-2: sending email fails
Posted by Dignesh <dg...@opentext.com>.
Loading javamail.default.providers from
jar:file:/C:/Users/dgoyal/Desktop/geronimo-javamail_1.4_mail-1.7.jar!/META-INF/javamail.default.providers
DEBUG: loading new provider protocol=smtp,
className=org.apache.geronimo.javamail.transport.smtp.SMTPTransport,
vendor=Apache Software Foundation, version=1.0
DEBUG: loading new provider protocol=smtps,
className=org.apache.geronimo.javamail.transport.smtp.SMTPSTransport,
vendor=Apache Software Foundation, version=1.0
DEBUG: loading new provider protocol=nntp-post,
className=org.apache.geronimo.javamail.transport.nntp.NNTPTransport,
vendor=Apache Software Foundation, version=1.0
DEBUG: loading new provider protocol=nntp-posts,
className=org.apache.geronimo.javamail.transport.nntp.NNTPSSLTransport,
vendor=Apache Software Foundation, version=1.0
DEBUG: loading new provider protocol=nntp,
className=org.apache.geronimo.javamail.store.nntp.NNTPStore, vendor=Apache
Software Foundation, version=1.0
DEBUG: loading new provider protocol=nntps,
className=org.apache.geronimo.javamail.store.nntp.NNTPSSLStore,
vendor=Apache Software Foundation, version=1.0
DEBUG: loading new provider protocol=pop3,
className=org.apache.geronimo.javamail.store.pop3.POP3Store, vendor=Apache
Software Foundation, version=1.0
DEBUG: loading new provider protocol=pop3s,
className=org.apache.geronimo.javamail.store.pop3.POP3SSLStore,
vendor=Apache Software Foundation, version=1.0
DEBUG: loading new provider protocol=imap,
className=org.apache.geronimo.javamail.store.imap.IMAPStore, vendor=Apache
Software Foundation, version=1.0
DEBUG: loading new provider protocol=imaps,
className=org.apache.geronimo.javamail.store.imap.IMAPSSLStore,
vendor=Apache Software Foundation, version=1.0
DEBUG: getProvider() returning provider protocol=smtp;
type=javax.mail.Provider$Type@4769b07b;
class=org.apache.geronimo.javamail.transport.smtp.SMTPTransport;
vendor=Apache Software Foundation;version=1.0
smtp DEBUG: Attempting plain socket connection to server 10.96.132.189:25
220 10.96.132.189m Microsoft ESMTP MAIL Service, Version: 8.5.9600.16384
ready at Fri, 1 Sep 2017 09:43:45 +0530
EHLO dignesh123
250-10.96.132.189m Hello [10.96.132.81]
250-AUTH=LOGIN
250-AUTH LOGIN
250-TURN
250-SIZE
250-ETRN
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-8bitmime
250-BINARYMIME
250-CHUNKING
250-VRFY
250 OK
smtp DEBUG: Processing extension AUTH=LOGIN
smtp DEBUG: Processing extension AUTH LOGIN
smtp DEBUG: Processing extension TURN
smtp DEBUG: Processing extension SIZE
smtp DEBUG: Processing extension ETRN
smtp DEBUG: Processing extension PIPELINING
smtp DEBUG: Processing extension DSN
smtp DEBUG: Processing extension ENHANCEDSTATUSCODES
smtp DEBUG: Processing extension 8bitmime
smtp DEBUG: Processing extension BINARYMIME
smtp DEBUG: Processing extension CHUNKING
smtp DEBUG: Processing extension VRFY
smtp DEBUG: Processing extension OK
smtp DEBUG: Successful connection
MAIL FROM: <di...@test.com> SIZE=461
530 5.7.3 Client was not authenticated
QUIT
221 2.0.0 10.96.132.189 Service closing transmission channel
Exception in thread "main"
org.apache.geronimo.javamail.transport.smtp.SMTPSendFailedException: 5.7.3
Client was not authenticated
at
org.apache.geronimo.javamail.transport.smtp.SMTPTransport.sendMessage(SMTPTransport.java:257)
at javax.mail.Transport.send(Transport.java:95)
at javax.mail.Transport.send(Transport.java:48)
at dignesh.test.TestEmail.main(TestEmail.java:72)
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
Re: geronimo-javamail_1.4_mail-1.9.0-alpha-2: sending email fails
Posted by chongma <ma...@nbmlaw.co.uk>.
actually i just looked at my old code before i changed to loading session in
context.xml and this is how i used to create a mail session and authenticate
(before i changed to SSL).
private Session getSession() {
Authenticator authenticator = new Authenticator();
Properties properties = new Properties();
properties.setProperty("mail.smtp.submitter",
authenticator.getPasswordAuthentication().getUserName());
properties.setProperty("mail.smtp.auth", "true");
properties.setProperty("mail.smtp.host", "mail.domain.tld");
properties.setProperty("mail.smtp.port", "25");
return Session.getInstance(properties, authenticator);
}
private class Authenticator extends javax.mail.Authenticator {
private PasswordAuthentication authentication;
public Authenticator() {
String username = "user@domain.tld";
String password = "smtppassword";
authentication = new PasswordAuthentication(username, password);
}
protected PasswordAuthentication getPasswordAuthentication() {
return authentication;
}
}
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
Re: geronimo-javamail_1.4_mail-1.9.0-alpha-2: sending email fails
Posted by Dignesh <dg...@opentext.com>.
Hi Mathew , Romain
Thank you very much for your help on this.
I just debugged the code again. The issue was i was setting the boolean
value for "mail.smtp.auth" property.
p.put("mail.smtp.auth", true);
modified to
p.put("mail.smtp.auth", "true"); to resolve the issue. :)
Thank you very much once again.
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
Re: geronimo-javamail_1.4_mail-1.9.0-alpha-2: sending email fails
Posted by Romain Manni-Bucau <rm...@gmail.com>.
If you use tomee.xml or resources.xml yes, if you don't use the built-in
factory then you need to handle it yourself
Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>
2017-09-01 9:25 GMT+02:00 chongma <ma...@nbmlaw.co.uk>:
> so looking at line 31:
> final String password = properties.getProperty("password");
>
> that might mean the password should be passed as:
> p.put("password", "smtppassword");
>
> and it is not necessary to pass an Authenticator with
> PasswordAuthentication?
>
>
>
> --
> Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-
> f982480.html
>
Re: geronimo-javamail_1.4_mail-1.9.0-alpha-2: sending email fails
Posted by chongma <ma...@nbmlaw.co.uk>.
so looking at line 31:
final String password = properties.getProperty("password");
that might mean the password should be passed as:
p.put("password", "smtppassword");
and it is not necessary to pass an Authenticator with
PasswordAuthentication?
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
Re: geronimo-javamail_1.4_mail-1.9.0-alpha-2: sending email fails
Posted by Romain Manni-Bucau <rm...@gmail.com>.
For reference there can be some config changes after the 1.9 upgrade (
https://issues.apache.org/jira/browse/TOMEE-1697). Would be good to ensure
1. you authenticator is actually called (if the LOGIN fails it can be it
read the password from the session properties where it is not. FYI here is
how tomee instantiate sessions
https://github.com/apache/tomee/blob/master/container/openejb-core/src/main/java/org/apache/openejb/core/MailSessionFactory.java
(which is not the case if you use context.xml)
Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>
2017-09-01 9:00 GMT+02:00 chongma <ma...@nbmlaw.co.uk>:
> is the server protected by TLS or SSL? or is it open?
>
> if SSL protected have you tried:
> p.put("mail.smtp.auth", "true");
> p.put("mail.smtp.ssl.enable", "true");
>
> Also have you tried loading Mail Session as a Resource in context.xml (or
> tomee.xml) as per my previous example? I didn't have much luck configuring
> it the way you are describing.
>
> Regards,
> Matthew
>
>
>
> --
> Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-
> f982480.html
>
Re: geronimo-javamail_1.4_mail-1.9.0-alpha-2: sending email fails
Posted by chongma <ma...@nbmlaw.co.uk>.
is the server protected by TLS or SSL? or is it open?
if SSL protected have you tried:
p.put("mail.smtp.auth", "true");
p.put("mail.smtp.ssl.enable", "true");
Also have you tried loading Mail Session as a Resource in context.xml (or
tomee.xml) as per my previous example? I didn't have much luck configuring
it the way you are describing.
Regards,
Matthew
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
Re: geronimo-javamail_1.4_mail-1.9.0-alpha-2: sending email fails
Posted by Dignesh <dg...@opentext.com>.
Hi Romain,
Thank you very much for quick reply.
Can you try to set mail.smtp.auth before creating the session?
- I added this -still it doesnt work
Also maybe debug in your authenticator to check it is well used.
- I haven't understood what needs to be done here .can you please elaborate
on this .
Thank you,
Dignesh
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
Re: geronimo-javamail_1.4_mail-1.9.0-alpha-2: sending email fails
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi Dignesh,
Can you try to set mail.smtp.auth before creating the session? Also maybe
debug in your authenticator to check it is well used.
Le 1 sept. 2017 06:22, "Dignesh" <dg...@opentext.com> a écrit :
Loading javamail.default.providers from
jar:file:/C:/Users/dgoyal/Desktop/geronimo-javamail_1.4_
mail-1.7.jar!/META-INF/javamail.default.providers
DEBUG: loading new provider protocol=smtp,
className=org.apache.geronimo.javamail.transport.smtp.SMTPTransport,
vendor=Apache Software Foundation, version=1.0
DEBUG: loading new provider protocol=smtps,
className=org.apache.geronimo.javamail.transport.smtp.SMTPSTransport,
vendor=Apache Software Foundation, version=1.0
DEBUG: loading new provider protocol=nntp-post,
className=org.apache.geronimo.javamail.transport.nntp.NNTPTransport,
vendor=Apache Software Foundation, version=1.0
DEBUG: loading new provider protocol=nntp-posts,
className=org.apache.geronimo.javamail.transport.nntp.NNTPSSLTransport,
vendor=Apache Software Foundation, version=1.0
DEBUG: loading new provider protocol=nntp,
className=org.apache.geronimo.javamail.store.nntp.NNTPStore, vendor=Apache
Software Foundation, version=1.0
DEBUG: loading new provider protocol=nntps,
className=org.apache.geronimo.javamail.store.nntp.NNTPSSLStore,
vendor=Apache Software Foundation, version=1.0
DEBUG: loading new provider protocol=pop3,
className=org.apache.geronimo.javamail.store.pop3.POP3Store, vendor=Apache
Software Foundation, version=1.0
DEBUG: loading new provider protocol=pop3s,
className=org.apache.geronimo.javamail.store.pop3.POP3SSLStore,
vendor=Apache Software Foundation, version=1.0
DEBUG: loading new provider protocol=imap,
className=org.apache.geronimo.javamail.store.imap.IMAPStore, vendor=Apache
Software Foundation, version=1.0
DEBUG: loading new provider protocol=imaps,
className=org.apache.geronimo.javamail.store.imap.IMAPSSLStore,
vendor=Apache Software Foundation, version=1.0
DEBUG: getProvider() returning provider protocol=smtp;
type=javax.mail.Provider$Type@4769b07b;
class=org.apache.geronimo.javamail.transport.smtp.SMTPTransport;
vendor=Apache Software Foundation;version=1.0
smtp DEBUG: Attempting plain socket connection to server 10.96.132.189:25
220 10.96.132.189m Microsoft ESMTP MAIL Service, Version: 8.5.9600.16384
ready at Fri, 1 Sep 2017 09:43:45 +0530
EHLO dignesh123
250-10.96.132.189m Hello [10.96.132.81]
250-AUTH=LOGIN
250-AUTH LOGIN
250-TURN
250-SIZE
250-ETRN
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-8bitmime
250-BINARYMIME
250-CHUNKING
250-VRFY
250 OK
smtp DEBUG: Processing extension AUTH=LOGIN
smtp DEBUG: Processing extension AUTH LOGIN
smtp DEBUG: Processing extension TURN
smtp DEBUG: Processing extension SIZE
smtp DEBUG: Processing extension ETRN
smtp DEBUG: Processing extension PIPELINING
smtp DEBUG: Processing extension DSN
smtp DEBUG: Processing extension ENHANCEDSTATUSCODES
smtp DEBUG: Processing extension 8bitmime
smtp DEBUG: Processing extension BINARYMIME
smtp DEBUG: Processing extension CHUNKING
smtp DEBUG: Processing extension VRFY
smtp DEBUG: Processing extension OK
smtp DEBUG: Successful connection
MAIL FROM: <di...@test.com> SIZE=461
530 5.7.3 Client was not authenticated
QUIT
221 2.0.0 10.96.132.189 Service closing transmission channel
Exception in thread "main"
org.apache.geronimo.javamail.transport.smtp.SMTPSendFailedException: 5.7.3
Client was not authenticated
at
org.apache.geronimo.javamail.transport.smtp.SMTPTransport.
sendMessage(SMTPTransport.java:257)
at javax.mail.Transport.send(Transport.java:95)
at javax.mail.Transport.send(Transport.java:48)
at dignesh.test.TestEmail.main(TestEmail.java:72)
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
Re: geronimo-javamail_1.4_mail-1.9.0-alpha-2: sending email fails
Posted by Dignesh <dg...@opentext.com>.
Loading javamail.default.providers from
jar:file:/C:/Users/dgoyal/Desktop/geronimo-javamail_1.4_mail-1.7.jar!/META-INF/javamail.default.providers
DEBUG: loading new provider protocol=smtp,
className=org.apache.geronimo.javamail.transport.smtp.SMTPTransport,
vendor=Apache Software Foundation, version=1.0
DEBUG: loading new provider protocol=smtps,
className=org.apache.geronimo.javamail.transport.smtp.SMTPSTransport,
vendor=Apache Software Foundation, version=1.0
DEBUG: loading new provider protocol=nntp-post,
className=org.apache.geronimo.javamail.transport.nntp.NNTPTransport,
vendor=Apache Software Foundation, version=1.0
DEBUG: loading new provider protocol=nntp-posts,
className=org.apache.geronimo.javamail.transport.nntp.NNTPSSLTransport,
vendor=Apache Software Foundation, version=1.0
DEBUG: loading new provider protocol=nntp,
className=org.apache.geronimo.javamail.store.nntp.NNTPStore, vendor=Apache
Software Foundation, version=1.0
DEBUG: loading new provider protocol=nntps,
className=org.apache.geronimo.javamail.store.nntp.NNTPSSLStore,
vendor=Apache Software Foundation, version=1.0
DEBUG: loading new provider protocol=pop3,
className=org.apache.geronimo.javamail.store.pop3.POP3Store, vendor=Apache
Software Foundation, version=1.0
DEBUG: loading new provider protocol=pop3s,
className=org.apache.geronimo.javamail.store.pop3.POP3SSLStore,
vendor=Apache Software Foundation, version=1.0
DEBUG: loading new provider protocol=imap,
className=org.apache.geronimo.javamail.store.imap.IMAPStore, vendor=Apache
Software Foundation, version=1.0
DEBUG: loading new provider protocol=imaps,
className=org.apache.geronimo.javamail.store.imap.IMAPSSLStore,
vendor=Apache Software Foundation, version=1.0
DEBUG: getProvider() returning provider protocol=smtp;
type=javax.mail.Provider$Type@4769b07b;
class=org.apache.geronimo.javamail.transport.smtp.SMTPTransport;
vendor=Apache Software Foundation;version=1.0
smtp DEBUG: Attempting plain socket connection to server 10.96.132.189:25
220 10.96.132.189m Microsoft ESMTP MAIL Service, Version: 8.5.9600.16384
ready at Fri, 1 Sep 2017 09:43:45 +0530
EHLO dignesh123
250-10.96.132.189m Hello [10.96.132.81]
250-AUTH=LOGIN
250-AUTH LOGIN
250-TURN
250-SIZE
250-ETRN
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-8bitmime
250-BINARYMIME
250-CHUNKING
250-VRFY
250 OK
smtp DEBUG: Processing extension AUTH=LOGIN
smtp DEBUG: Processing extension AUTH LOGIN
smtp DEBUG: Processing extension TURN
smtp DEBUG: Processing extension SIZE
smtp DEBUG: Processing extension ETRN
smtp DEBUG: Processing extension PIPELINING
smtp DEBUG: Processing extension DSN
smtp DEBUG: Processing extension ENHANCEDSTATUSCODES
smtp DEBUG: Processing extension 8bitmime
smtp DEBUG: Processing extension BINARYMIME
smtp DEBUG: Processing extension CHUNKING
smtp DEBUG: Processing extension VRFY
smtp DEBUG: Processing extension OK
smtp DEBUG: Successful connection
MAIL FROM: <di...@test.com> SIZE=461
530 5.7.3 Client was not authenticated
QUIT
221 2.0.0 10.96.132.189 Service closing transmission channel
Exception in thread "main"
org.apache.geronimo.javamail.transport.smtp.SMTPSendFailedException: 5.7.3
Client was not authenticated
at
org.apache.geronimo.javamail.transport.smtp.SMTPTransport.sendMessage(SMTPTransport.java:257)
at javax.mail.Transport.send(Transport.java:95)
at javax.mail.Transport.send(Transport.java:48)
at dignesh.test.TestEmail.main(TestEmail.java:72)
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
Re: geronimo-javamail_1.4_mail-1.9.0-alpha-2: sending email fails
Posted by Romain Manni-Bucau <rm...@gmail.com>.
just add in properties mail.debug=true
BTW, why not using tomee.xml to define this resource? We have some code
using this decriptor to handle the authentication a default resource
wouldn't have.
Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>
2017-08-29 13:38 GMT+02:00 Dignesh <dg...@opentext.com>:
> Hi Romain,
> I am using IIS as my mail server.
> can you please let me know on what package you want debug trace to be
> enabled.
>
> Thank you,
> Dignesh,
>
>
>
>
>
> --
> 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-tp4682494p4682497.html
> Sent from the TomEE Dev mailing list archive at Nabble.com.
>
Re: geronimo-javamail_1.4_mail-1.9.0-alpha-2: sending email fails
Posted by Dignesh <dg...@opentext.com>.
Hi Romain,
I am using IIS as my mail server.
can you please let me know on what package you want debug trace to be
enabled.
Thank you,
Dignesh,
--
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-tp4682494p4682497.html
Sent from the TomEE Dev mailing list archive at Nabble.com.
Re: geronimo-javamail_1.4_mail-1.9.0-alpha-2: sending email fails
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi
what is your mail server?
can you activate the debug traces?
Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>
2017-08-29 12:02 GMT+02:00 Dignesh <dg...@opentext.com>:
> 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", "dignesh@test.com"); // 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("dignesh@test.com");
>
> 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.
>