4D Internet Commands v14

SMTP_Auth

Home

 
4D Internet Commands v14
SMTP_Auth

SMTP_Auth 


 

SMTP_Auth ( smtp_ID ; userName ; password {; authMode} ) -> Function result 
Parameter Type   Description
smtp_ID  Longint in Message reference
userName  String in User name to be used for SMTP authentication
password  String in Password to be used for SMTP authentication
authMode  Integer in Authentication mode to be used: 0 or omitted = Mode defined by server 1= PLAIN, 2 = LOGIN, 3 = CRAM-MD5
Function result  Integer in Error code

The SMTP_Auth command allows sending a message referenced by smtp_ID when an authentication mechanism is required by the SMTP server. This type of authentication is required by some SMTP servers in order to reduce the risk that messages have been falsified or that the sender's identity has been usurped, in particular for the purpose of spamming.

This command can be used whether authentication is needed or not since it is only executed if userName and password are not null strings.

smtp_ID is the long integer reference to the mail message created with the SMTP_New command.

userName is the authentication user name on the SMTP server. userName should not contain the domain. For example, for the address “jack@4d.com,” userName would just be “jack.”

password is the authentication password for userName on the SMTP server.

Note: If userName and/or password are null strings, the SMTP_Auth command is not executed.

The optional authMode parameter allows the “forcing” of the authentication mode used. You can pass 0, 1, 2 or 3 in this parameter:

  • If you pass 0 (zero), the authentication mode used by the SMTP_Auth command will be the most secure mode supported by the server (CRAM-MD5, LOGIN then PLAIN),
  • If you pass 1, the authentication method used will be PLAIN,
  • If you pass 2, the authentication method used will be LOGIN,
  • If you pass 3, the authentication method used will be CRAM-MD5.
    If authMode is omitted, the value 0 is used by default. If the authentication method requested by this parameter is not supported by the SMTP server, an error is returned.

Example  

This example enables sending a message with or without authentication depending on the content of specific fields stored in the 4D database:

 C_INTEGER($vError)
 C_LONGINT($vSmtp_id)
 C_STRING(30;$vAuthUserName;$vAuthPassword)
 
 $vError:=SMTP_New($vSmtp_id)
 $vError:=SMTP_Host($vSmtp_id;"wkrp.com")
 $vError:=SMTP_From($vSmtp_id;"herb_tarlick@wkrp.com")
 $vError:=SMTP_Subject($vSmtp_id;"Are you there?")
 $vError:=SMTP_To($vSmtp_id;"Dupont@wkrp.com")
 $vError:=SMTP_Body($vSmtp_id;"Can we have a meeting?")
 
  ` The fields are entered if the server uses an authentication
  ` mechanism. Otherwise, null strings are returned.
 $vAuthUserName:=[Account]AuthUser
 $vAuthPassword:=[Account]AuthPass
 
 $vError:=SMTP_Auth($vSmtp_id;$vAuthUserName;$vAuthPassword)
 $vError:=SMTP_Send($vSmtp_id)
 $vError:=SMTP_Clear($vSmtp_id)

 
PROPERTIES 

Product: 4D Internet Commands
Theme: IC Send Mail
Number: 88851

 
HISTORY 

Modified: 4D Internet Commands 2003

 
ARTICLE USAGE

4D Internet Commands ( 4D Internet Commands v11.4)
4D Internet Commands ( 4D v13.2)
4D Internet Commands ( 4D Internet Commands v12.1)
4D Internet Commands ( 4D Internet Commands v14 R2)
4D Internet Commands ( 4D Internet Commands v14)
4D Internet Commands ( 4D Internet Commands v14 R3)
4D Internet Commands ( 4D Internet Commands v14 R4)