Miscellaneous functions for sending an email. More...
#include "config.h"
#include <ctype.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "mutt.h"
#include "sendlib.h"
#include "attach/lib.h"
#include "convert/lib.h"
#include "ncrypt/lib.h"
#include "body.h"
#include "copy.h"
#include "globals.h"
#include "handler.h"
#include "header.h"
#include "mutt_mailbox.h"
#include "muttlib.h"
#include "mx.h"
#include "send.h"
#include "sendmail.h"
#include "smtp.h"
Go to the source code of this file.
Functions | |
enum ContentType | mutt_lookup_mime_type (struct Body *b, const char *path) |
Find the MIME type for an attachment. | |
static void | transform_to_7bit (struct Body *b, FILE *fp_in, struct ConfigSubset *sub) |
Convert MIME parts to 7-bit. | |
void | mutt_message_to_7bit (struct Body *b, FILE *fp, struct ConfigSubset *sub) |
Convert an email's MIME parts to 7-bit. | |
static void | set_encoding (struct Body *b, struct Content *info, struct ConfigSubset *sub) |
Determine which Content-Transfer-Encoding to use. | |
void | mutt_stamp_attachment (struct Body *b) |
Timestamp an Attachment. | |
void | mutt_update_encoding (struct Body *b, struct ConfigSubset *sub) |
Update the encoding type. | |
struct Body * | mutt_make_message_attach (struct Mailbox *m, struct Email *e, bool attach_msg, struct ConfigSubset *sub) |
Create a message attachment. | |
static void | run_mime_type_query (struct Body *b, struct ConfigSubset *sub) |
Run an external command to determine the MIME type. | |
struct Body * | mutt_make_file_attach (const char *path, struct ConfigSubset *sub) |
Create a file attachment. | |
static void | encode_headers (struct ListHead *h, struct ConfigSubset *sub) |
RFC2047-encode a list of headers. | |
const char * | mutt_fqdn (bool may_hide_host, const struct ConfigSubset *sub) |
Get the Fully-Qualified Domain Name. | |
char * | mutt_gen_msgid (void) |
Generate a random Message ID. | |
void | mutt_prepare_envelope (struct Envelope *env, bool final, struct ConfigSubset *sub) |
Prepare an email header. | |
void | mutt_unprepare_envelope (struct Envelope *env) |
Undo the encodings of mutt_prepare_envelope() | |
static int | bounce_message (FILE *fp, struct Mailbox *m, struct Email *e, struct AddressList *to, const char *resent_from, struct AddressList *env_from, struct ConfigSubset *sub) |
Bounce an email message. | |
int | mutt_bounce_message (FILE *fp, struct Mailbox *m, struct Email *e, struct AddressList *to, struct ConfigSubset *sub) |
Bounce an email message. | |
static void | set_noconv_flags (struct Body *b, bool flag) |
Set/reset the "x-mutt-noconv" flag. | |
int | mutt_write_multiple_fcc (const char *path, struct Email *e, const char *msgid, bool post, char *fcc, char **finalpath, struct ConfigSubset *sub) |
Handle FCC with multiple, comma separated entries. | |
int | mutt_write_fcc (const char *path, struct Email *e, const char *msgid, bool post, const char *fcc, char **finalpath, struct ConfigSubset *sub) |
Write email to FCC mailbox. | |
Miscellaneous functions for sending an email.
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, see http://www.gnu.org/licenses/.
Definition in file sendlib.c.
enum ContentType mutt_lookup_mime_type | ( | struct Body * | b, |
const char * | path | ||
) |
Find the MIME type for an attachment.
b | Email with attachment |
path | Path to attachment |
enum | ContentType, e.g. TYPE_IMAGE |
Given a file at 'path', see if there is a registered MIME type. Returns the major MIME type, and copies the subtype to "d". First look in a system mime.types if we can find one, then look for ~/.mime.types. The longest match is used so that we can match 'ps.gz' when 'gz' also exists.
Definition at line 76 of file sendlib.c.
|
static |
Convert MIME parts to 7-bit.
b | Body of the email |
fp_in | File to read |
sub | Config Subset |
Definition at line 196 of file sendlib.c.
void mutt_message_to_7bit | ( | struct Body * | b, |
FILE * | fp, | ||
struct ConfigSubset * | sub | ||
) |
Convert an email's MIME parts to 7-bit.
b | Body of the email |
fp | File to read (OPTIONAL) |
sub | Config Subset |
Definition at line 259 of file sendlib.c.
|
static |
Determine which Content-Transfer-Encoding to use.
[in] | b | Body of email |
[out] | info | Info about the email |
[in] | sub | Config Subset |
Definition at line 351 of file sendlib.c.
void mutt_stamp_attachment | ( | struct Body * | b | ) |
Timestamp an Attachment.
b | Attachment |
Definition at line 410 of file sendlib.c.
void mutt_update_encoding | ( | struct Body * | b, |
struct ConfigSubset * | sub | ||
) |
Update the encoding type.
b | Body to update |
sub | Config Subset |
Assumes called from send mode where Body->filename points to actual file
Definition at line 422 of file sendlib.c.
struct Body * mutt_make_message_attach | ( | struct Mailbox * | m, |
struct Email * | e, | ||
bool | attach_msg, | ||
struct ConfigSubset * | sub | ||
) |
Create a message attachment.
ptr | Newly allocated Body |
NULL | Error |
Definition at line 454 of file sendlib.c.
|
static |
Run an external command to determine the MIME type.
b | Attachment |
sub | Config Subset |
The command in $mime_type_query_command is run.
Definition at line 566 of file sendlib.c.
struct Body * mutt_make_file_attach | ( | const char * | path, |
struct ConfigSubset * | sub | ||
) |
Create a file attachment.
path | File to attach |
sub | Config Subset |
ptr | Newly allocated Body |
NULL | Error |
Definition at line 607 of file sendlib.c.
|
static |
RFC2047-encode a list of headers.
h | String List of headers |
sub | Config Subset |
The strings are encoded in-place.
Definition at line 667 of file sendlib.c.
const char * mutt_fqdn | ( | bool | may_hide_host, |
const struct ConfigSubset * | sub | ||
) |
Get the Fully-Qualified Domain Name.
may_hide_host | If true, hide the hostname (leaving just the domain) |
sub | Config Subset |
ptr | string pointer into Hostname |
NULL | Error, e.g no Hostname |
Definition at line 707 of file sendlib.c.
char * mutt_gen_msgid | ( | void | ) |
Generate a random Message ID.
ptr | Message ID |
The length of the message id is chosen such that it is maximal and fits in the recommended 78 character line length for the headers Message-ID:, References:, and In-Reply-To:, this leads to 62 available characters (excluding @
and >
). Since we choose from 32 letters, we have 32^62 = 2^310 different message ids.
Examples:
The distribution of the characters to left-of-@ and right-of-@ was arbitrary. The choice was made to put more into the left-id and shorten the right-id to slightly mimic a common length domain name.
Definition at line 753 of file sendlib.c.
void mutt_prepare_envelope | ( | struct Envelope * | env, |
bool | final, | ||
struct ConfigSubset * | sub | ||
) |
Prepare an email header.
env | Envelope to prepare |
final | true if this email is going to be sent (not postponed) |
sub | Config Subset |
Encode all the headers prior to sending the email.
For postponing (!final) do the necessary encodings only
Definition at line 780 of file sendlib.c.
void mutt_unprepare_envelope | ( | struct Envelope * | env | ) |
Undo the encodings of mutt_prepare_envelope()
env | Envelope to unprepare |
Decode all the headers of an email, e.g. when the sending failed or was aborted.
Definition at line 819 of file sendlib.c.
|
static |
Bounce an email message.
fp | Handle of message |
m | Mailbox |
e | |
to | Address to bounce to |
resent_from | Address of new sender |
env_from | Envelope of original sender |
sub | Config Subset |
0 | Success |
-1 | Failure |
Definition at line 845 of file sendlib.c.
int mutt_bounce_message | ( | FILE * | fp, |
struct Mailbox * | m, | ||
struct Email * | e, | ||
struct AddressList * | to, | ||
struct ConfigSubset * | sub | ||
) |
Bounce an email message.
0 | Success |
-1 | Failure |
Definition at line 917 of file sendlib.c.
|
static |
Set/reset the "x-mutt-noconv" flag.
b | Body of email |
flag | If true, set the flag, otherwise remove it |
Definition at line 975 of file sendlib.c.
int mutt_write_multiple_fcc | ( | const char * | path, |
struct Email * | e, | ||
const char * | msgid, | ||
bool | post, | ||
char * | fcc, | ||
char ** | finalpath, | ||
struct ConfigSubset * | sub | ||
) |
Handle FCC with multiple, comma separated entries.
[in] | path | Path to mailboxes (comma separated) |
[in] | e | |
[in] | msgid | Message id |
[in] | post | If true, postpone message |
[in] | fcc | fcc setting to save (postpone only) |
[out] | finalpath | Final path of email |
[in] | sub | Config Subset |
0 | Success |
-1 | Failure |
Definition at line 1005 of file sendlib.c.
int mutt_write_fcc | ( | const char * | path, |
struct Email * | e, | ||
const char * | msgid, | ||
bool | post, | ||
const char * | fcc, | ||
char ** | finalpath, | ||
struct ConfigSubset * | sub | ||
) |
Write email to FCC mailbox.
[in] | path | Path to mailbox |
[in] | e | |
[in] | msgid | Message id |
[in] | post | If true, postpone message, else fcc mode |
[in] | fcc | fcc setting to save (postpone only) |
[out] | finalpath | Final path of email |
[in] | sub | Config Subset |
0 | Success |
-1 | Failure |
Definition at line 1058 of file sendlib.c.