smtp_client_misc.c File Reference

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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.0

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]contextPointer to the SMTP client context
[in]newStateNew 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]contextPointer 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]contextPointer to the SMTP client context
[in]commandNULL-terminated string containing the SMTP command
[in]argumentNULL-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]contextPointer to the SMTP client context
[in]fromEmail address of the sender
[in]recipientsEmail addresses of the recipients
[in]numRecipientsNumber of email addresses in the list
[in]subjectNULL-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]contextPointer to the SMTP client context
[in]filenameNULL-terminated string that holds the file name (optional parameter)
[in]contentTypeNULL-terminated string that holds the content type (optional parameter)
[in]contentTransferEncodingNULL-terminated string that holds the content transfer encoding (optional parameter)
[in]lastThis 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]contextSMTP client context
[in]replyLineResponse 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]contextPointer to the SMTP client context
[in]callbackOptional callback to parse each line of the reply
Returns
Error code

Definition at line 72 of file smtp_client_misc.c.