Saltar al contenido principal
Versión: 20 R5 BETA

POP3Transporter

The POP3Transporter class allows you to retrieve messages from a POP3 email server.

Objeto POP3 Transporter

POP3 Transporter objects are instantiated with the POP3 New transporter command. Ofrecen las siguientes propiedades y funciones:

.acceptUnsecureConnection : Boolean    True if 4D is allowed to establish an unencrypted connection
.authenticationMode : Text    the authentication mode used to open the session on the mail server
.checkConnection() : Object     checks the connection using information stored in the transporter object
.connectionTimeOut : Integer    the maximum wait time (in seconds) allowed to establish a connection to the server
.delete( msgNumber : Integer )    flags the msgNumber email for deletion from the POP3 server
.getBoxInfo() : Object    returns a boxInfo object corresponding to the mailbox designated by the POP3 transporter
.getMail( msgNumber : Integer { ; headerOnly : Boolean } ) : Object    returns the Email object corresponding to the msgNumber in the mailbox designated by the POP3 transporter
.getMailInfo( msgNumber : Integer ) : Object    returns a mailInfo object corresponding corresponding to the msgNumber in the mailbox designated by the POP3 transporter
.getMailInfoList() : Collection    returns a collection of mailInfo objects describing all messages in the mailbox designated by the POP3 transporter
.getMIMEAsBlob( msgNumber : Integer ) : Blob    returns a BLOB containing the MIME contents for the message corresponding to the msgNumber in the mailbox designated by the POP3_transporter
.host : Text    the name or the IP address of the host server
.logFile : Text    the path of the extended log file defined (if any) for the mail connection
.port : Integer     the port number used for mail transactions
.undeleteAll()    removes all delete flags set on the emails in the POP3_transporter
.user : Text     the user name used for authentication on the mail server

POP3 New transporter

Historia
LanzamientoModificaciones
18 R2Añadidos

POP3 New transporter( server : Object ) : 4D.POP3Transporter

ParámetrosTipoDescripción
serverobject->Información del servidor de correo
Result4D.POP3Transporter<-POP3 transporter object

Descripción

The POP3 New transporter command configures a new POP3 connectionaccording to the server parameter and returns a new POP3 transporter object. El objeto transportador devuelto se utilizará normalmente para recibir correos electrónicos.

In the server parameter, pass an object containing the following properties:

serverValor por defecto (si se omite)
.acceptUnsecureConnection : Boolean&nbsp;&nbsp;&nbsp;&nbsp;True if 4D is allowed to establish an unencrypted connectionFalse
.accessTokenOAuth2: Text
.accessTokenOAuth2: Object
Text string or token object representing OAuth2 authorization credentials. Used only with OAUTH2 authenticationMode. If accessTokenOAuth2 is used but authenticationMode is omitted, the OAuth 2 protocol is used (if allowed by the server). Not returned in SMTP transporter object.
ninguno
.authenticationMode : Text&nbsp;&nbsp;&nbsp;&nbsp;the authentication mode used to open the session on the mail serverse utiliza el modo de autenticación más seguro soportado por el servidor
.connectionTimeOut : Integer&nbsp;&nbsp;&nbsp;&nbsp;the maximum wait time (in seconds) allowed to establish a connection to the server30
.host : Text&nbsp;&nbsp;&nbsp;&nbsp;the name or the IP address of the host serverobligatorio
.logFile : Text&nbsp;&nbsp;&nbsp;&nbsp;the path of the extended log file defined (if any) for the mail connectionninguno
.password : Text
User password for authentication on the server. Not returned in SMTP transporter object.
ninguno
.port : Integer&nbsp;&nbsp;&nbsp;&nbsp; the port number used for mail transactions995
.user : Text&nbsp;&nbsp;&nbsp;&nbsp; the user name used for authentication on the mail serverninguno

Result

The function returns a POP3 transporter object. All returned properties are read-only.

