Re: sending emails with authentication

Chris Burdess <[email protected]> Mon, 27 Sep 2010 15:39:20 +0100
Newsgroups gmane.comp.java.classpath.extensions.javamail
Message-ID <[email protected]>
Daniel Rindt wrote:
> thanks for your efforts. This example is connecting via imaps to the
> mailserver properly seems. But covers not my use case, i want sending =
a
> email.=20
> So i add a line like this:
> =3D=3D=3D 8< =3D=3D=3D
> Transport transport =3D session.getTransport(url);
> =3D=3D=3D 8< =3D=3D=3D
> I couldn't use imaps i got an exeption that no Provider is available
> for. So i use just imap for testing. But when i wan't the transport
> object it told me:
> =3D=3D=3D 8< =3D=3D=3D
> javax.mail.NoSuchProviderException: invalid provider
> =3D=3D=3D 8< =3D=3D=3D
>=20
> So i would like to ask you if you can provide please a working example
> for sending emails with that server? Thanks.


IMAP is only a mail retrieval protocol, you cannot get a transport for =
this provider. You need a transport protocol like SMTP:

Transport transport =3D session.getTransport("smtp");

For how to send a message, see the testSendMessage method of =
test/src/TransportTest.java in the GNUMail distribution.
--=20
Chris Burdess