Commit de89e4bfd20b5078f09726cfac8866f5b876fe0e

Authored by David RENÉ
1 parent 75d4dac8

add the management of the alternative multipart according to new components of t…

…he type (text_content, html_content)
mail/compose_email.anubis
@@ -331,6 +331,31 @@ public define String @@ -331,6 +331,31 @@ public define String
331 else 331 else
332 encode_plain_text_content(split_lines(content), []) + crlf. 332 encode_plain_text_content(split_lines(content), []) + crlf.
333 333
  334 +public define String
  335 + make_alternative
  336 + (
  337 + String email_id,
  338 + String text_part_content,
  339 + String html_part_content
  340 + )=
  341 + if length(text_part_content) > 0 & length(html_part_content) > 0 then
  342 + //multipart alternative
  343 + with boundary = "=_alternative_"+email_id+"_=",
  344 + "Content-Type: multipart/alternative;" + crlf +
  345 + " boundary=\"" + boundary + "\"" + crlf +
  346 + crlf +
  347 + "--" + boundary + crlf +
  348 + text_part_content + crlf +
  349 + "--" + boundary + crlf +
  350 + html_part_content + crlf +
  351 + "--" + boundary + "--"
  352 + else if length(text_part_content) > 0 then
  353 + text_part_content
  354 + else
  355 + html_part_content
  356 +
  357 +.
  358 +
334 359
335 public define String 360 public define String
336 compose_mail 361 compose_mail
@@ -338,24 +363,33 @@ public define String @@ -338,24 +363,33 @@ public define String
338 Email_to_send send 363 Email_to_send send
339 ) = 364 ) =
340 //with header_to_name = "To: ", 365 //with header_to_name = "To: ",
341 - if send is data_to_send(from, to_list, cc_list, bcc_list, subject, content, files, send_copy, reply_to) then 366 + if send is data_to_send(from, to_list, cc_list, bcc_list, subject, text_content, html_content, files, send_copy, reply_to) then
342 with send_date = get_rfc822_date_format, 367 with send_date = get_rfc822_date_format,
343 - text_type = if find("<html",content,0) is  
344 - {  
345 - failure then "plain",  
346 - success(_) then "html"  
347 - },  
348 - data_text = "Content-Type: text/" + text_type + "; charset=UTF-8" + crlf +  
349 - "Content-Transfer-Encoding: 8bit" + crlf +  
350 - crlf +  
351 - encode_content(content, text_type = "html"),  
352 - is_multipart = if files is  
353 - {  
354 - [] then false,  
355 - [h . t] then true  
356 - }, 368 + with email_id = to_ascii(sha1((from, send_date))),
  369 + data_text = if length(text_content) > 0 then
  370 + "Content-Type: text/plain; charset=UTF-8" + crlf +
  371 + "Content-Transfer-Encoding: 8bit" + crlf +
  372 + crlf +
  373 + encode_content(text_content, false)
  374 + else
  375 + "",
  376 + data_html = if length(html_content) > 0 then
  377 + "Content-Type: text/html; charset=UTF-8" + crlf +
  378 + "Content-Transfer-Encoding: 8bit" + crlf +
  379 + crlf +
  380 + encode_content(html_content, true)
  381 + else
  382 + "",
  383 + body_text = make_alternative(email_id, data_text, data_html),
  384 +
  385 + is_multipart = if length(files) > 0 then true else false,
  386 +// is
  387 +// {
  388 +// [] then false,
  389 +// [h . t] then true
  390 +// },
357 391
358 - "Message-ID: " + to_ascii(sha1((from, send_date))) + crlf + 392 + "Message-ID: " + email_id + crlf +
359 "Date: " + send_date + crlf + 393 "Date: " + send_date + crlf +
360 // "From: " + user.login + "<" + user.login + "@" + domain + ">" + crlf + 394 // "From: " + user.login + "<" + user.login + "@" + domain + ">" + crlf +
361 "User-Agent: Anubis XLib email sender" + crlf + 395 "User-Agent: Anubis XLib email sender" + crlf +
@@ -380,19 +414,19 @@ public define String @@ -380,19 +414,19 @@ public define String
380 "Subject: " + to_folded_base64_text("UTF-8", subject) + crlf 414 "Subject: " + to_folded_base64_text("UTF-8", subject) + crlf
381 ) + 415 ) +
382 if is_multipart then 416 if is_multipart then
383 - with boundary = to_ascii(sha1((from, send_date))), 417 + with boundary = "=_mixed_"+email_id+"_=",
384 "Content-Type: multipart/mixed;" + crlf + 418 "Content-Type: multipart/mixed;" + crlf +
385 " boundary=\"" + boundary + "\"" + crlf + 419 " boundary=\"" + boundary + "\"" + crlf +
386 crlf + 420 crlf +
387 "This is a multi-part message in MIME format." + crlf + 421 "This is a multi-part message in MIME format." + crlf +
388 "--" + boundary + crlf + 422 "--" + boundary + crlf +
389 - data_text + crlf + 423 + body_text + crlf +
390 424
391 data_files_multipart(files, boundary) + 425 data_files_multipart(files, boundary) +
392 426
393 "--" + boundary + "--" 427 "--" + boundary + "--"
394 else 428 else
395 - data_text 429 + body_text
396 . 430 .
397 431
398 432
mail/types/generated/email_to_send.anubis
1 -/* 1 +/*
2 * Created by 伝作 (Densaku). 2 * Created by 伝作 (Densaku).
3 * Types & Messages generator written by フランスのトトロ aka (David RENÉ) 3 * Types & Messages generator written by フランスのトトロ aka (David RENÉ)
4 * Date: 2020-04-01 4 * Date: 2020-04-01
@@ -10,8 +10,8 @@ transmit system/muscle.anubis @@ -10,8 +10,8 @@ transmit system/muscle.anubis
10 transmit system/convert.anubis 10 transmit system/convert.anubis
11 transmit tools/basis.anubis 11 transmit tools/basis.anubis
12 12
13 -transmit types/generated/file_ref.anubis  
14 -transmit types/generated/email_address.anubis 13 +transmit calexium_lib/types/generated/file_ref.anubis
  14 +transmit calexium_lib/mail/types/generated/email_address.anubis
15 15
16 16
17 17