La conexión POP3 se cierra automáticamente cuando se destruye el objeto transportador.

Ejemplo

 var $server : Object
$server:=New object
$server.host:="pop.gmail.com" //Obligatorio
$server.port:=995
$server.user:="4d@gmail.com"
$server.password:="XXXXXXXX"
$server.logFile:="LogTest.txt" //log a registrar en la carpeta Logs

var $transporter : 4D.POP3Transporter
$transporter:=POP3 New transporter($server)

$status:=$transporter.checkConnection()
If(Not($status.success))
ALERT("An error occurred receiving the mail: "+$status.statusText)
End if

4D.POP3Transporter.new()

4D.POP3Transporter.new( server : Object ) : 4D.POP3Transporter

ParámetrosTipoDescripción
serverObject->Información del servidor de correo
Result4D.POP3Transporter<-POP3 transporter object

Descripción

The 4D.POP3Transporter.new() function creates and returns a new object of the 4D.POP3Transporter type. It is identical to the POP3 New transporter command (shortcut).

.acceptUnsecureConnection

Historia
LanzamientoModificaciones
17 R4Añadidos

.acceptUnsecureConnection : Boolean

Descripción

The .acceptUnsecureConnection property contains True if 4D is allowed to establish an unencrypted connection when encrypted connection is not possible.

It contains False if unencrypted connections are unallowed, in which case an error in returned when encrypted connection is not possible.

Los puertos seguros disponibles son:

  • SMTP

    • 465: SMTPS
    • 587 o 25: SMTP con actualización STARTTLS si lo soporta el servidor.
  • IMAP

    • 143: Puerto IMAP no encriptado
    • 993: IMAP con actualización STARTTLS si lo soporta el servidor
  • POP3

    • 110: Puerto POP3 no encriptado
    • 995: POP3 con actualización STARTTLS si lo soporta el servidor.

.authenticationMode

Historia
LanzamientoModificaciones
17 R4Añadidos

.authenticationMode : Text

Descripción

The .authenticationMode property contains the authentication mode used to open the session on the mail server.

Por defecto, se utiliza el modo más seguro soportado por el servidor.

Los valores posibles son:

ValorConstantesComentario
APOPPOP3 authentication APOPAuthentication using APOP protocol (POP3 only)
CRAM-MD5POP3 authentication CRAM MD5Autenticación utilizando el protocolo CRAM-MD5
LOGINPOP3 authentication loginAutenticación utilizando el protocolo LOGIN
OAUTH2POP3 authentication OAUTH2Autenticación utilizando el protocolo OAuth2
PLAINPOP3 authentication plainAutenticación utilizando el protocolo PLAIN

.checkConnection()

Historia
LanzamientoModificaciones
17 R4Añadidos

.checkConnection() : Object

ParámetrosTipoDescripción
ResultObject<-Estado de la conexión del objeto transportador

Descripción

The .checkConnection() function checks the connection using information stored in the transporter object, recreates the connection if necessary, and returns the status. Esta función permite verificar que los valores proporcionados por el usuario son válidos y coherentes.

Objeto devuelto

La función envía una solicitud al servidor de correo y devuelve un objeto que describe el estado del correo. Este objeto puede contener las siguientes propiedades:

PropiedadTipoDescripción
successbooleanTrue si la verificación es exitosa, False en caso contrario
statusnumber(sólo SMTP) Código de estado devuelto por el servidor de correo (0 en caso de un problema no relacionado con el procesamiento del correo)
statusTexttextMensaje de estado devuelto por el servidor de correo, o último error devuelto en la pila de errores de 4D
errorscollectionPila de errores 4D (no se devuelve si se recibe una respuesta del servidor de correo)
[ ].errCodenumberCódigo de error 4D
[ ].messagetextDescripción del error 4D
[ ].componentSignaturetextFirma del componente interno que ha devuelto el error

Ejemplo

 var $pw :  Text
var $options : Object
$options:=New object

