API java : javax.mail


Package javax.mail

The JavaMailTM API provides classes that model a mail system.

See:
          Description

Interface Summary
MessageAware An interface optionally implemented by DataSources to supply information to a DataContentHandler about the message context in which the data content object is operating.
MultipartDataSource MultipartDataSource is a DataSource that contains body parts.
Part The Part interface is the common base interface for Messages and BodyParts.
QuotaAwareStore An interface implemented by Stores that support quotas.
UIDFolder The UIDFolder interface is implemented by Folders that can support the "disconnected" mode of operation, by providing unique-ids for messages in the folder.
 

Class Summary
Address This abstract class models the addresses in a message.
Authenticator The class Authenticator represents an object that knows how to obtain authentication for a network connection.
BodyPart This class models a Part that is contained within a Multipart.
FetchProfile Clients use a FetchProfile to list the Message attributes that it wishes to prefetch from the server for a range of messages.
FetchProfile.Item This inner class is the base class of all items that can be requested in a FetchProfile.
Flags The Flags class represents the set of flags on a Message.
Flags.Flag This inner class represents an individual system flag.
Folder Folder is an abstract class that represents a folder for mail messages.
Header The Header class stores a name/value pair to represent headers.
Message This class models an email message.
Message.RecipientType This inner class defines the types of recipients allowed by the Message class.
MessageContext The context in which a piece of Message content is contained.
Multipart Multipart is a container that holds multiple body parts.
PasswordAuthentication The class PasswordAuthentication is a data holder that is used by Authenticator.
Provider The Provider is a class that describes a protocol implementation.
Provider.Type This inner class defines the Provider type.
Quota This class represents a set of quotas for a given quota root.
Quota.Resource An individual resource in a quota root.
Service An abstract class that contains the functionality common to messaging services, such as stores and transports.
Session The Session class represents a mail session and is not subclassed.
Store An abstract class that models a message store and its access protocol, for storing and retrieving messages.
Transport An abstract class that models a message transport.
UIDFolder.FetchProfileItem A fetch profile item for fetching UIDs.
URLName The name of a URL.
 

Exception Summary
AuthenticationFailedException This exception is thrown when the connect method on a Store or Transport object fails due to an authentication failure (e.g., bad user name or password).
FolderClosedException This exception is thrown when a method is invoked on a Messaging object and the Folder that owns that object has died due to some reason.
FolderNotFoundException This exception is thrown by Folder methods, when those methods are invoked on a non existent folder.
IllegalWriteException The exception thrown when a write is attempted on a read-only attribute of any Messaging object.
MessageRemovedException The exception thrown when an invalid method is invoked on an expunged Message.
MessagingException The base class for all exceptions thrown by the Messaging classes
MethodNotSupportedException The exception thrown when a method is not supported by the implementation
NoSuchProviderException This exception is thrown when Session attempts to instantiate a Provider that doesn't exist.
ReadOnlyFolderException This exception is thrown when an attempt is made to open a folder read-write access when the folder is marked read-only.
SendFailedException This exception is thrown when the message cannot be sent.
StoreClosedException This exception is thrown when a method is invoked on a Messaging object and the Store that owns that object has died due to some reason.
 

Package javax.mail Description

The JavaMailTM API provides classes that model a mail system. The javax.mail package defines classes that are common to all mail systems. The javax.mail.internet package defines classes that are specific to mail systems based on internet standards such as MIME, SMTP, POP3, and IMAP. The JavaMail API includes the javax.mail package and subpackages.

For an overview of the JavaMail API, read the JavaMail specification included in the download bundle or available on the JavaMail web site.

The code to send a plain text message can be as simple as the following:

    Properties props = new Properties();
    props.put("mail.smtp.host", "my-mail-server");
    props.put("mail.from", "me@example.com");
    Session session = Session.getInstance(props, null);

    try {
        MimeMessage msg = new MimeMessage(session);
        msg.setFrom();
        msg.setRecipients(Message.RecipientType.TO,
                          "you@example.com");
        msg.setSubject("JavaMail hello world example");
        msg.setSentDate(new Date());
        msg.setText("Hello, world!\n");
        Transport.send(msg);
    } catch (MessagingException mex) {
        System.out.println("send failed, exception: " + mex);
    }
