version 6.8.2
SMTP_Auth (smtp_ID; userName; password) Integer
| Parameter | Type | Description | |
| smtp_ID | Longint | Message reference | |
| userName | String | User name to be used for SMTP authentication | |
| password | String | Password to be used for SMTP authentication | |
| Function result | Integer | Error code |
Description
The SMTP_Auth command allows sending a mesage 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.
Note : This command is compatible with the CRAM-MD5, PLAIN and LOGIN authentication mechanisms.
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 be just "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.
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
;30;$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)