smtp-client
SMTP Client C Library
smtp.h
Go to the documentation of this file.
1 
12 #ifndef SMTP_H
13 #define SMTP_H
14 
15 #include <sys/types.h>
16 #include <stddef.h>
17 #include <stdio.h>
18 
19 #ifndef SIZE_MAX
20 
23 # define SIZE_MAX ((size_t)(-1))
24 #endif /* SIZE_MAX */
25 
37 
42 
47 
52 
57 
62 
67 
72 
77 
82 
87 
92 
100 };
101 
110 
115 
120 
134 };
135 
141 #ifdef SMTP_OPENSSL
142 
149 
156 #endif /* SMTP_OPENSSL */
157 
164 };
165 
171 #ifdef SMTP_OPENSSL
172 
176 #endif /* SMTP_OPENSSL */
177 
183 
188 
193 };
194 
202  SMTP_DEBUG = 1 << 0,
203 
213 };
214 
215 struct smtp;
216 
217 #ifdef __cplusplus
218 extern "C" {
219 #endif /* __cplusplus */
220 
247 enum smtp_status_code
248 smtp_open(const char *const server,
249  const char *const port,
250  enum smtp_connection_security connection_security,
251  enum smtp_flag flags,
252  const char *const cafile,
253  struct smtp **smtp);
254 
265 enum smtp_status_code
266 smtp_auth(struct smtp *const smtp,
267  enum smtp_authentication_method auth_method,
268  const char *const user,
269  const char *const pass);
270 
291 enum smtp_status_code
292 smtp_mail(struct smtp *const smtp,
293  const char *const body);
294 
302 enum smtp_status_code
303 smtp_close(struct smtp *smtp);
304 
311 enum smtp_status_code
312 smtp_status_code_get(const struct smtp *const smtp);
313 
320 enum smtp_status_code
321 smtp_status_code_clear(struct smtp *const smtp);
322 
337 enum smtp_status_code
338 smtp_status_code_set(struct smtp *const smtp,
339  enum smtp_status_code new_status_code);
340 
349 const char *
351 
368 enum smtp_status_code
369 smtp_header_add(struct smtp *const smtp,
370  const char *const key,
371  const char *const value);
372 
378 void
379 smtp_header_clear_all(struct smtp *const smtp);
380 
397 enum smtp_status_code
398 smtp_address_add(struct smtp *const smtp,
399  enum smtp_address_type type,
400  const char *const email,
401  const char *const name);
402 
408 void
409 smtp_address_clear_all(struct smtp *const smtp);
410 
423 enum smtp_status_code
424 smtp_attachment_add_path(struct smtp *const smtp,
425  const char *const name,
426  const char *const path);
427 
440 enum smtp_status_code
441 smtp_attachment_add_fp(struct smtp *const smtp,
442  const char *const name,
443  FILE *fp);
444 
460 enum smtp_status_code
461 smtp_attachment_add_mem(struct smtp *const smtp,
462  const char *const name,
463  const void *const data,
464  size_t datasz);
465 
471 void
472 smtp_attachment_clear_all(struct smtp *const smtp);
473 
474 
475 /*
476  * The SMTP_INTERNAL DEFINE section contains definitions that get used
477  * internally by the SMTP client library.
478  */
479 #ifdef SMTP_INTERNAL_DEFINE
480 
488 
492  SMTP_READY = 220,
493 
497  SMTP_CLOSE = 221,
498 
503 
507  SMTP_DONE = 250,
508 
514 
519 };
520 
532 
539  int more;
540 
544  const char *text;
545 };
546 
556 
561 
566 };
567 
577  char *_buf;
578 
582  size_t _bufsz;
583 
587  size_t _buf_len;
588 
592  char *line;
593 
597  size_t line_len;
598 
608  long (*getdelimfd_read)(struct str_getdelimfd *const gdfd,
609  void *buf,
610  size_t count);
611 
615  void *user_data;
616 
620  int delim;
621 
625  char pad[4];
626 };
627 
628 #endif /* SMTP_INTERNAL_DEFINE */
629 
630 #ifdef __cplusplus
631 }
632 #endif /* __cplusplus */
633 
634 #endif /* SMTP_H */
635 
enum smtp_status_code smtp_close(struct smtp *smtp)
Definition: smtp.c:3168
const char * smtp_status_code_errstr(enum smtp_status_code status_code)
Definition: smtp.c:3241
enum smtp_status_code smtp_status_code_set(struct smtp *const smtp, enum smtp_status_code new_status_code)
Definition: smtp.c:3231
enum smtp_status_code smtp_attachment_add_mem(struct smtp *const smtp, const char *const name, const void *const data, size_t datasz)
Definition: smtp.c:3462
enum smtp_result_code code
Definition: smtp.h:531
enum smtp_status_code smtp_header_add(struct smtp *const smtp, const char *const key, const char *const value)
Definition: smtp.c:3278
enum smtp_status_code smtp_mail(struct smtp *const smtp, const char *const body)
Definition: smtp.c:3062
enum smtp_flag flags
Definition: smtp.c:154
enum smtp_status_code smtp_attachment_add_path(struct smtp *const smtp, const char *const name, const char *const path)
Definition: smtp.c:3416
size_t _buf_len
Definition: smtp.h:587
void smtp_attachment_clear_all(struct smtp *const smtp)
Definition: smtp.c:3515
size_t line_len
Definition: smtp.h:597
int more
Definition: smtp.h:539
smtp_connection_security
Definition: smtp.h:140
smtp_result_code
Definition: smtp.h:483
void smtp_header_clear_all(struct smtp *const smtp)
Definition: smtp.c:3332
char * line
Definition: smtp.h:592
char * _buf
Definition: smtp.h:577
enum smtp_status_code smtp_status_code_clear(struct smtp *const smtp)
Definition: smtp.c:3222
void smtp_address_clear_all(struct smtp *const smtp)
Definition: smtp.c:3401
smtp_status_code
Definition: smtp.h:32
const char * cafile
Definition: smtp.c:221
smtp_authentication_method
Definition: smtp.h:170
enum smtp_status_code smtp_address_add(struct smtp *const smtp, enum smtp_address_type type, const char *const email, const char *const name)
Definition: smtp.c:3347
void * user_data
Definition: smtp.h:615
enum smtp_status_code status_code
Definition: smtp.c:208
Definition: smtp.c:150
smtp_flag
Definition: smtp.h:198
str_getdelim_retcode
Definition: smtp.h:551
enum smtp_status_code smtp_auth(struct smtp *const smtp, enum smtp_authentication_method auth_method, const char *const user, const char *const pass)
Definition: smtp.c:3026
const char * text
Definition: smtp.h:544
char pad[4]
Definition: smtp.h:625
enum smtp_status_code smtp_attachment_add_fp(struct smtp *const smtp, const char *const name, FILE *fp)
Definition: smtp.c:3439
enum smtp_status_code smtp_status_code_get(const struct smtp *const smtp)
Definition: smtp.c:3217
int delim
Definition: smtp.h:620
enum smtp_status_code smtp_open(const char *const server, const char *const port, enum smtp_connection_security connection_security, enum smtp_flag flags, const char *const cafile, struct smtp **smtp)
Definition: smtp.c:2987
smtp_address_type
Definition: smtp.h:105
size_t _bufsz
Definition: smtp.h:582