Which is best way to add footer text in email? - email

My target is to modify MIME contents & add footer note in email, without changing it's behavior.
If email content content type is text/plain then I'm updating email content type to multipart/mixed as below:
Content-Type: multipart/mixed;
Boundary="--=_SAMPLE_MIME_BOUNDARY_"
email original data
----=_SAMPLE_MIME_BOUNDARY_
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
!-- Sample footer note --!
----=_SAMPLE_MIME_BOUNDARY_--
And if email content type is by default multipart/mixed then I'm updating email contents are as below:
Content-Type: multipart/mixed;
boundary="----=_SAMPLE_MIME_BOUNDARY_"
------=_SAMPLE_MIME_BOUNDARY_
Content-Type: text/plain;
Content-Transfer-Encoding: 8bit
email data
------=_SAMPLE_MIME_BOUNDARY_
Content-Type: application/octet-stream;
name="test_attachment"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test_attachment"
<<attachment data>>
------=_SAMPLE_MIME_BOUNDARY_
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit;
Content-Disposition: inline;
!-- Sample footer note --!
------=_20160127171644_62291--
But when I update email body then Outlook treat sample note as an attachment. And in case of Thunderbird when I click on forward email it will treat footer as an attachment.
So my questions are, Which is best way to add footer text in email?
Am I doing right? Suggest changes/pinpoints if anything wrong.

The MIME structure of your message is wrong. It needs to be
multipart/mixed
multipart/alternative
text/plain
text/html
application/octet-stream

Related

Should I design my API to receive JSON as a hierarchy child?

I'm designing an API that receives a form post request from the front end. The front-end form contains both regular form
fields and a file upload field. Let's say the behaviour of a trivial front-end from show as below
<form>
<input type="file" name="image">
<input type="text" name="field_1">
<input type="text" name="field_2">
</form>
would result the following post request:
Content-Disposition: form-data; name="image"
Content-Type: application/octet-stream
===CONTENT OF THE IMAGE===
Content-Disposition: form-data; name="field_1"
value of field 1
Content-Disposition: form-data; name="field_2"
value of field 2
But another backend developer insisted that we should wrap all of the fields except the image into a json object so that the request appears like
Content-Disposition: form-data; name="image"
Content-Type: application/octet-stream
===CONTENT OF THE IMAGE===
Content-Disposition: form-data; name="body"
{
"field_1": "value of field 1",
"field_2": "value of field 2"
}
Our backend technology is Spring/Boot, and as a result, the latter design would greatly simplify our controller signature, like
public EmptyResponse acceptFormInput(
#RequestPart EmptyResponse body,
#RequestPart("file") MultipartFile file
)
It appears to me that the Controller should directly reflect what our API looks like. And the controller signature should reflect the API declaration. But that fellow developer argued that the nesting API design is also part of the W3C standard (in draft though), thus should be doable. (W3C plan)
I'm having trouble figuring out which is the common practice in designing such API. Any suggestion is appreciated.

How to replicate a composite POST in SOAP-UI

I'm trying to test an endpoint that will accept a certain request. It takes 5 minutes to go through the process of firing off the request, so I'd like to replicate it in SOAP-UI. I'm not sure how to get the request to look like the following.
Host: somedomain.net
User-Agent: Jakarta; Commons-HttpClient/3.0.1
--7ZRj4zj5nzTkWtBlwkO5Y4Il-En_uTGP2enCIMn
Content-Disposition: form-data; name="companyId"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
985
--7ZRj4zj5nzTkWtBlwkO5Y4Il-En_uTGP2enCIMn
Content-Disposition: form-data; name="inputFormData"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><response>Response XML Data</response>
--7ZRj4zj5nzTkWtBlwkO5Y4Il-En_uTGP2enCIMn
Content-Disposition: form-data; name="completedAgreement"; filename="48ce7fa4079790440a964815a744d232.zip"
Content-Type: application/octet-stream; charset=ISO-8859-1
Content-Transfer-Encoding: binary
PK
Any help would be appreciated.
I could not recreate in SOAP-UI but I was able to create a simple html form to get the job done.
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<form action="/api/receiver" method="post" enctype="multipart/form-data">
<p>
Company Id:<br />
<input type="text" value="725" name="companyId" />
</p>
<p>
Input Form Data:<br />
<textarea name="inputFormData" rows="10" cols="50">
</textarea>
</p>
<p>
Completed Agreement:<br />
<input type="file" name="completedAgreement" />
</p>
<p>
<input type="submit" value="submit" />
</p>
</form>
</body>
</html>
The most important part was setting the enctype in the form tag to enctype="multipart/form-data"

Wicket form makes entire page disappear

