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.ru: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
<ignore>
s_client -starttls smtp -connect smtpgateway.enkod.ru:587 ehlo testmail.ru auth plain AABfN3lhTUZtcm5hZ251VFRXR1lueVNiQWNLX2R4VTh4WWWVYdzV2UzBYXVpMQ== mail from:[email protected] rcpt to:[email protected] data Date: Thu, 29 Sep 2022 15:42:13 GMT From: [email protected] To: [email protected] 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><ignore><!--[if (mso 16)]></ignore> <ignore><style type<ignore>=</ignore>"text/css"></ignore> a {text-decoration: none;} <ignore></head></ignore> <ignore><html></ignore> <ignore><body></ignore> message body <ignore></body></ignore> <ignore></html></ignore> <ignore>
</ignore></ignore></ignore>
<ignore>=====</ignore> Possible errors <ignore>=====</ignore>
- <ignore><ignore>
</ignore></ignore>invalid from email<ignore><ignore>
</ignore></ignore> - the sending email does not match the structure of [email protected]. - <ignore><ignore>
</ignore></ignore>
</ignore></ignore>no username or password<ignore><ignore></ignore></ignore> - AUTH PLAIN authentication is not used. * <ignore><ignore>
</ignore></ignore></ignore></ignore>api key doesn't have accesses<ignore><ignore>
</ignore></ignore> - no SMTP access for API key - <ignore><ignore>
</ignore></ignore>client is deleted<ignore><ignore>
</ignore></ignore> - account is inactive or deleted - <ignore><ignore>
</ignore></ignore>internal service error<ignore><ignore>
</ignore></ignore> - internal service error - <ignore><ignore>
</ignore></ignore>wrong api key<ignore><ignore>
</ignore></ignore> - API key is invalid