Helper functions for SMTP client. More...
#include <stdlib.h>
#include <ctype.h>
#include "core/net.h"
#include "smtp/smtp_client.h"
#include "smtp/smtp_client_transport.h"
#include "smtp/smtp_client_misc.h"
#include "str.h"
#include "debug.h"
Go to the source code of this file.
Macros | |
#define | TRACE_LEVEL SMTP_TRACE_LEVEL |
Functions | |
void | smtpClientChangeState (SmtpClientContext *context, SmtpClientState newState) |
Update SMTP client state. More... | |
error_t | smtpClientSendCommand (SmtpClientContext *context, SmtpClientReplyCallback callback) |
Send SMTP command and wait for a reply. More... | |
error_t | smtpClientFormatCommand (SmtpClientContext *context, const char_t *command, const char_t *argument) |
Format SMTP command. More... | |
error_t | smtpClientParseEhloReply (SmtpClientContext *context, char_t *replyLine) |
Parse EHLO response. More... | |
error_t | smtpClientFormatMailHeader (SmtpClientContext *context, const SmtpMailAddr *from, const SmtpMailAddr *recipients, uint_t numRecipients, const char_t *subject) |
Format email header. More... | |
error_t | smtpClientFormatMultipartHeader (SmtpClientContext *context, const char_t *filename, const char_t *contentType, const char_t *contentTransferEncoding, bool_t last) |
Format multipart header. More... | |
error_t | smtpClientCheckTimeout (SmtpClientContext *context) |
Determine whether a timeout error has occurred. More... | |
Detailed Description
Helper functions for SMTP client.
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneTCP Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- Version
- 2.4.4
Definition in file smtp_client_misc.c.
Macro Definition Documentation
◆ TRACE_LEVEL
#define TRACE_LEVEL SMTP_TRACE_LEVEL |
Definition at line 32 of file smtp_client_misc.c.
Function Documentation
◆ smtpClientChangeState()
void smtpClientChangeState | ( | SmtpClientContext * | context, |
SmtpClientState | newState | ||
) |
Update SMTP client state.
- Parameters
-
[in] context Pointer to the SMTP client context [in] newState New state to switch to
Definition at line 54 of file smtp_client_misc.c.
◆ smtpClientCheckTimeout()
error_t smtpClientCheckTimeout | ( | SmtpClientContext * | context | ) |
Determine whether a timeout error has occurred.
- Parameters
-
[in] context Pointer to the SMTP client context
- Returns
- Error code
Definition at line 590 of file smtp_client_misc.c.
◆ smtpClientFormatCommand()
error_t smtpClientFormatCommand | ( | SmtpClientContext * | context, |
const char_t * | command, | ||
const char_t * | argument | ||
) |
Format SMTP command.
- Parameters
-
[in] context Pointer to the SMTP client context [in] command NULL-terminated string containing the SMTP command [in] argument NULL-terminated string containing the argument
- Returns
- Error code
Definition at line 196 of file smtp_client_misc.c.
◆ smtpClientFormatMailHeader()
error_t smtpClientFormatMailHeader | ( | SmtpClientContext * | context, |
const SmtpMailAddr * | from, | ||
const SmtpMailAddr * | recipients, | ||
uint_t | numRecipients, | ||
const char_t * | subject | ||
) |
Format email header.
- Parameters
-
[in] context Pointer to the SMTP client context [in] from Email address of the sender [in] recipients Email addresses of the recipients [in] numRecipients Number of email addresses in the list [in] subject NULL-terminated string containing the email subject
- Returns
- Error code
Definition at line 345 of file smtp_client_misc.c.
◆ smtpClientFormatMultipartHeader()
error_t smtpClientFormatMultipartHeader | ( | SmtpClientContext * | context, |
const char_t * | filename, | ||
const char_t * | contentType, | ||
const char_t * | contentTransferEncoding, | ||
bool_t | last | ||
) |
Format multipart header.
- Parameters
-
[in] context Pointer to the SMTP client context [in] filename NULL-terminated string that holds the file name (optional parameter) [in] contentType NULL-terminated string that holds the content type (optional parameter) [in] contentTransferEncoding NULL-terminated string that holds the content transfer encoding (optional parameter) [in] last This flag indicates whether the multipart header is the final one
- Returns
- Error code
Definition at line 505 of file smtp_client_misc.c.
◆ smtpClientParseEhloReply()
error_t smtpClientParseEhloReply | ( | SmtpClientContext * | context, |
char_t * | replyLine | ||
) |
Parse EHLO response.
- Parameters
-
[in] context SMTP client context [in] replyLine Response line
- Returns
- Error code
Definition at line 264 of file smtp_client_misc.c.
◆ smtpClientSendCommand()
error_t smtpClientSendCommand | ( | SmtpClientContext * | context, |
SmtpClientReplyCallback | callback | ||
) |
Send SMTP command and wait for a reply.
- Parameters
-
[in] context Pointer to the SMTP client context [in] callback Optional callback to parse each line of the reply
- Returns
- Error code
Definition at line 72 of file smtp_client_misc.c.