A couple of years ago I was moderately proficient in Wicket. Today I picked it up again at the latest version, 6.12.0. I'm using it in an embedded Jetty server. I managed to configure everything and get a "Hello World" page working.
But here's the odd thing: the minute I add a form, the entire page disappears! Let's say I have:
<h1>Hello</h1>
<p>blah</p>
<p><label>Upload File:</label> <input wicket:id="fileUpload"
type="file" size="40" /><br /> <input wicket:id="uploadButton"
type="submit" value="Upload" /></p>
That works fine. Then I add:
<h1>Hello</h1>
<p>blah</p>
<form wicket:id="form">...</form>
Suddenly the page is blank! The response code is still 200 OK, but there is no content. Here's what comes back:
Date: Tue, 19 Nov 2013 01:32:48 GMT
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Pragma: no-cache
Cache-Control: no-cache, no-store
Transfer-Encoding: chunked
Server: Jetty(9.1.0.v20131115)
200 OK
Yes, when I add the form, I make sure the components on the form (e.g. the buttons) are now programmatically added to the form instead of the page:
final Form form=new Form("form");
form.add(new FileUploadField("fileUpload"));
form.add(new Button("uploadButton"));
add(form);
My Jetty configuration had disabled sessions. I didn't see the exception (which was clear about the problem) because I hadn't configured log4j for the project. After changing NO_SESSIONS to SESSIONS forms seem to work fine:
final ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);

DKIM wrong body hash using Perl CPAN Mail::DKIM::Signer

