smtp_client.h File Reference

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

#include "core/socket.h"
#include "core/crypto.h"
#include "tls.h"
#include "encoding/base64.h"
#include "mac/hmac.h"
#include "hash/md5.h"

Go to the source code of this file.

Data Structures

struct  SmtpAuthInfo
 Authentication information. More...
 
struct  SmtpMailAddr
 Mail address. More...
 
struct  SmtpMail
 Mail contents. More...
 
struct  SmtpClientContext
 SMTP client context. More...
 

Macros

#define SMTP_CLIENT_SUPPORT   ENABLED
 
#define SMTP_CLIENT_DEFAULT_TIMEOUT   10000
 
#define SMTP_CLIENT_MAX_LINE_LENGTH   512
 
#define SMTP_CLIENT_TLS_SUPPORT   DISABLED
 
#define SMTP_CLIENT_LOGIN_AUTH_SUPPORT   ENABLED
 
#define SMTP_CLIENT_PLAIN_AUTH_SUPPORT   ENABLED
 
#define SMTP_CLIENT_CRAM_MD5_AUTH_SUPPORT   DISABLED
 
#define SMTP_PORT   25
 
#define SMTPS_PORT   465
 
#define SMTP_SUBMISSION_PORT   587
 
#define SMTP_REPLY_CODE_2YZ(code)   ((code) >= 200 && (code) < 300)
 
#define SMTP_REPLY_CODE_3YZ(code)   ((code) >= 300 && (code) < 400)
 
#define SMTP_REPLY_CODE_4YZ(code)   ((code) >= 400 && (code) < 500)
 
#define SMTP_REPLY_CODE_5YZ(code)   ((code) >= 500 && (code) < 600)
 

Typedefs

typedef error_t(* SmtpReplyCallback) (SmtpClientContext *context, char_t *replyLine, uint_t replyCode)
 

Enumerations

enum  SmtpRecipientType { SMTP_RCPT_TYPE_TO = 1, SMTP_RCPT_TYPE_CC = 2, SMTP_RCPT_TYPE_BCC = 4 }
 Recipient type. More...
 

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.

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

Definition in file smtp_client.h.

Macro Definition Documentation

◆ SMTP_CLIENT_CRAM_MD5_AUTH_SUPPORT

#define SMTP_CLIENT_CRAM_MD5_AUTH_SUPPORT   DISABLED

Definition at line 79 of file smtp_client.h.

◆ SMTP_CLIENT_DEFAULT_TIMEOUT

#define SMTP_CLIENT_DEFAULT_TIMEOUT   10000

Definition at line 44 of file smtp_client.h.

◆ SMTP_CLIENT_LOGIN_AUTH_SUPPORT

#define SMTP_CLIENT_LOGIN_AUTH_SUPPORT   ENABLED

Definition at line 65 of file smtp_client.h.

◆ SMTP_CLIENT_MAX_LINE_LENGTH

#define SMTP_CLIENT_MAX_LINE_LENGTH   512

Definition at line 51 of file smtp_client.h.

◆ SMTP_CLIENT_PLAIN_AUTH_SUPPORT

#define SMTP_CLIENT_PLAIN_AUTH_SUPPORT   ENABLED

Definition at line 72 of file smtp_client.h.

◆ SMTP_CLIENT_SUPPORT

#define SMTP_CLIENT_SUPPORT   ENABLED

Definition at line 37 of file smtp_client.h.

◆ SMTP_CLIENT_TLS_SUPPORT

#define SMTP_CLIENT_TLS_SUPPORT   DISABLED

Definition at line 58 of file smtp_client.h.

◆ SMTP_PORT

#define SMTP_PORT   25

Definition at line 105 of file smtp_client.h.

◆ SMTP_REPLY_CODE_2YZ

#define SMTP_REPLY_CODE_2YZ (   code)    ((code) >= 200 && (code) < 300)

Definition at line 112 of file smtp_client.h.

◆ SMTP_REPLY_CODE_3YZ

#define SMTP_REPLY_CODE_3YZ (   code)    ((code) >= 300 && (code) < 400)

Definition at line 113 of file smtp_client.h.

◆ SMTP_REPLY_CODE_4YZ

#define SMTP_REPLY_CODE_4YZ (   code)    ((code) >= 400 && (code) < 500)

Definition at line 114 of file smtp_client.h.

◆ SMTP_REPLY_CODE_5YZ

#define SMTP_REPLY_CODE_5YZ (   code)    ((code) >= 500 && (code) < 600)

Definition at line 115 of file smtp_client.h.

◆ SMTP_SUBMISSION_PORT

#define SMTP_SUBMISSION_PORT   587

Definition at line 109 of file smtp_client.h.

◆ SMTPS_PORT

#define SMTPS_PORT   465

Definition at line 107 of file smtp_client.h.

Typedef Documentation

◆ SmtpReplyCallback

typedef error_t(* SmtpReplyCallback) (SmtpClientContext *context, char_t *replyLine, uint_t replyCode)

Definition at line 201 of file smtp_client.h.

Enumeration Type Documentation

◆ SmtpRecipientType

Recipient type.

Enumerator
SMTP_RCPT_TYPE_TO 
SMTP_RCPT_TYPE_CC 
SMTP_RCPT_TYPE_BCC 

Definition at line 127 of file smtp_client.h.

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.