$pw:=Request("Please enter your password:")
if(OK=1)
$options.host:="pop3.gmail.com"

$options.user:="test@gmail.com"
$options.password:=$pw

$transporter:=POP3 New transporter($options)

$status:=$transporter.checkConnection()
If($status.success)
ALERT("POP3 connection check successful!")
Else
ALERT("Error: "+$status.statusText)
End if
End if

.connectionTimeOut

Historia
LanzamientoModificaciones
17 R5Añadidos

.connectionTimeOut : Integer

Descripción

The .connectionTimeOut property contains the maximum wait time (in seconds) allowed to establish a connection to the server. By default, if the property has not been set in the server object (used to create the transporter object with SMTP New transporter, POP3 New transporter, or IMAP New transporter), the value is 30.

.delete()

Historia
LanzamientoModificaciones
18 R2Añadidos

.delete( msgNumber : Integer )

ParámetrosTipoDescripción
msgNumberInteger->Número del mensaje a eliminar
Descripción

The .delete( ) function flags the msgNumber email for deletion from the POP3 server.

In the msgNumber parameter, pass the number of the email to delete. This number is returned in the number property by the .getMailInfoList() method.

La ejecución de este método no elimina realmente ningún correo electrónico. The flagged email will be deleted from the POP3 server only when the POP3_transporter object (created with POP3 New transporter) is destroyed. The flag could be also be removed using the .undeleteAll() method.

Si la sesión actual termina inesperadamente y se cierra la conexión (por ejemplo, por tiempo de espera, fallo de la red, etc.), se genera un mensaje de error y los mensajes marcados para ser borrados permanecerán en el servidor POP3.

Ejemplo
 $mailInfoList:=$POP3_transporter.getMailInfoList()
For each($mailInfo;$mailInfoList)
// Marcar el correo como "a eliminar al final de la sesión"
$POP3_transporter.delete($mailInfo.number)
End for each
// Forzar el cierre de sesión para eliminar los correos marcados para ser borrados
CONFIRM("Selected messages will be deleted.";"Delete";"Undo")
If(OK=1) //borrado confirmado
$POP3_transporter:=Null
Else
$POP3_transporter.undeleteAll() //eliminar los marcadores de eliminación
End if

.getBoxInfo()

Historia
LanzamientoModificaciones
18 R2Añadidos

.getBoxInfo() : Object

ParámetrosTipoDescripción
ResultObject<-objeto boxInfo
Descripción

The .getBoxInfo() function returns a boxInfo object corresponding to the mailbox designated by the POP3 transporter. Esta función permite recuperar la información sobre el buzón.

The boxInfo object returned contains the following properties:

PropiedadTipoDescripción
mailCountNumberNúmero de mensajes en el buzón
sizeNumberTamaño del mensaje en bytes
Ejemplo
 var $server; $boxinfo : Object

$server:=New object
$server.host:="pop.gmail.com" //Obligatorio
$server.port:=995
$server.user:="4d@gmail.com"
$server.password:="XXXXXXXX"

$transporter:=POP3 New transporter($server)

//mailbox info
$boxInfo:=$transporter.getBoxInfo()
ALERT("The mailbox contains "+String($boxInfo.mailCount)+" messages.")

.getMail()

Historia
LanzamientoModificaciones
20Support of headerOnly parameter
18 R2Añadidos

.getMail( msgNumber : Integer { ; headerOnly : Boolean } ) : Object

ParámetrosTipoDescripción
msgNumberInteger->Número del mensaje en la lista
headerOnlyBoolean->True para descargar sólo los encabezados del correo electrónico (por defecto, False)
ResultObject<-Email object
Descripción

The .getMail() function returns the Email object corresponding to the msgNumber in the mailbox designated by the POP3 transporter. Esta función permite recuperar la información sobre el email.

Pass in msgNumber the number of the message to retrieve. This number is returned in the number property by the .getMailInfoList() function.