I have a script that is sending emails via SMTP and I'm trying to get it to sign emails with a DKIM signature using CPAN's Mail::DKIM::Signer. The trouble is I am getting error that the body hash is invalid. For example I sent the email below to the port25.com verifier and it is telling me the body hash it expected is "QFBPfFyqSONobf7fNoeeGl652WY=" but my signature says "qUFULrL5rN08Illvd85ZYXxgNNk=".
My DNS record is "k=rsa; t=s; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDs5BnRmpNH0Pz6B02+z
F2GuLm7ahrEXu6zB3WgxySbAGT8v9rpzI7ePhXhxo/RMXR9p5IYtzmBJ0NTjNLDKRFeSOMTeRdDi8DnO
4gUxKyT3v31IvS0+1ZZH2Sj404uv/jg2TKNinIU4/v+pM4ImLZ8uIXsEXRFgGhwKTjTJRNX0QIDAQAB"
Is anyone able to shed some light onto why recipients (including yahoo & port25) are expecting a different body hash? Something to do with the way it's encoded?
This is a MIME encoded message.
--=_b4326086ed9a1ae338d4dabe6b015dde
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi this is a test of DKIM. Bye!
--=_b4326086ed9a1ae338d4dabe6b015dde
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<style type=3D"text/css">
body,td,th { font-family: Verdana; font-size: 13px; color: #000000; }
body { background-color: #3895CB; margin: 0px 20px; text-align:center; }
</style>
</head>
<body>
Hi this a test of <b>DKIM</b>. Bye!
</body>
</html>
--=_b4326086ed9a1ae338d4dabe6b015dde--
Problem solved.
dos2unix on the email before signing it did the trick.
Does that means the problem was with carriage returns or something?
I had the same problem. I used '\n' as newline.
Chaning this to '\r\n' solved the problem.

HTML in iCal attachment

Can an iCal attachment contain HTML in the description property? If so, what are the restrictions?
After doing some research and testing. The answer is a qualified no. Meaning: you could throw it in there, but you shouldn't.
It is not strictly forbidden by the RFC, but DESCRIPTION is not the appropriate property for HTML content.
DESCRIPTION should be the plain text version of your content. The property X-ALT-DESC with a FMTTYPE declaration of text/html is the appropriate property for HTML content.
The following example worked in both Outlook and Gmail/Google Calendar, but does not appear to be supported by Thunderbird(w/Lightning): (please, forgive the ouput. it was generated by Outlook)
X-ALT-DESC;FMTTYPE=text/html:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//E
N">\n<HTML>\n<HEAD>\n<META NAME="Generator" CONTENT="MS Exchange Server ve
rsion 08.00.0681.000">\n<TITLE></TITLE>\n</HEAD>\n<BODY>\n<!-- Converted f
rom text/rtf format -->\n\n<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPAN LANG
="en-us"><FONT FACE="Calibri">Is this in HTML?</FONT></SPAN><SPAN LANG="en
-us"></SPAN><SPAN LANG="en-us"></SPAN></P>\n\n<P DIR=LTR><SPAN LANG="en-us
"><FONT FACE="Calibri">Bullets:</FONT></SPAN></P>\n\n<P DIR=LTR><SPAN LANG
="en-us"><FONT FACE="Calibri">1.&nbsp\;&nbsp\;&nbsp\;&nbsp\;&nbsp\;</FONT>
</SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-
us"></SPAN><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"> <FONT FACE="Calib
ri">Test 1</FONT></SPAN></P>\n\n<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="
Calibri">2.&nbsp\;&nbsp\;&nbsp\;&nbsp\;&nbsp\;</FONT></SPAN><SPAN LANG="en
-us"> <FONT FACE="Calibri">Test 2</FONT></SPAN><SPAN LANG="en-us"></SPAN><
SPAN LANG="en-us"></SPAN></P>\n\n<P DIR=LTR><SPAN LANG="en-us"></SPAN><SPA
N LANG="en-us"></SPAN><SPAN LANG="en-us"></SPAN></P>\n\n</BODY>\n</HTML>
Like any HTML rendering in an email client supported tags and styles are limited.
HTML in the description won't be rendered as HTML in Outlook, at the least. If you want to include rich text that Outlook will recognize, export an event from your Outlook calendar, and take a look at what they do. I believe they provide plain-text in the Description and then create another property for the HTML.
For anyone happening upon this page like I did and is looking to specifically have HTML content displayed for Outlook events...
As the accepted answer states, the DESCRIPTION shouldn't have any HTML. However, you can get HTML into the content of the event (at least in Outlook) using a multipart/alternative email.
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="_CAL_B598a1969806776.58663423_B_"
To: "Your Name" <yourname#example.com>
From: "John Doe" <john.doe#example.com>
--_CAL_B598a1969806776.58663423_B_
Content-Type: text/html; charset="iso - 8859 - 1"
Content-Transfer-Encoding: quoted-printable
<html><body>
<h1>Hello World</h1>
<p>This is a calendar event test</p>
</body></html>
--_CAL_B598a1969806776.58663423_B_
Content-Type: text/calendar; charset="utf - 8"; method=REQUEST
Content-Transfer-Encoding: base64
QkVHSU46VkNBTEVOREFSDQpNRVRIT0Q6UkVRVUVTVA0KUFJPRElEOi0vL1BIUC8vTWVl
dGluZ1JlcXVlc3QvL0VODQpWRVJTSU9OOjIuMA0KQkVHSU46VkVWRU5UDQpPUkdBTkla
RVI7Q049Sm9obiBEb2U6TUFJTFRPOmpvaG4uZG9lQGV4YW1wbGUuY29tDQpBVFRFTkRF
RTtST0xFPVJFUS1QQVJUSUNJUEFOVDtQQVJUU1RBVD1ORUVEUy1BQ1RJT047UlNWUD1U
UlVFO0NOPVlvdXIgTmFtZTpNQUlMVE86eW91cm5hbWVAZXhhbXBsZS5jb20NCkRFU0NS
SVBUSU9OOkhlbGxvIFdvcmxkIEV2ZW50DQpTVU1NQVJZOkhlbGxvIFdvcmxkIEV2ZW50
DQpEVFNUQVJUOjIwMTcwODE1VDE5MDAwMFoNCkRURU5EOjIwMTcwODE1VDIwMDAwMFoN
ClVJRDowMTIzNDU2Nzg5DQpDTEFTUzpQVUJMSUMNClBSSU9SSVRZOjUNCkRUU1RBTVA6
MjAxNzA4MDhUMjAwNDU3Wg0KVFJBTlNQOk9QQVFVRQ0KU1RBVFVTOkNPTkZJUk1FRA0K
U0VRVUVOQ0U6MA0KTE9DQVRJT046MTIzIEFueSBTdHJlZXQNCkJFR0lOOlZBTEFSTQ0K
QUNUSU9OOkRJU1BMQVkNCkRFU0NSSVBUSU9OOlJFTUlOREVSDQpUUklHR0VSO1JFTEFU
RUQ9U1RBUlQ6LVBUMTVNDQpFTkQ6VkFMQVJNDQpFTkQ6VkVWRU5UDQpFTkQ6VkNBTEVO
REFS
--_CAL_B598a1969806776.58663423_B_--
In case you are wondering, that Base64 encoding translates to:
BEGIN:VCALENDAR
METHOD:REQUEST
PRODID:-//PHP//MeetingRequest//EN
VERSION:2.0
BEGIN:VEVENT
ORGANIZER;CN=John Doe:MAILTO:john.doe#example.com
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Your Name:MAILTO:yourname#example.com
DESCRIPTION:Hello World Event
SUMMARY:Hello World Event
DTSTART:20170815T190000Z
DTEND:20170815T200000Z
UID:0123456789
CLASS:PUBLIC
PRIORITY:5
DTSTAMP:20170808T200457Z
TRANSP:OPAQUE
STATUS:CONFIRMED
SEQUENCE:0
LOCATION:123 Any Street
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:REMINDER
TRIGGER;RELATED=START:-PT15M
END:VALARM
END:VEVENT
END:VCALENDAR
I think it's possible, according to the RFC, but I doubt that it's a good idea, as it appears to be a bit of a security hole.