Go to the documentation of this file.
32 #define TRACE_LEVEL SMTP_TRACE_LEVEL
45 #if (SMTP_CLIENT_SUPPORT == ENABLED)
58 context->state = newState;
84 reply = context->buffer;
90 if(context->bufferPos < context->commandLen)
94 context->buffer + context->bufferPos,
95 context->commandLen - context->bufferPos, &
n, 0);
101 context->bufferPos +=
n;
107 if(context->replyLen != 0 && reply[context->replyLen - 1] ==
'\n')
125 context->buffer + context->replyLen,
133 context->replyLen +=
n;
139 reply[context->replyLen] =
'\0';
153 if(reply[3] ==
' ' || reply[3] ==
'\0')
156 context->replyCode =
osStrtoul(reply, NULL, 10);
167 error = callback(context, reply);
171 context->replyLen = 0;
177 context->replyLen = 0;
207 osSprintf(context->buffer,
"%s: <%s>\r\n", command, argument);
212 osSprintf(context->buffer,
"%s: <>\r\n", command);
233 osSprintf(context->buffer,
"%s %s\r\n", command, argument);
238 osSprintf(context->buffer,
"%s\r\n", command);
246 context->commandLen =
osStrlen(context->buffer);
249 context->bufferPos = 0;
250 context->replyLen = 0;
289 context->startTlsSupported =
TRUE;
304 context->authLoginSupported =
TRUE;
309 context->authPlainSupported =
TRUE;
314 context->authCramMd5Supported =
TRUE;
358 if(from->
addr != NULL)
361 if(from->
name && from->
name[0] !=
'\0')
377 for(first =
TRUE, i = 0; i < numRecipients; i++)
380 if(recipients[i].
addr != NULL)
419 if(recipients[i].
name && recipients[i].
name[0] !=
'\0')
446 if(subject != NULL && subject[0] !=
'\0')
452 #if (SMTP_CLIENT_MIME_SUPPORT == ENABLED)
454 if(context->contentType[0] !=
'\0')
461 if(
osStrncasecmp(context->contentType,
"multipart/", 10) == 0)
464 p +=
osSprintf(
p,
"Content-Type: %s; boundary=%s\r\n",
465 context->contentType, context->boundary);
471 p +=
osSprintf(
p,
"Content-Type: %s\r\n", context->contentType);
483 context->bufferLen =
osStrlen(context->buffer);
484 context->bufferPos = 0;
509 #if (SMTP_CLIENT_MIME_SUPPORT == ENABLED)
522 p +=
osSprintf(
p,
"\r\n--%s\r\n", context->boundary);
528 p +=
osSprintf(
p,
"Content-Disposition: attachment; filename=\"%s\"\r\n",
533 if(contentType != NULL && contentType[0] !=
'\0')
537 p +=
osSprintf(
p,
"Content-Type: %s\r\n", contentType);
541 if(contentTransferEncoding != NULL && contentTransferEncoding[0] !=
'\0')
545 p +=
osSprintf(
p,
"Content-Transfer-Encoding: %s\r\n",
546 contentTransferEncoding);
549 if(
osStrcasecmp(contentTransferEncoding,
"base64") == 0)
551 context->base64Encoding =
TRUE;
562 p +=
osSprintf(
p,
"\r\n--%s--\r\n", context->boundary);
572 context->bufferLen =
osStrlen(context->buffer);
573 context->bufferPos = 0;
592 #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.