mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-08 17:13:56 +00:00
Fixed double sent attachments in email notifications
SVN revision: 1960
This commit is contained in:
parent
d2edbdd32e
commit
4fe5ff024e
18
src/elogd.c
18
src/elogd.c
@ -19913,7 +19913,7 @@ void format_email_attachments(LOGBOOK * lbs, int message_id, int attachment_type
|
|||||||
char att_file[MAX_ATTACHMENTS][256], char *mail_text, int size,
|
char att_file[MAX_ATTACHMENTS][256], char *mail_text, int size,
|
||||||
char *multipart_boundary, int content_id)
|
char *multipart_boundary, int content_id)
|
||||||
{
|
{
|
||||||
int i, index, n_att, fh, n, is_inline;
|
int i, index, n_att, fh, n, is_inline, length;
|
||||||
char str[256], file_name[256], buffer[256], email_from[256], *p;
|
char str[256], file_name[256], buffer[256], email_from[256], *p;
|
||||||
|
|
||||||
/* count attachments */
|
/* count attachments */
|
||||||
@ -19975,6 +19975,7 @@ void format_email_attachments(LOGBOOK * lbs, int message_id, int attachment_type
|
|||||||
strlcat(file_name, att_file[index], sizeof(file_name));
|
strlcat(file_name, att_file[index], sizeof(file_name));
|
||||||
|
|
||||||
fh = open(file_name, O_RDONLY | O_BINARY);
|
fh = open(file_name, O_RDONLY | O_BINARY);
|
||||||
|
length = strlen(mail_text);
|
||||||
if (fh > 0) {
|
if (fh > 0) {
|
||||||
do {
|
do {
|
||||||
n = my_read(fh, buffer, 45);
|
n = my_read(fh, buffer, 45);
|
||||||
@ -19982,8 +19983,13 @@ void format_email_attachments(LOGBOOK * lbs, int message_id, int attachment_type
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
base64_bufenc((unsigned char *) buffer, n, str);
|
base64_bufenc((unsigned char *) buffer, n, str);
|
||||||
strlcat(mail_text, str, size);
|
|
||||||
strlcat(mail_text, "\r\n", size);
|
if (length + (int)strlen(str) + 2 < size) {
|
||||||
|
strcpy(mail_text + length, str);
|
||||||
|
length += strlen(str);
|
||||||
|
strcpy(mail_text + length, "\r\n");
|
||||||
|
length += 2;
|
||||||
|
}
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
close(fh);
|
close(fh);
|
||||||
@ -20385,7 +20391,7 @@ void format_email_html2(LOGBOOK * lbs, int message_id, char att_file[MAX_ATTACHM
|
|||||||
strlcat(mail_text, "\r\n", size);
|
strlcat(mail_text, "\r\n", size);
|
||||||
|
|
||||||
if (attachments_present) {
|
if (attachments_present) {
|
||||||
format_email_attachments(lbs, message_id, 0, att_file, mail_text, size, multipart_boundary_related,
|
format_email_attachments(lbs, message_id, 2, att_file, mail_text, size, multipart_boundary_related,
|
||||||
TRUE);
|
TRUE);
|
||||||
strlcat(mail_text, "--", size);
|
strlcat(mail_text, "--", size);
|
||||||
strlcat(mail_text, multipart_boundary_related, size);
|
strlcat(mail_text, multipart_boundary_related, size);
|
||||||
@ -20487,14 +20493,14 @@ int compose_email(LOGBOOK * lbs, char *rcpt_to, char *mail_to, int message_id,
|
|||||||
|
|
||||||
status = sendmail(lbs, smtp_host, mail_from, rcpt_to, mail_text, error, sizeof(error));
|
status = sendmail(lbs, smtp_host, mail_from, rcpt_to, mail_text, error, sizeof(error));
|
||||||
|
|
||||||
/**/
|
/*
|
||||||
{
|
{
|
||||||
int fh;
|
int fh;
|
||||||
fh = open("mail.html", O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, 0644);
|
fh = open("mail.html", O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, 0644);
|
||||||
write(fh, mail_text, strlen(mail_text));
|
write(fh, mail_text, strlen(mail_text));
|
||||||
close(fh);
|
close(fh);
|
||||||
}
|
}
|
||||||
/**/
|
*/
|
||||||
|
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
sprintf(str, loc("Error sending Email via <i>\"%s\"</i>"), smtp_host);
|
sprintf(str, loc("Error sending Email via <i>\"%s\"</i>"), smtp_host);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user