Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
956a3c65
...
956a3c65217d28de4ba7901906ce8f11277486a2
authored
2006-12-29 13:12:52 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Sent empty messages only if nullbody is set
1 parent
9740641b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
24 deletions
mail/send.c
mail/send.c
View file @
956a3c6
...
...
@@ -307,6 +307,43 @@ compose_destroy (compose_env_t * env)
}
}
static
int
fill_body
(
mu_message_t
msg
,
FILE
*
file
)
{
mu_body_t
body
=
NULL
;
mu_stream_t
stream
=
NULL
;
off_t
offset
=
0
;
char
*
buf
=
NULL
;
size_t
n
=
0
;
mu_message_get_body
(
msg
,
&
body
);
mu_body_get_stream
(
body
,
&
stream
);
while
(
getline
(
&
buf
,
&
n
,
file
)
>=
0
)
{
size_t
len
=
strlen
(
buf
);
mu_stream_write
(
stream
,
buf
,
len
,
offset
,
&
n
);
offset
+=
len
;
}
if
(
buf
)
free
(
buf
);
if
(
offset
==
0
)
{
if
(
util_getenv
(
NULL
,
"nullbody"
,
Mail_env_boolean
,
0
)
==
0
)
{
char
*
str
;
if
(
util_getenv
(
&
str
,
"nullbodymsg"
,
Mail_env_string
,
0
)
==
0
)
util_error
(
"%s
\n
"
,
_
(
str
));
}
else
return
1
;
}
return
0
;
}
/* mail_send0(): shared between mail_send() and mail_reply();
If the variable "record" is set, the outgoing message is
...
...
@@ -492,35 +529,18 @@ mail_send0 (compose_env_t * env, int save_to)
{
mu_mailer_t
mailer
;
mu_message_t
msg
=
NULL
;
int
rc
;
mu_message_create
(
&
msg
,
NULL
);
mu_message_set_header
(
msg
,
env
->
header
,
NULL
);
/* Fill the body. */
{
mu_body_t
body
=
NULL
;
mu_stream_t
stream
=
NULL
;
off_t
offset
=
0
;
char
*
buf
=
NULL
;
size_t
n
=
0
;
mu_message_get_body
(
msg
,
&
body
);
mu_body_get_stream
(
body
,
&
stream
);
while
(
getline
(
&
buf
,
&
n
,
file
)
>=
0
)
{
size_t
len
=
strlen
(
buf
);
mu_stream_write
(
stream
,
buf
,
len
,
offset
,
&
n
);
offset
+=
len
;
}
if
(
offset
==
0
)
util_error
(
_
(
"Null message body; hope that's ok
\n
"
));
if
(
buf
)
free
(
buf
);
}
rc
=
fill_body
(
msg
,
file
);
fclose
(
file
);
if
(
rc
==
0
)
{
/* Save outgoing message */
if
(
save_to
)
{
...
...
@@ -555,7 +575,8 @@ mail_send0 (compose_env_t * env, int save_to)
{
int
status
;
mu_mailbox_t
mbx
=
NULL
;
status
=
mu_mailbox_create_default
(
&
mbx
,
env
->
outfiles
[
i
]);
status
=
mu_mailbox_create_default
(
&
mbx
,
env
->
outfiles
[
i
]);
if
(
status
==
0
)
{
status
=
mu_mailbox_open
(
mbx
,
MU_STREAM_WRITE
...
...
@@ -583,7 +604,8 @@ mail_send0 (compose_env_t * env, int save_to)
||
compose_header_get
(
env
,
MU_HEADER_BCC
,
NULL
))
{
char
*
sendmail
;
if
(
util_getenv
(
&
sendmail
,
"sendmail"
,
Mail_env_string
,
0
)
==
0
)
if
(
util_getenv
(
&
sendmail
,
"sendmail"
,
Mail_env_string
,
0
)
==
0
)
{
int
status
=
mu_mailer_create
(
&
mailer
,
sendmail
);
if
(
status
==
0
)
...
...
@@ -594,7 +616,8 @@ mail_send0 (compose_env_t * env, int save_to)
mu_debug_t
debug
=
NULL
;
mu_mailer_get_debug
(
mailer
,
&
debug
);
mu_debug_set_level
(
debug
,
MU_DEBUG_TRACE
|
MU_DEBUG_PROT
);
MU_DEBUG_TRACE
|
MU_DEBUG_PROT
);
}
status
=
mu_mailer_open
(
mailer
,
MU_STREAM_RDWR
);
if
(
status
==
0
)
...
...
@@ -610,6 +633,7 @@ mail_send0 (compose_env_t * env, int save_to)
else
util_error
(
_
(
"Variable sendmail not set: no mailer"
));
}
}
mu_message_destroy
(
&
msg
,
NULL
);
remove
(
filename
);
free
(
filename
);
...
...
Please
register
or
sign in
to post a comment