summaryrefslogtreecommitdiff
path: root/src/mail.h
blob: 2c5da2f90291c0cded4fb666d67935546f3b4dc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef BOKF_MAIL_H
#define BOKF_MAIL_H

#include <stddef.h>
#include <stdint.h>
#include <sqlite3.h>

struct mail_message {
    const char *to;
    const char *subject;
    const char *body;
    const char *attach_name;
    const unsigned char *attach;
    size_t attach_len;
};

/* True for an address the SMTP client can send to: one @, no spaces or
   control characters, not empty. */
int mail_addr_valid(const char *addr);

/* Checks the org's SMTP settings (including decrypting the stored
   smtp_password) without sending. 0 configured, -1 not configured. */
int mail_config_check(sqlite3 *db, int64_t org_id, char *err, size_t errlen);

/* Sends m as a PDF attachment. 0 sent, -1 not configured, -2 send failed.
   err receives an English message; secrets are never included. */
int mail_send_pdf(sqlite3 *db, int64_t org_id, const struct mail_message *m,
                  char *err, size_t errlen);

#endif