Optionally, you can pass true in the headerOnly parameter to exclude the body parts from the returned Email object. Only headers properties (headers, to, from...) se devuelven. Esta opción permite optimizar el paso de descarga cuando hay muchos correos electrónicos en el servidor.

nota

The headerOnly option may not be supported by the server.

El método devuelve Null si:

  • msgNumber designates a non-existing message,
  • the message was marked for deletion using .delete().

Objeto devuelto

.getMail() returns an Email object.

Ejemplo

Quiere saber el remitente del primer correo del buzón:

 var $server; $transporter : Object
var $mailInfo : Collection
var $sender : Variant

$server:=New object
$server.host:="pop.gmail.com" //Obligatorio
$server.port:=995
$server.user:="4d@gmail.com"
$server.password:="XXXXXXXX"

$transporter:=POP3 New transporter($server)

$mailInfo:=$transporter.getMailInfoList()

$sender:=$transporter.getMail($mailInfo[0].number).from

.getMailInfo()

Historia
LanzamientoModificaciones
18 R2Añadidos

.getMailInfo( msgNumber : Integer ) : Object

ParámetrosTipoDescripción
msgNumberInteger->Número del mensaje en la lista
ResultObject<-objeto mailInfo
Descripción

The .getMailInfo() function returns a mailInfo object corresponding corresponding to the msgNumber in the mailbox designated by the POP3 transporter. Esta función permite gestionar localmente la lista de mensajes localizados en el servidor de correo POP3.

In msgNumber, pass the number of the message to retrieve. This number is returned in the number property by the .getMailInfoList() method.

The mailInfo object returned contains the following properties:

PropiedadTipoDescripción
sizeNumberTamaño del mensaje en bytes
idTextID único del mensaje

The method returns Null if:

  • msgNumber designates a non-existing message,
  • the message was marked for deletion using .delete( ).
Ejemplo
 var $server; $mailInfo : Object
var $mailNumber : Integer

$server.host:="pop.gmail.com" //Mandatory
$server.port:=995
$server.user:="4d@gmail.com"
$server.password:="XXXXXXXX"

var $transporter : 4D.POP3Transporter
$transporter:=POP3 New transporter($server)

