smtp_client.c File Reference

SMTP client (Simple Mail Transfer Protocol) More...

#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include "core/net.h"
#include "smtp/smtp_client.h"
#include "core/socket.h"
#include "str.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   SMTP_TRACE_LEVEL
 

Functions

error_t smtpSendMail (const SmtpAuthInfo *authInfo, const SmtpMail *mail)
 Send a mail to the specified recipients. More...
 
error_t smtpEhloReplyCallback (SmtpClientContext *context, char_t *replyLine, uint_t replyCode)
 Callback function to parse EHLO response. More...
 
error_t smtpSendAuthLogin (SmtpClientContext *context, const SmtpAuthInfo *authInfo)
 Authentication using LOGIN mechanism. More...
 
error_t smtpSendAuthPlain (SmtpClientContext *context, const SmtpAuthInfo *authInfo)
 Authentication using PLAIN mechanism. More...
 
error_t smtpSendAuthCramMd5 (SmtpClientContext *context, const SmtpAuthInfo *authInfo)
 Authentication using CRAM-MD5 mechanism. More...
 
error_t smtpSendData (SmtpClientContext *context, const SmtpMail *mail)
 Send message body. More...
 
error_t smtpSendCommand (SmtpClientContext *context, const char_t *command, uint_t *replyCode, SmtpReplyCallback callback)
 Send SMTP command and wait for a reply. More...
 
error_t smtpWrite (SmtpClientContext *context, const void *data, size_t length, uint_t flags)
 Send data to the SMTP server. More...
 
error_t smtpRead (SmtpClientContext *context, void *data, size_t size, size_t *received, uint_t flags)
 Receive data from the SMTP server. More...
 

Detailed Description

SMTP client (Simple Mail Transfer Protocol)

License

Copyright (C) 2010-2018 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.

Description

SMTP is designed as a mail transport and delivery protocol. Refer to the following RFCs for complete details:

  • RFC 5321: Simple Mail Transfer Protocol
  • RFC 4954: SMTP Service Extension for Authentication
  • RFC 3207: SMTP Service Extension for Secure SMTP over TLS
Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
1.9.0

Definition in file smtp_client.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   SMTP_TRACE_LEVEL

Definition at line 38 of file smtp_client.c.

Function Documentation

◆ smtpEhloReplyCallback()

error_t smtpEhloReplyCallback ( SmtpClientContext context,
char_t replyLine,
uint_t  replyCode 
)

Callback function to parse EHLO response.

Parameters
[in]contextSMTP client context
[in]replyLineResponse line
[in]replyCodeResponse code
Returns
Error code

Definition at line 430 of file smtp_client.c.

◆ smtpRead()

error_t smtpRead ( SmtpClientContext context,
void *  data,
size_t  size,
size_t *  received,
uint_t  flags 
)

Receive data from the SMTP server.

Parameters
[in]contextSMTP client context
[out]dataBuffer into which received data will be placed
[in]sizeMaximum number of bytes that can be received
[out]receivedActual number of bytes that have been received
[in]flagsSet of flags that influences the behavior of this function
Returns
Error code

Definition at line 943 of file smtp_client.c.

◆ smtpSendAuthCramMd5()

error_t smtpSendAuthCramMd5 ( SmtpClientContext context,
const SmtpAuthInfo authInfo 
)

Authentication using CRAM-MD5 mechanism.

Parameters
[in]contextSMTP client context
[in]authInfoAuthentication information
Returns
Error code

Definition at line 603 of file smtp_client.c.

◆ smtpSendAuthLogin()

error_t smtpSendAuthLogin ( SmtpClientContext context,
const SmtpAuthInfo authInfo 
)

Authentication using LOGIN mechanism.

Parameters
[in]contextSMTP client context
[in]authInfoAuthentication information
Returns
Error code

Definition at line 493 of file smtp_client.c.

◆ smtpSendAuthPlain()

error_t smtpSendAuthPlain ( SmtpClientContext context,
const SmtpAuthInfo authInfo 
)

Authentication using PLAIN mechanism.

Parameters
[in]contextSMTP client context
[in]authInfoAuthentication information
Returns
Error code

Definition at line 555 of file smtp_client.c.

◆ smtpSendCommand()

error_t smtpSendCommand ( SmtpClientContext context,
const char_t command,
uint_t replyCode,
SmtpReplyCallback  callback 
)

Send SMTP command and wait for a reply.

Parameters
[in]contextSMTP client context
[in]commandCommand line
[out]replyCodeSMTP server reply code
[in]callbackOptional callback to parse each line of the reply
Returns
Error code

Definition at line 835 of file smtp_client.c.

◆ smtpSendData()

error_t smtpSendData ( SmtpClientContext context,
const SmtpMail mail 
)

Send message body.

Parameters
[in]contextSMTP client context
[in]mailMail contents
Returns
Error code

Definition at line 696 of file smtp_client.c.

◆ smtpSendMail()

error_t smtpSendMail ( const SmtpAuthInfo authInfo,
const SmtpMail mail 
)

Send a mail to the specified recipients.

Parameters
[in]authInfoAuthentication information
[in]mailMail contents
Returns
Error code

Definition at line 61 of file smtp_client.c.

◆ smtpWrite()

error_t smtpWrite ( SmtpClientContext context,
const void *  data,
size_t  length,
uint_t  flags 
)

Send data to the SMTP server.

Parameters
[in]contextSMTP client context
[in]dataPointer to a buffer containing the data to be transmitted
[in]lengthNumber of bytes to be transmitted
[in]flagsSet of flags that influences the behavior of this function

Definition at line 915 of file smtp_client.c.