smtp-client
SMTP Client C Library
test_nossl.c
Go to the documentation of this file.
1 
12 #include <assert.h>
13 #include <stdio.h>
14 #include <string.h>
15 
16 #include <smtp.h>
17 
24 static void
25 load_test_email(char *const email,
26  size_t emailsz){
27  FILE *fp;
28  int rc;
29  size_t bytes_read;
30 
31  fp = fopen("test/config/test_email.txt", "r");
32  assert(fp);
33 
34  bytes_read = fread(email, sizeof(*email), emailsz, fp);
35  assert(bytes_read > 0);
36 
37  email[bytes_read - 1] = '\0';
38 
39  rc = ferror(fp);
40  assert(rc == 0);
41 
42  rc = fclose(fp);
43  assert(rc == 0);
44 }
45 
49 static void
51  int rc;
52  struct smtp *smtp;
53  char email[1000];
54 
55  load_test_email(email, sizeof(email));
56 
57  rc = smtp_open("localhost",
58  "25",
60  SMTP_DEBUG,
61  NULL,
62  &smtp);
63  assert(rc == SMTP_STATUS_OK);
64 
65  rc = smtp_address_add(smtp,
67  email,
68  "Test Email");
69  assert(rc == SMTP_STATUS_OK);
70 
71  rc = smtp_address_add(smtp,
73  email,
74  "Test Email");
75  assert(rc == SMTP_STATUS_OK);
76 
77  rc = smtp_header_add(smtp,
78  "Subject",
79  "SMTP Test: Build Without OpenSSL");
80  assert(rc == SMTP_STATUS_OK);
81 
82  rc = smtp_mail(smtp,
83  "This email tests the build without OpenSSL compiled into"
84  " the library.");
85  assert(rc == SMTP_STATUS_OK);
86 
87  rc = smtp_close(smtp);
88  assert(rc == SMTP_STATUS_OK);
89 }
90 
98 int main(void){
100  return 0;
101 }
102 
enum smtp_status_code smtp_close(struct smtp *smtp)
Definition: smtp.c:3168
enum smtp_status_code smtp_header_add(struct smtp *const smtp, const char *const key, const char *const value)
Definition: smtp.c:3278
#define ferror
Definition: seams.h:113
enum smtp_status_code smtp_mail(struct smtp *const smtp, const char *const body)
Definition: smtp.c:3062
static void test_nossl_smtp(void)
Definition: test_nossl.c:50
static void load_test_email(char *const email, size_t emailsz)
Definition: test_nossl.c:25
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
Definition: smtp.c:150
SMTP client library.
int main(void)
Definition: test_nossl.c:98
#define fclose
Definition: seams.h:105
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