Saltar para o conteúdo principal
Versão: 20 R7 BETA

SMTP New transporter

SMTP New transporter( server : Object ) : 4D.SMTPTransporter

ParâmetroTipoDescrição
serverObjectInformação de servidor de correio
Resultado4D.SMTPTransporterSMTP transporter object
História
ReleaseMudanças
18Nova propriedade logFile
17 R5Novas propriedades bodyCharset e headerCharset
17 R4Adicionado

Descrição

The SMTP New transporter command configures a new SMTP connection according to the server parameter and returns a new SMTP transporter object object. O objecto transportador devolvido será então normalmente utilizado para enviar mensagens de correio electrónico.

Este comando não abre qualquer ligação com o servidor SMTP. The SMTP connection is actually opened when the .send() function is executed.

A coleção SMTP é automaticamente fechada:

  • when the transporter object is destroyed if the keepAlive property is true (default),
  • after each .send() function execution if the keepAlive property is set to false.

No parâmetro server, passe um objeto contendo as propriedades abaixo:

serverValor padrão (se omitido)
.acceptUnsecureConnection : Boolean
True if 4D is allowed to establish an unencrypted connection
False
.accessTokenOAuth2: Text
.accessTokenOAuth2: Objeto
Cadeia ou objeto token que representa as credenciais de autorização OAuth2. Usado somente com OAUTH2 authenticationMode. Se accessTokenOAuth2 for usado, mas authenticationMode for omitido, o protocolo OAuth 2 será usado (se permitido pelo servidor). Not returned in SMTP transporter object.
nenhum
.authenticationMode : Text
the authentication mode used to open the session on the mail server
o modo de autenticação mais seguro disponível no servidor é usado
.bodyCharset : Text
the charset and encoding used for the body part of the email
mail mode UTF8 (US-ASCII_UTF8_QP)
.connectionTimeOut : Integer
the maximum wait time (in seconds) allowed to establish a connection to the server
30
.headerCharset : Text
the charset and encoding used for the email header
mail mode UTF8 (US-ASCII_UTF8_QP)
.host : Text
the name or the IP address of the host server
mandatory
.keepAlive : Boolean
True if the SMTP connection must be kept alive until the transporter object is destroyed
True
.logFile : Text
the path of the extended log file defined (if any) for the mail connection
nenhum
password : Text
Senha do usuário para autenticação no servidor. Not returned in SMTP transporter object.
nenhum
.port : Integer
the port number used for mail transactions
587
.sendTimeOut : Integer
the maximum wait time (in seconds) of a call to .send( ) before a timeout occurs
100
.user : Text
the user name used for authentication on the mail server
nenhum

Resultados

The function returns a SMTP transporter object. Todas as propriedades retornadas são apenas leitura.

Exemplo

 $server:=New object
$server.host:="smtp.gmail.com" //Mandatory
$server.port:=465
$server.user:="4D@gmail.com"
$server.password:="XXXX"
$server.logFile:="LogTest.txt" //Extended log to save in the Logs folder

var $transporter : 4D.SMTPTransporter
$transporter:=SMTP New transporter($server)

$email:=New object
$email.subject:="my first mail "
$email.from:="4d@gmail.com"
$email.to:="4d@4d.com;test@4d.com"
$email.textBody:="Hello World"
$email.htmlBody:="<h1>Hello World</h1><h4>'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...'</h4>\
<p>There are many variations of passages of Lorem Ipsum available."\
+"The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.</p>"

$status:=$transporter.send($email)
If(Not($status.success))
ALERT("An error occurred sending the mail: "+$status.message)
End if