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.
Related
I'm sending an html-formatted email with a link like this:
click here
It works fine in most email clients, but for a very small percentage of recipients, they receive a modified link that either removes the "." before "com" or adds a second "." before the com. Like one of these:
click here
click here
I can think of two possible causes
A bug in a mail server or email client
I'm thinking this is the more likely cause. The dot that gets doubled is the first dot on a line (see below), which seems to be part of the SMTP spec ("dot stuffing"). Some server or client is likely processing this incorrectly.
If this is the case, I still don't know how to prevent it from happening.
A formatting error in the email content that I'm sending
I've copied the email as received by gmail below. I've tried to remove unnecessary detail but keep anything that could potentially cause a problem.
Perhaps there is a special character that I should be escaping or encoding in a different way. I've seen conflicting info about whether to use \n or \r\n for line endings so not sure if that is relevant.
I can reformat my email template so that the dot in ".com" won't ever be the first dot on a line, but there could be other dots that could be first on a line.
Any insights would be greatly appreciated. This has been an infuriating bug!
--7322d27723a96e14a03643b49db19027e8314f2950d710d4f12530b99277
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
Mime-Version: 1.0
Use this link:
https://www.example.com/123?e=3Duser%40examp=
le.com&c=abcde
--7322d27723a96e14a03643b49db19027e8314f2950d710d4f12530b99277
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
Mime-Version: 1.0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.=
w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=3D"http://www.w3.org/1999/xhtml">
<head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF=
-8" />
<title></title>
</head>
<body>
<table border=3D"0" cellpadding=3D"0" cellspacing=3D"0" height=3D"100%" id=
=3D"bodyTable" width=3D"100%">
<tbody>
<tr>
<td align=3D"center" valign=3D"top">
<table border=3D"0" cellpadding=3D"20" cellspacing=3D"0" id=3D"emailContain=
er" width=3D"600">
<tbody>
<tr bgcolor=3D"#3d486f">
<td align=3D"center" style=3D"padding:10px 0;">
</td>
</tr>
<tr>
<td valign=3D"top">
<p>Click on this button:</p>
<p align=3D"center" style=3D"margin:20px 0;"><a href=3D"https://www.example=
.com/123?e=3Duser%40example.com&c=abc=
de" style=3D"padding:10px 25px; color:#FFF; text-decoration:none; cu=
rsor:pointer; border-radius:5px; background-color:#3d486f;">Vote</a></p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</body>
</html>
--7322d27723a96e14a03643b49db19027e8314f2950d710d4f12530b99277--
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"
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
I can't seem to get google prettify to work with basic XML: anyone got this to work, or can see what I am doing wrong: here is my code:
<html>
<head>
<meta charset="utf-8" />
<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js?autoload=true&skin=sunburst&lang=xml"></script>
</head>
<body>
<h1>XML Output</h1>
<pre class="prettyprint" id="quine" style="border:4px solid #88c">
<Rest_appt_pull licenseKey="123" passWord="456" start="30-oct-2014 00:00:00" finish="31-oct-2014 23:59:59" p_method="event">
<timings>
<entry label="Read"
time=".03"
segment=".03" />
<entry label="Processing XML"
time=".04"
segment=".01" />
</timings>
</Rest_appt_pull>
</pre>
</body>
</html>
Any help would be gratefully appreciated
The root cause is html tag symbol.
Change < to <
Change > to >
You need to html encode your xml code example first. You can use one of available online tools to do that. Then just wrap it in pre/code
<pre class="prettyprint lang-xml"> ... your html encoded xml code ... </pre>
and attach js code on the site.
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. \; \; \; \; \;</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. \; \; \; \; \;</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.