SMTP gate
What is an SMTP gate
SMTP-gate is a way to send us jobs to send emails via the SMTP protocol. The difference between API and SMTP is the data transfer protocol used: SMTP or HTTP protocol. With the SMTP protocol, a sequence of commands is used to send to the server.
Authorisation and sending a message
The enKod authentication is done using SMTP keys. Obtain an SMTP key from your personal SMTP manager to use the SMTP gateway.
Connect to the SMTP server at address: smtpgateway.enkod.io:587
Use the following command sequence:
STARTTLS- after entering this command, all further communication between the client and the server takes place via encrypted TLS protocol.EHLO- welcome message, in response we receive a list of server settingsAUTH PLAIN- base64 encoded login and password (only SMTP API key as password is required for authentication, login is left blank)MAIL FROM- email address from which the message will be sentRCPT TO- email address to which the message is to be sentDATA- after entering this command you can enter the message body with headers.
Example of a request to send via openssl
s_client -starttls smtp -connect smtpgateway.enkod.ru:587
ehlo testmail.ru
auth plain AABfN3lhTUZtcm5hZ251VFRXR1lueVNiQWNLX2R4VTh4WWVYdzV2UzBYXVpMQ==
mail from:test@testmail.ru
rcpt to:test2@testmail.ru
data
Date: Thu, 29 Sep 2022 15:42:13 GMT
From: test@testmail.ru
To: test2@testmail.ru
Subject: subject
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xmlns:o="urn:schemas-microsoft-com:office:office" style="font-family:'open sans', 'helvetica neue', helvetica, arial, sans-serif">
<head>
<meta charset="UTF-8"/>
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<meta name="x-apple-disable-message-reformatting"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta content="telephone=no" name="format-detection"/>
<title>title</title><!--[if (mso 16)]>
<style type="text/css">
a {text-decoration: none;}
</head>
<html>
<body>
message body
</body>
</html>
Possible errors
invalid from email- the sending email does not match the structure of name@domain.com.no username or password- AUTH PLAIN authentication is not used.api key doesn't have accesses- no SMTP access for API keyclient is deleted- account is inactive or deletedinternal service error- internal service errorwrong api key- API key is invalid