Go to the documentation of this file.
32 #define TRACE_LEVEL SMTP_TRACE_LEVEL
43 #if (SMTP_CLIENT_SUPPORT == ENABLED)
56 context->state = newState;
82 reply = context->buffer;
88 if(context->bufferPos < context->commandLen)
92 context->buffer + context->bufferPos,
93 context->commandLen - context->bufferPos, &
n, 0);
99 context->bufferPos +=
n;
105 if(context->replyLen != 0 && reply[context->replyLen - 1] ==
'\n')
123 context->buffer + context->replyLen,
131 context->replyLen +=
n;
137 reply[context->replyLen] =
'\0';
151 if(reply[3] ==
' ' || reply[3] ==
'\0')
154 context->replyCode =
osStrtoul(reply, NULL, 10);
165 error = callback(context, reply);
169 context->replyLen = 0;
175 context->replyLen = 0;
205 osSprintf(context->buffer,
"%s: <%s>\r\n", command, argument);
210 osSprintf(context->buffer,
"%s: <>\r\n", command);
231 osSprintf(context->buffer,
"%s %s\r\n", command, argument);
236 osSprintf(context->buffer,
"%s\r\n", command);
244 context->commandLen =
osStrlen(context->buffer);
247 context->bufferPos = 0;
248 context->replyLen = 0;
287 context->startTlsSupported =
TRUE;
302 context->authLoginSupported =
TRUE;
307 context->authPlainSupported =
TRUE;
312 context->authCramMd5Supported =
TRUE;
356 if(from->
addr != NULL)
359 if(from->
name && from->
name[0] !=
'\0')
375 for(first =
TRUE, i = 0; i < numRecipients; i++)
378 if(recipients[i].
addr != NULL)
417 if(recipients[i].
name && recipients[i].
name[0] !=
'\0')
444 if(subject != NULL && subject[0] !=
'\0')
450 #if (SMTP_CLIENT_MIME_SUPPORT == ENABLED)
452 if(context->contentType[0] !=
'\0')
459 if(
osStrncasecmp(context->contentType,
"multipart/", 10) == 0)
462 p +=
osSprintf(
p,
"Content-Type: %s; boundary=%s\r\n",
463 context->contentType, context->boundary);
469 p +=
osSprintf(
p,
"Content-Type: %s\r\n", context->contentType);
481 context->bufferLen =
osStrlen(context->buffer);
482 context->bufferPos = 0;
507 #if (SMTP_CLIENT_MIME_SUPPORT == ENABLED)
520 p +=
osSprintf(
p,
"\r\n--%s\r\n", context->boundary);
526 p +=
osSprintf(
p,
"Content-Disposition: attachment; filename=\"%s\"\r\n",
531 if(contentType != NULL && contentType[0] !=
'\0')
535 p +=
osSprintf(
p,
"Content-Type: %s\r\n", contentType);
539 if(contentTransferEncoding != NULL && contentTransferEncoding[0] !=
'\0')
543 p +=
osSprintf(
p,
"Content-Transfer-Encoding: %s\r\n",
544 contentTransferEncoding);
547 if(
osStrcasecmp(contentTransferEncoding,
"base64") == 0)
549 context->base64Encoding =
TRUE;
560 p +=
osSprintf(
p,
"\r\n--%s--\r\n", context->boundary);
570 context->bufferLen =
osStrlen(context->buffer);
571 context->bufferPos = 0;
590 #if (NET_RTOS_SUPPORT == DISABLED)
String manipulation helper functions.
#define SMTP_CLIENT_BUFFER_SIZE
void strRemoveTrailingSpace(char_t *s)
Removes all trailing whitespace from a string.
Transport protocol abstraction layer.
#define timeCompare(t1, t2)
error_t smtpClientFormatMultipartHeader(SmtpClientContext *context, const char_t *filename, const char_t *contentType, const char_t *contentTransferEncoding, bool_t last)
Format multipart header.
void smtpClientChangeState(SmtpClientContext *context, SmtpClientState newState)
Update SMTP client state.
Helper functions for SMTP client.
@ ERROR_INVALID_PARAMETER
Invalid parameter.
#define osStrncasecmp(s1, s2, length)
SMTP client (Simple Mail Transfer Protocol)
SmtpClientState
SMTP client states.
#define SmtpClientContext
#define osSprintf(dest,...)
error_t smtpClientParseEhloReply(SmtpClientContext *context, char_t *replyLine)
Parse EHLO response.
#define osStrtok_r(s, delim, last)
#define osStrcasecmp(s1, s2)
uint32_t systime_t
System time.
#define osStrtoul(s, endptr, base)
error_t(* SmtpClientReplyCallback)(SmtpClientContext *context, char_t *replyLine)
Multiline reply parsing callback function.
error_t smtpClientReceiveData(SmtpClientContext *context, void *data, size_t size, size_t *received, uint_t flags)
Receive data using the relevant transport protocol.
error_t smtpClientFormatMailHeader(SmtpClientContext *context, const SmtpMailAddr *from, const SmtpMailAddr *recipients, uint_t numRecipients, const char_t *subject)
Format email header.
error_t smtpClientFormatCommand(SmtpClientContext *context, const char_t *command, const char_t *argument)
Format SMTP command.
error_t smtpClientSendData(SmtpClientContext *context, const void *data, size_t length, size_t *written, uint_t flags)
Send data using the relevant transport protocol.
error_t smtpClientSendCommand(SmtpClientContext *context, SmtpClientReplyCallback callback)
Send SMTP command and wait for a reply.
error_t smtpClientCheckTimeout(SmtpClientContext *context)
Determine whether a timeout error has occurred.
systime_t osGetSystemTime(void)
Retrieve system time.