The JavaMail download bundle contains many more complete examples in the "demo" directory.

Don't forget to see the JavaMail API FAQ for answers to the most common questions. The JavaMail web site contains many additional resources.

The JavaMail API supports the following standard properties, which may be set in the Session object, or in the Properties object used to create the Session object. The properties are always set as strings; the Type column describes how the string is interpreted. For example, use

        props.put("mail.debug", "true");
to set the mail.debug property, which is of type boolean.

Name Type Description
mail.debug boolean The initial debug mode. Default is false.
mail.from String The return email address of the current user, used by the InternetAddress method getLocalAddress.
mail.mime.address.strict boolean The MimeMessage class uses the InternetAddress method parseHeader to parse headers in messages. This property controls the strict flag passed to the parseHeader method. The default is true.
mail.host String The default host name of the mail server for both Stores and Transports. Used if the mail.protocol.host property isn't set.
mail.store.protocol String Specifies the default message access protocol. The Session method getStore() returns a Store object that implements this protocol. By default the first Store provider in the configuration files is returned.
mail.transport.protocol String Specifies the default message access protocol. The Session method getTransport() returns a Transport object that implements this protocol. By default the first Transport provider in the configuration files is returned.
mail.user String The default user name to use when connecting to the mail server. Used if the mail.protocol.user property isn't set.
mail.protocol.class String Specifies the fully qualified class name of the provider for the specified protocol. Used in cases where more than one provider for a given protocol exists; this property can be used to specify which provider to use by default. The provider must still be listed in a configuration file.
mail.protocol.host String The host name of the mail server for the specified protocol. Overrides the mail.host property.
mail.protocol.port int The port number of the mail server for the specified protocol. If not specified the protocol's default port number is used.
mail.protocol.user String The user name to use when connecting to mail servers using the specified protocol. Overrides the mail.user property.

The JavaMail API also supports several System properties; see the javax.mail.internet package documentation for details.

The JavaMail reference implementation from Sun includes protocol providers in subpackages of com.sun.mail. Note that the APIs to these protocol providers are not part of the standard JavaMail API. Portable programs will not use these APIs.

Nonportable programs may use the APIs of the Sun protocol providers by (for example) casting a returned Folder object to a com.sun.mail.imap.IMAPFolder object. Similarly for Store and Message objects returned from the standard JavaMail APIs.

The Sun protocol providers also support properties that are specific to those providers. The package documentation for the IMAP, POP3, and SMTP packages provide details.


Ces informations proviennent du site de http://java.sun.com

Remarques

Contenu

Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :

Quels sont les motivations de cette démarche?

Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.

Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.

Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.

Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.

Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.

Réseaux sociaux

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.

 

Nuage de mots clés

6 mots clés dont 0 définis manuellement (plus d'information...).

Avertissement

Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.

 

Astuce pour imprimer les couleurs des cellules de tableaux : http://www.gaudry.be/ast-rf-450.html
Aucun commentaire pour cette page

© Ce document issu de l′infobrol est enregistré sous le certificat Cyber PrInterDeposit Digital Numbertection. Enregistrement IDDN n° 5329-12507
Document créé le 24/12/07 03:38, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-javaee-rf-javax/mail/package-summary.html Document affiché 1 fois ce mois de Juin.
St.Gaudry©07.01.02
Outils (masquer)
||
Recherche (afficher)
Recherche :

Utilisateur (masquer)
Apparence (afficher)
Stats (afficher)
15832 documents
452 astuces.
549 niouzes.
3099 definitions.
447 membres.
8115 messages.

Document genere en :
0,64 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
Toute recette requiert un ingrédient que vous n'avez pas dans votre cuisine. Si vous voulez l'acheter, les magasins viennent de fermer. Et si vous arrivez à vous le procurer, il en manque un autre.

Loi de Murphy
 
l'infobrol
Nous sommes le Vendredi 01 Juin 2012, 10:00, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)