KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Authenticating to an SMTP server using SMTP_auth
PRODUCT: 4D | VERSION: | PLATFORM: Mac & Win
Published On: May 9, 2003

Version: 6.8.x, 2003

To help reduce spam, some mail servers require mail clients to send a SMTP_auth before allowing mail to be relayed. SMTP_auth allows authentication to an SMTP server using one of the AUTH methods PLAIN, LOGIN or CRAM-MD5.

When using 4D Internet commands to send mail, to authenticate with a mail server requiring SMTP authentication, use the command SMTP_Auth.

This command is compatible with the CRAM-MD5, PLAIN and LOGIN authentication mechanisms.

A small example:

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)