Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Application-SimpleSMTPClient_HelloWorld final
Fork of SimpleSMTPClient by
SimpleSMTPClient.h
- Committer:
- bhakti08
- Date:
- 2014-04-29
- Revision:
- 8:085f37025cb9
- Parent:
- 2:27053679f44b
- Child:
- 4:7d16b08a1291
File content as of revision 8:085f37025cb9:
/*
*
* mbed Simple SMTP Client
* Copyright (c) 2012 Tadao Iida
* Released under the MIT License: http://mbed.org/license/mit
*/
/** @file
* @brief Simple SMTP Client
*/
#ifndef SimpleSMTPC_h
#define SimpleSMTPC_h
#include "EthernetInterface.h"
///SMTP authentication
enum SMTPAuth {
SMTP_AUTH_NONE, ///<No authentication
SMTP_AUTH_PLAIN ///<AUTH PLAIN authentication
};
///SimpleSMTP client results
enum SMTPResult
{
SMTP_AUTH_OK = 235, ///<Authentication successful
SMTP_OK = 250, ///<Requested mail action okay, completed
SMTP_INPUT = 354 ///<Start mail input
};
#define DEBUG
#define SMTP_TIMEOUT 15000 // ms
class SimpleSMTPClient
{
public:
/**
Instantiate the SimpleSMTP client
*/
SimpleSMTPClient();
/** send mail
* @param host mail server
* @param data mail body
* @param user auth username
* @param pwd auth password
* @param domain
* @param port mail port
* @param auth SMTP auth
* @return 0:success, -1:failue
*/
int sendmail (char *host, char *user, char *pwd,char *domain,char *port,SMTPAuth auth);
/** setMessage
* @param sub Subject <The Subject are less than 64 characters.>
* @param msg Message
* @return 0:success, -1:failue
*/
int setMessage(char *sub,char *msg);
/** addMessage
* @param msg Message
* @return 0:success, -1:failue
*/
int addMessage(char *msg);
/** setFromAddress
* @param from mail address
* @return character count, -1:failue
*/
int setFromAddress(char *from);
/** setToAddress <The ToAddress are less than 128 characters.>
* @param to mail address
* @return character count, -1:failue
*/
int setToAddress(char *to);
private:
int base64enc(const char *input, unsigned int length, char *output, int outputlen);
int receiveMessage(int code);
char* getFromAddress(void);
char* getToAddress(void);
char* getSubject();
char* getHeader();
char* getMessage();
int makeHeader(void);
TCPSocketConnection smtp;
char header[256];
char body[1500];
char from[64];
char to[128];
char subject[64];
char message[1244];
};
#endif