//message info
$mailInfo:=$transporter.getMailInfo(1) //get the first mail
If($mailInfo #Null)
ALERT("First mail size is:"+String($mailInfo.size)+" bytes.")
End if

.getMailInfoList()

Historia
LanzamientoModificaciones
18 R2Añadidos

.getMailInfoList() : Collection

ParámetrosTipoDescripción
ResultCollection<-Collection of mailInfo objects
Descripción

The .getMailInfoList() function returns a collection of mailInfo objects describing all messages in the mailbox designated by the POP3 transporter. Esta función permite gestionar localmente la lista de mensajes localizados en el servidor de correo POP3.

Each mailInfo object in the returned collection contains the following properties:

PropiedadTipoDescripción
[ ].sizeNumberTamaño del mensaje en bytes
[ ].numberNumberNúmero del mensaje
[ ].idTextID único del mensaje (útil si almacena el mensaje localmente)

Si el buzón no contiene ningún mensaje, se devuelve una colección vacía.

Propiedades number e ID

number is the number of a message in the mailbox at the time the POP3_transporter was created. The number property is not a static value in relation to any specific message and will change from session to session dependent on its relation to other messages in the mailbox at the time the session was opened. The numbers assigned to the messages are only valid during the lifetime of the POP3_transporter. At the time the POP3_transporter is deleted any message marked for deletion will be removed. Cuando el usuario vuelva a conectarse al servidor, los mensajes actuales en el buzón serán renumerados de 1 a x.

The id however is a unique number assigned to the message when it was received by the server. Este número se calcula utilizando la hora y la fecha de recepción del mensaje y es un valor asignado por su servidor POP3. Unfortunately, POP3 servers do not use the id as the primary reference to their messages. Throughout the POP3 sessions you will need to specify the number as the reference to messages on the server. Los desarrolladores deben tener cierto cuidado si desarrollan soluciones que introducen referencias a los mensajes en una base de datos pero dejan el cuerpo del mensaje en el servidor.

Ejemplo

Quiere saber el número total y el tamaño de los correos electrónicos en el buzón:

 var $server : Object
$server:=New object
$server.host:="pop.gmail.com" //Obligatorio
$server.port:=995
$server.user:="4d@gmail.com"
$server.password:="XXXXXXXX"

var $transporter : 4D.POP3Transporter
$transporter:=POP3 New transporter($server)

C_COLLECTION($mailInfo)
C_LONGINT($vNum;$vSize)

$mailInfo:=$transporter.getMailInfoList()
$vNum:=$mailInfo.length
$vSize:=$mailInfo.sum("size")

ALERT("The mailbox contains "+String($vNum)+" message(s) for "+String($vSize)+" bytes.")

.getMIMEAsBlob()

Historia
LanzamientoModificaciones
18 R3Añadidos

.getMIMEAsBlob( msgNumber : Integer ) : Blob

ParámetrosTipoDescripción
msgNumberInteger->Número del mensaje en la lista
ResultBlob<-Blob de la cadena MIME devuelta por el servidor de correo
Descripción

The .getMIMEAsBlob() function returns a BLOB containing the MIME contents for the message corresponding to the msgNumber in the mailbox designated by the POP3_transporter.

In msgNumber, pass the number of the message to retrieve. This number is returned in the number property by the .getMailInfoList() method.

El método devuelve un BLOB vacío si:

  • msgNumber designates a non-existing message,
  • the message was marked for deletion using .delete().

BLOB devuelto

.getMIMEAsBlob() returns a BLOB which can be archived in a database or converted to an Email object with the MAIL Convert from MIME command.

Ejemplo

Quiere saber el número total y el tamaño de los correos electrónicos en el buzón:

 var $server : Object
var $mailInfo : Collection
var $blob : Blob
var $transporter : 4D.POP3Transporter

$server:=New object
$server.host:="pop.gmail.com"
$server.port:=995
$server.user:="4d@gmail.com"
$server.password:="XXXXXXXX"

$transporter:=POP3 New transporter($server)

$mailInfo:=$transporter.getMailInfoList()
$blob:=$transporter.getMIMEAsBlob($mailInfo[0].number)

.host

Historia
LanzamientoModificaciones
17 R5Añadidos

.host : Text

Descripción

The .host property contains the name or the IP address of the host server. Se utiliza para las transacciones de correo (SMTP, POP3, IMAP).

.logFile

Historia
LanzamientoModificaciones
17 R5Añadidos

.logFile : Text

Descripción

The .logFile property contains the path of the extended log file defined (if any) for the mail connection. Puede ser relativo (a la carpeta actual Logs) o absoluto.

Unlike regular log files (enabled via the SET DATABASE PARAMETER command), extended log files store MIME contents of all sent mails and do not have any size limit. Para más información sobre los archivos de registro extendidos, consulte:

.port

Historia
LanzamientoModificaciones
17 R4Añadidos

.port : Integer

Descripción

The .port property contains the port number used for mail transactions. By default, if the port property has not been set in the server object (used to create the transporter object with SMTP New transporter, POP3 New transporter, IMAP New transporter), the port used is:

  • SMTP - 587
  • POP3 - 995
  • IMAP - 993

.undeleteAll()

Historia
LanzamientoModificaciones
18 R2Añadidos

.undeleteAll()

ParámetrosTipoDescripción
No requiere ningún parámetro
Descripción

The .undeleteAll() function removes all delete flags set on the emails in the POP3_transporter.

.user

Historia
LanzamientoModificaciones
17 R4Añadidos

.user : Text

Descripción

The .user property contains the user name used for authentication on the mail server.