I have a weird issue but not sure what to make of it,
I have a .net console application that prepares some data and FTP's it over
after the operation is complete it's supposed to send out a confirmation email - only what happens is that sometimes email is recieved, sometimes not
the application runs under a schedulear from SQL Job Agent using sql server 2014
the app is on the same server as the database , owner is sa and job is run under SQL Server agent - SQLSERVERAGENT has all the rights on the folder
Mail server being used is MDaemon, checking on the server logs it reveals that:
Fri 2016-08-12 06:28:50.387: 01: ----------
Fri 2016-08-12 06:31:24.154: 05: Session 834167; child 0001
Fri 2016-08-12 06:31:24.154: 05: Accepting SMTP connection from xxx to xxx
Fri 2016-08-12 06:31:24.164: 03: --> xxx ESMTP MDaemon 16.0.4; Fri, 12 Aug 2016 06:31:24 +1000
Fri 2016-08-12 06:31:24.164: 03: --> 220-Unauthorized relay prohibited.
Fri 2016-08-12 06:31:24.164: 03: --> 220 All transactions and IP are logged.
Fri 2016-08-12 06:31:24.167: 02: <-- EHLO OCSQL2
Fri 2016-08-12 06:31:24.168: 03: --> xxx Hello OCSQL2 [10.10.45.34], pleased to meet you
Fri 2016-08-12 06:31:24.168: 03: --> 250-ETRN
Fri 2016-08-12 06:31:24.168: 03: --> 250-AUTH LOGIN CRAM-MD5 PLAIN
Fri 2016-08-12 06:31:24.168: 03: --> 250-8BITMIME
Fri 2016-08-12 06:31:24.168: 03: --> 250-ENHANCEDSTATUSCODES
Fri 2016-08-12 06:31:24.168: 03: --> 250-STARTTLS
Fri 2016-08-12 06:31:24.168: 03: --> 250 SIZE
Fri 2016-08-12 06:31:24.168: 02: <-- MAIL FROM:<xxx>
Fri 2016-08-12 06:31:24.170: 01: xxx is an alias for xxx
Fri 2016-08-12 06:31:24.170: 03: --> 250 2.1.0 Sender OK
Fri 2016-08-12 06:31:24.170: 02: <-- RCPT TO:<xxx>
Fri 2016-08-12 06:31:24.175: 03: --> 250 2.1.5 Recipient OK
Fri 2016-08-12 06:31:24.175: 02: <-- RCPT TO:<xxx>
Fri 2016-08-12 06:31:24.265: 03: --> 250 2.1.5 Recipient OK
Fri 2016-08-12 06:31:24.266: 02: <-- RCPT TO:<xxx>
Fri 2016-08-12 06:31:24.270: 03: --> 250 2.1.5 Recipient OK
Fri 2016-08-12 06:31:24.270: 02: <-- RCPT TO:<xxx>
Fri 2016-08-12 06:31:24.275: 03: --> 250 2.1.5 Recipient OK
Fri 2016-08-12 06:31:24.276: 02: <-- RCPT TO:<xxx>
Fri 2016-08-12 06:31:24.281: 03: --> 250 2.1.5 Recipient OK
Fri 2016-08-12 06:31:24.281: 02: <-- RCPT TO:<xxx>
Fri 2016-08-12 06:31:24.286: 03: --> 250 2.1.5 Recipient OK
Fri 2016-08-12 06:31:24.286: 02: <-- DATA
Fri 2016-08-12 06:31:24.290: 01: Creating temp file (SMTP): e:\mdaemon\queues\temp\md50000008212.tmp
Fri 2016-08-12 06:31:24.290: 03: --> 354 Enter mail, end with <CRLF>.<CRLF>
Fri 2016-08-12 06:31:24.295: 01: Message size: 552 bytes
Fri 2016-08-12 06:31:24.323: 04: Socket error sending response to DATA
Fri 2016-08-12 06:31:24.324: 04: * Socket error 10054 - Connection was reset by the other side!
Fri 2016-08-12 06:31:24.324: 04: SMTP session terminated (Bytes in/out: 841/540)
code in the application:
public bool sendUploadNotification() {
var arrToEmail = toEmail.Split(';');
var arrCCEmail = ccEmail.Split(';');
MailMessage msg = new MailMessage();
string body;
string subject;
bool result = false;
if (logger.IsDebugEnabled) { logger.Debug("sending upload email"); }
try {
body = ReadBody();
subject = GetSubject();
if (logger.IsDebugEnabled) {
logger.Debug("ToEmail:" + toEmail + "," + "CCEmail:" + ccEmail + ",Subject:" + subject);
}
msg.IsBodyHtml = true;
msg.BodyEncoding = Encoding.UTF8;
msg.SubjectEncoding = Encoding.UTF8;
msg.From = new MailAddress(fromEmail,fromName);
msg.Subject = subject;
msg.Body = body;
foreach (var item in arrToEmail) {
msg.To.Add(new MailAddress(item));
}
foreach (var item in arrCCEmail) {
msg.CC.Add(new MailAddress(item));
}
client.Send(msg);
result = true;
if (logger.IsInfoEnabled) {
logger.Info("Upload confirmation email sent");
}
}
catch (Exception ex) {
if (logger.IsErrorEnabled) {
logger.Error("Error sending upload confirmation email", ex);
}
sendExceptionMail(ex);
result = false;
}
return result;
}
I'm not getting any exception in the application logs, everything is completed successfully.
the server has other .net modules which don't seem to have this problem, however other modules that send out emails are not triggered by SQL agent, they are called at runtime from the website
this problem seems to occur at random, most of the times it doesn't work, sometimes I have recieved the email as expected with no changes to the application or the server
I can't figure out why it's failing, searching google turned up some issue with windows 2008 server regarding tcp / ip stack but I'm on windows server 2012 R2 - the only thing that I can think if it may have to do with permissions, but it works sometimes
I have the same situation yesterday. For first, you will need to make sure of the email addresses are in correct format. believe me or not it can make you a problem.
Using System.ComponentModel;
foreach (var item in arrToEmail)
{
if (RegularExpressions.Regex.IsMatch(Strings.Trim(Sender), "^\\w+([-+.']\\w+)*#\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$"))
{
msg.To.Add(new MailAddress(item));
}
}
foreach (var item in arrCCEmail)
{
if (RegularExpressions.Regex.IsMatch(Strings.Trim(Sender), "^\\w+([-+.']\\w+)*#\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$"))
{
msg.CC.Add(new MailAddress(item));
}
}
Second, add the sender to your mail construction. MDaemon is very tricky and touchy.
msg.Sender = New MailAddress(credentialUser)
Third, Don't close the application too fast or dispose the "client" variable you have (assuming is a SMTPClient object). If the connection was dispose too fast, MDaemon think the 3rd party cancel the operation regardless if the mail structure is on MDaemon Server.
Optional, you can use Async Send Mail in your application. This will give you the confirmation and the right time of an email was sended (or failed).
For Example:
Before client.send(msg); in your code you can add this:
// Set the method that is called back when the send operation ends.
smtp.SendCompleted += SendCompletedCallback;
string userState = "Email Token or any text here to identify your Operation";
//This line will replace "client.send(msg)" code
smtp.SendAsync(msg, userState);
Somewhere in your code add this delegate:
private void SendCompletedCallback(object sender, AsyncCompletedEventArgs e) {
// Get the unique identifier for this asynchronous operation.
string token = e.UserState.ToString();
if (e.Cancelled) {
Console.WriteLine("[{0}] Send canceled.", token);
}
if (e.Error != null) {
Console.WriteLine("[{0}] {1}", token, e.Error.ToString());
}
else {
Console.WriteLine("Message sent.");
}
}
Hope it helps!
Related
I'm connecting to Office 365 mail servers using IMAP.
Our sysadmin enabled the anti-spam, so any recieved mail from outside is transformed: we just recieve a forward message rather that the original message.
With Thunderbird or Outlook Web Access, I can see the original mail as an attached EML file.
But when I try to parse attachements in the mails, I can't find attachement in those mails. If I recieve an email with a real attachement, I get can find it as attachement.
I tried a message.ToString() to get the complete message I recieve:
Received: from *****.prod.outlook.com (*****)
by *****.prod.outlook.com with HTTPS; Thu, 11 Aug 2022
13:37:42 +0000
Received: from *****.PROD.OUTLOOK.COM (*****) by
*****.prod.outlook.com (*****) with
Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.23; Thu, 11 Aug
2022 13:37:41 +0000
Received: from *****.prod.protection.outlook.com
(*****) by *****.outlook.office365.com
(*****) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11 via Frontend
Transport; Thu, 11 Aug 2022 13:37:41 +0000
Authentication-Results: spf=none (sender IP is *****)
smtp.helo=*****.aznetwork.eu; dkim=none (message not signed)
header.d=none;dmarc=none action=none header.from=aznetwork.eu;compauth=pass
reason=105
Received-SPF: None (protection.outlook.com: *****.aznetwork.eu does not
designate permitted sender hosts)
Received: from *****.aznetwork.eu (*****) by
*****.mail.protection.outlook.com (*****) with Microsoft SMTP
Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
15.20.5525.11 via Frontend Transport; Thu, 11 Aug 2022 13:37:41 +0000
Received: from localhost (localhost.localdomain [127.0.0.1])
by *****.aznetwork.eu (Postfix) with ESMTP id 053BC1C631E
for <recipient#mail.com>; Thu, 11 Aug 2022 15:37:41 +0200 (CEST)
Received: from *****.aznetwork.eu ([127.0.0.1])
by localhost (*****.aznetwork.eu [127.0.0.1]) (amavisd-new, port 10032)
with ESMTP id Tin75ip0CVd1 for <recipient#mail.com>;
Thu, 11 Aug 2022 15:37:40 +0200 (CEST)
Received: from localhost (localhost.localdomain [127.0.0.1])
by *****.aznetwork.eu (Postfix) with ESMTP id B55251C6446
for <recipient#mail.com>; Thu, 11 Aug 2022 15:37:40 +0200 (CEST)
X-Virus-Scanned: amavisd-new at *****.aznetwork.eu
Received: from *****.aznetwork.eu ([127.0.0.1])
by localhost (*****.aznetwork.eu [127.0.0.1]) (amavisd-new, port 10026)
with ESMTP id 4lpOVXL1yFKw for <recipient#mail.com>;
Thu, 11 Aug 2022 15:37:40 +0200 (CEST)
Received: from *****.aznetwork.eu (*****.aznetwork.priv [*****])
by *****.aznetwork.eu (Postfix) with ESMTP id 9E4CB1C631E
for <recipient#mail.com>; Thu, 11 Aug 2022 15:37:40 +0200 (CEST)
Date: Thu, 11 Aug 2022 15:37:40 +0200 (CEST)
From: Sender Name <sender#mail.com>
To: recipient#mail.com
Message-ID: <1682353652.2846324.1660225060639.JavaMail.zimbra#aznetwork.eu>
Subject: [EXTERNE] Read-Receipt: Mail Subject
Auto-Submitted: auto-replied (zimbra; read-receipt)
Precedence: bulk
Return-Path: <>
X-MS-Exchange-Organization-ExpirationStartTime: 11 Aug 2022 13:37:41.4732
(UTC)
X-MS-Exchange-Organization-ExpirationStartTimeReason: OriginalSubmit
X-MS-Exchange-Organization-ExpirationInterval: 1:00:00:00.0000000
X-MS-Exchange-Organization-ExpirationIntervalReason: OriginalSubmit
X-MS-Exchange-Organization-Network-Message-Id:
384141c3-c532-4391-771a-08da7b9eaa12
X-EOPAttributedMessage: 0
X-EOPTenantAttributedMessage: 873b62a6-6fcf-467d-8380-ce41a1d6da9f:0
X-MS-Exchange-Organization-MessageDirectionality: Incoming
X-MS-PublicTrafficType: Email
X-MS-Exchange-Organization-AuthSource:
*****.prod.protection.outlook.com
X-MS-Exchange-Organization-AuthAs: Anonymous
X-MS-Office365-Filtering-Correlation-Id: 384141c3-c532-4391-771a-08da7b9eaa12
X-MS-TrafficTypeDiagnostic: AM9PR02MB7641:EE_
Content-Type: multipart/mixed;
boundary="_16f20566-32fe-437d-8fb6-e2fcbadabd01_"
X-MS-Exchange-Organization-SCL: 1
X-Microsoft-Antispam: BCL:0;
X-Forefront-Antispam-Report:
CIP:*****;CTRY:FR;LANG:fr;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:*****.aznetwork.eu;PTR:*****.aznetwork.eu;CAT:NONE;SFS:(13230016)(36756003)(7696005)(6266002)(26005)(564344004)(356005)(7636003)(336012)(426003)(2616005)(66574015)(42882007)(83380400001)(78352004)(5660300002)(8676002)(6916009)(1096003);DIR:INB;
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2022 13:37:41.3795
(UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: 384141c3-c532-4391-771a-08da7b9eaa12
X-MS-Exchange-CrossTenant-Id: 873b62a6-6fcf-467d-8380-ce41a1d6da9f
X-MS-Exchange-CrossTenant-AuthSource:
*****.prod.protection.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Anonymous
X-MS-Exchange-CrossTenant-FromEntityHeader: Internet
X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR02MB7641
X-MS-Exchange-Transport-EndToEndLatency: 00:00:01.2537846
X-MS-Exchange-Processed-By-BccFoldering: 15.20.5525.010
X-Microsoft-Antispam-Mailbox-Delivery:
ucf:0;jmr:0;auth:0;dest:I;ENG:(910001)(944506458)(944626604)(920097)(930097);
X-Microsoft-Antispam-Message-Info:
=?iso-8859-1?somebase64data=
MIME-Version: 1.0
--_16f20566-32fe-437d-8fb6-e2fcbadabd01_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
ATTENTION: Ce message est originaire de l'ext=E9rieur de ***. Ne pas clique=
r sur les liens internet ou ouvrir les pi=E8ces jointes =E0 moins que vous =
ne connaissiez l'auteur ou sachiez que le contenu est sain (pas de virus).
--_16f20566-32fe-437d-8fb6-e2fcbadabd01_
Content-Type: message/rfc822
X-MS-Exchange-Organization-InternalOrgSender: True
Received: from *****.PROD.OUTLOOK.COM (*****) by
*****.prod.outlook.com (*****) with
Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.23; Thu, 11 Aug
2022 13:37:41 +0000
Received: from *****.prod.protection.outlook.com
(*****) by *****.outlook.office365.com
(*****) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11 via Frontend
Transport; Thu, 11 Aug 2022 13:37:41 +0000
Authentication-Results: spf=none (sender IP is *****)
smtp.helo=*****.aznetwork.eu; dkim=none (message not signed)
header.d=none;dmarc=none action=none header.from=aznetwork.eu;
Received-SPF: None (protection.outlook.com: *****.aznetwork.eu does not
designate permitted sender hosts)
Received: from *****.aznetwork.eu (*****) by
*****.mail.protection.outlook.com (*****) with Microsoft SMTP
Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
15.20.5525.11 via Frontend Transport; Thu, 11 Aug 2022 13:37:41 +0000
Received: from localhost (localhost.localdomain [127.0.0.1])
by *****.aznetwork.eu (Postfix) with ESMTP id 053BC1C631E
for <recipient#mail.com>; Thu, 11 Aug 2022 15:37:41 +0200 (CEST)
Received: from *****.aznetwork.eu ([127.0.0.1])
by localhost (*****.aznetwork.eu [127.0.0.1]) (amavisd-new, port 10032)
with ESMTP id Tin75ip0CVd1 for <recipient#mail.com>;
Thu, 11 Aug 2022 15:37:40 +0200 (CEST)
Received: from localhost (localhost.localdomain [127.0.0.1])
by *****.aznetwork.eu (Postfix) with ESMTP id B55251C6446
for <recipient#mail.com>; Thu, 11 Aug 2022 15:37:40 +0200 (CEST)
X-Virus-Scanned: amavisd-new at *****.aznetwork.eu
Received: from *****.aznetwork.eu ([127.0.0.1])
by localhost (*****.aznetwork.eu [127.0.0.1]) (amavisd-new, port 10026)
with ESMTP id 4lpOVXL1yFKw for <recipient#mail.com>;
Thu, 11 Aug 2022 15:37:40 +0200 (CEST)
Received: from *****.aznetwork.eu (*****.aznetwork.priv [*****])
by *****.aznetwork.eu (Postfix) with ESMTP id 9E4CB1C631E
for <recipient#mail.com>; Thu, 11 Aug 2022 15:37:40 +0200 (CEST)
Date: Thu, 11 Aug 2022 15:37:40 +0200 (CEST)
From: Sylvain DEVIDAL <sender#mail.com>
To: recipient#mail.com
Message-ID: <1682353652.2846324.1660225060639.JavaMail.zimbra#aznetwork.eu>
Subject: [EXTERNE] Read-Receipt: Mail Subject
Content-Type: multipart/report;
boundary="----=_Part_2846322_558173291.1660225060636"; report-type=disposition-notification
Auto-Submitted: auto-replied (zimbra; read-receipt)
Precedence: bulk
Return-Path: <>
X-MS-Exchange-Organization-OriginalArrivalTime: 11 Aug 2022 13:37:41.3795
(UTC)
X-MS-Exchange-Organization-ExpirationStartTime: 11 Aug 2022 13:37:41.4732
(UTC)
X-MS-Exchange-Organization-ExpirationStartTimeReason: OriginalSubmit
X-MS-Exchange-Organization-ExpirationInterval: 1:00:00:00.0000000
X-MS-Exchange-Organization-ExpirationIntervalReason: OriginalSubmit
X-MS-Exchange-Organization-Network-Message-Id:
384141c3-c532-4391-771a-08da7b9eaa12
X-MS-Exchange-Organization-OriginalClientIPAddress: *****
X-MS-Exchange-Organization-OriginalServerIPAddress: *****
X-EOPAttributedMessage: 0
X-EOPTenantAttributedMessage: 873b62a6-6fcf-467d-8380-ce41a1d6da9f:0
X-MS-Exchange-Organization-TargetResourceForest: *****.prod.outlook.com
X-MS-Exchange-Organization-OrgEopForest: EUR01
X-MS-Exchange-Organization-MessageDirectionality: Incoming
X-MS-Exchange-Organization-Id: 873b62a6-6fcf-467d-8380-ce41a1d6da9f
X-MS-Exchange-Organization-FFO-ServiceTag: EUR01B
X-MS-Exchange-Organization-Cross-Premises-Headers-Processed:
*****.prod.protection.outlook.com
X-MS-Exchange-Organization-ConnectingIP: *****
X-MS-Exchange-Organization-ConnectingEHLO: *****.aznetwork.eu
X-MS-Exchange-Organization-AS-LastExternalIp: *****
X-MS-Exchange-Organization-Originating-Country: FR
X-MS-Exchange-Organization-OriginalEnvelopeRecipients: recipient#mail.com
X-MS-Exchange-Organization-PtrDomains: *****.aznetwork.eu
X-MS-Exchange-Organization-EhloAndPtrDomain:
*****.aznetwork.eu;*****.aznetwork.eu
X-MS-Exchange-Organization-MxPointsToUs: true
X-MS-Exchange-Organization-RecipientMxInfo-PFAFD:
recipientdomain.com#*****.mail.protection.outlook.com
X-MS-Exchange-Organization-CompAuthRes: pass
X-MS-Exchange-Organization-CompAuthReason: 105
X-MS-Exchange-Organization-SpoofDetection-Frontdoor-DisplayDomainName:
aznetwork.eu
X-MS-Exchange-Organization-Auth-ExtendedDmarcStatus: Pass
X-MS-Exchange-Organization-SenderRep-Score: 3
X-MS-Exchange-Organization-SenderRep-Data:
IpClassSmallGrayBest_SmallGrayBest_unknown
X-MS-Exchange-Organization-VBR-Class: SmallGrayBest
X-MS-Exchange-Organization-HMATPModel-Spf: 5
X-MS-Exchange-Organization-HMATPModel-Recipient:
*****
X-MS-Exchange-Organization-TransportTrafficType: Email
X-MS-PublicTrafficType: Email
X-MS-Exchange-Organization-OrderedPrecisionLatencyInProgress:
LSRV=*****.PROD.OUTLOOK.COM:TOTAL-FE=0.093|SMR-PEN=0.082(RENV=0.068);2022-08-11T13:37:41.721Z
X-MS-Exchange-Organization-MessageLatency:
SRV=*****.eop-EUR01.prod.protection.outlook.com:TOTAL-FE=0.247|SMR-PEN=0.221(RENV=0.031(SMRRC=0.029(SMRRC-TenantAttributionAndInboundConnectorAgent=0.026
))|REOH=0.189(SMREH=0.127(SMREH-Protocol Filter Agent=0.124)))|SMS=0.029
X-MS-Exchange-Organization-MessageLatency:
SRV=*****.PROD.OUTLOOK.COM:TOTAL-FE=0.116|SMR-PEN=0.082(RENV=0.068)|SMS=0.023(SMSC=0.033)
X-MS-Exchange-Forest-ArrivalHubServer: *****.prod.outlook.com
X-MS-Exchange-Organization-AuthSource:
*****.prod.protection.outlook.com
X-MS-Exchange-Organization-AuthAs: Anonymous
X-MS-Exchange-Organization-FromEntityHeader: Internet
X-MS-Exchange-Organization-MessageScope: 7ca5d36b-aa6e-4988-8ce2-ebc9e7a7fc2a
X-MS-Exchange-Forest-MessageScope: 7ca5d36b-aa6e-4988-8ce2-ebc9e7a7fc2a
X-MS-Exchange-Organization-Antispam-ProtocolFilterHub-ScanContext:
ProtocolFilterHub:SmtpOnEndOfData;
X-MS-Office365-Filtering-Correlation-Id: 384141c3-c532-4391-771a-08da7b9eaa12
X-MS-Exchange-Organization-P2SenderDisplayNamePII:
H101(Oo2uoTVO0nYrZjTS6UNDuqjuYq+ejtD0u3d/6RR1MgI=)
X-MS-Exchange-Organization-P2SenderPII:
*****
X-MS-Exchange-Organization-PFAHub-Total-Message-Size: 9121
X-MS-Exchange-Organization-OriginalSize: 9121
X-MS-TrafficTypeDiagnostic: AM9PR02MB7641:EE_
X-MS-Exchange-Organization-HygienePolicy: Premium
X-MS-Exchange-Organization-ReplicationInfo:
ReplicaId=9de80d70-aee0-b1f9-8fed-3baa9e7bda08;ReplicatingServerFqdn=*****.eurprd02.prod.outlook.com
X-MS-Exchange-Forest-Language: fr
X-MS-Exchange-Forest-IndexAgent-0:
Somebase64data=
X-MS-Exchange-Forest-IndexAgent: 1 833
X-MS-Exchange-Forest-EmailMessageHash: 6E6C2B22,31F80CB7
X-MS-Exchange-Organization-PhishSim-Rules-Execution-History:
336d57ef-0937-4345-9ee7-7488d99e1eee
X-MS-Exchange-Organization-Antispam-PreContentFilter-PolicyLoadTime:
PSOSUB:6;PSOSUBLOAD:5;PSOSUBRUN:0;PSOSUBCOUNT:1;SMORES:2;SMORESLOAD:1;SMORESRUN:0;SMORESCOUNT:0;SAORES:4;SAORESLOAD:1;SLORES:2;APORES:22;APORESLOAD:1;APORESRUN:20;APORESCOUNT:2;RSORES:1;SLORESLOAD:1;
X-MS-Exchange-Organization-AttachmentDetailsHeaderStamp-Success: 1.0
X-MS-Exchange-Organization-AttachmentDetails:
0:EpUTydEBwSuS9oq8FNAFHYcMPGvyaOa9tpBsGPTlB4k=:U:Text:QVRUMDAwMDQ=::#:False:::N:::N::N:None:
X-MS-Exchange-Organization-MessageFingerprint:
A0DBCBFD.2F1B0759.C2DDF092.B4130E24.200A4
X-MS-Exchange-Organization-AttachmentDetailsInfo-ChunkCount: 1
X-MS-Exchange-Organization-AttachmentDetailsInfo-0:
[{"ID":0,"FS":308,"HFH":"EpUTydEBwSuS9oq8FNAFHYcMPGvyaOa9tpBsGPTlB4k=","FE":"","CEXT":[],"CFT":[],"AF":0,"AFT":"{784:\"ATT00004\",789:\"text\"}"}]
X-MS-Exchange-Organization-FeatureTable:
{385:"aznetwork.eu",452:1,453:1,454:"4A71A110#kp1.fr",504:7,506:4,507:5,508:"none",509:"aznetwork.eu",510:"*****.aznetwork.eu",651:2,653:1,656:1,721:"2.37",722:"2.35",742:1,743:3,744:1,748:"sign",749:"Latn",758:"A0DBC8FE.2F5B0759.F0DDB08F.A01F8E26.20082",781:1,782:8,1010:0,1011:"1830FF39|60572074|",1101:"0.194"}
X-MS-Exchange-Organization-MetadataFeatureTable:
{756:0,757:0,1010:0,1011:"1830FF39|60572074|",1036:"199167"}
X-MS-Exchange-Organization-Antispam-PreContentFilter-ScanContext:
CategorizerOnSubmitted;CategorizerOnResolved;
X-MS-Exchange-Organization-AVScannedByV2: true
X-MS-Exchange-Organization-AVScanComplete: true
X-MS-Exchange-Organization-ExternalRoutingTopologyAnalysis:
X-MS-Exchange-Organization-Recipient-Limit-Verified: True
X-MS-Exchange-Organization-TotalRecipientCount: 1
X-MS-Exchange-Organization-HVERecipientsForked: 1.0
X-MS-Exchange-Organization-AntiPhishPolicy: Default_kp1
X-MS-Exchange-Organization-ASDirectionalityType: 1
X-MS-Exchange-Organization-Boomerang-Verdict: None
X-MS-Exchange-Organization-HMATPModel-DkimAuthStatus: 7
X-MS-Exchange-Organization-HMATPModel-DmarcAuthStatus: 4
X-MS-Exchange-Organization-Cross-Session-Cache:
=?utf-8?somebase64data=
X-MS-Exchange-Organization-Cross-Session-Cache:
01xSupported=1;TMD_SS=1;TMD_AOT=3433;TMD_CSUM=5377;TMD_DTAET=1;TMD_ES=0;TMD_TT=0;TMD_DMNSPM=8914;TMD_DMSPM=338;TMD_PSATP=0;TMD_PS=1939;TMD_SCNT=5;TMD_TSATP=0;TMD_TS=0;TMD_ATPP2=False;TMD_CI=fr-FR;TMD_CD=2013-03-15
09:53:51.000;TMD_NEWT=0;TMD_NEWTT=0;TMD_QS=1;TR_SS=1;TR_SMAS=0;TR_TMAS=0;TR_UMAS=0;TR_TTU24H=0;TR_TT24H=0;TR_AFWR24H=18;TR_NDRSPMR24H=0;TR_R1H=315;TR_R24H=2709;TR_SPMR1H=0;TR_SPMR24H=0;TR_UP1R1H=0;TR_UP1R24H=0;TR_UP1SPMR24H=0;TR_QS=1;BR_V=None;DIR=1;PTRO=aznetwork.eu;P2O=aznetwork.eu;P_CAUTH=pass;P_CAUTHR=105;SIP2BCLAP=-1;SIP2BCLAF=-1;P2BCL=
X-MS-Exchange-Organization-Rules-Execution-History:
95544e5a-848e-428b-b1a3-43568aa659bf%%%5a9c7fc7-bc74-434e-81a5-8fe8f957dcbb%%%22b9f62e-47d3-4bb9-87f7-b1c42aa1f5e3%%%79dacf70-5b24-4672-8325-97733f56b4e3%%%572c1ac3-7cd0-4e7c-8a3b-99003d82e392
MIME-Version: 1.0
------=_Part_2846322_558173291.1660225060636
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Le mail envoy=C3=A9 le 11 ao=C3=BBt 2022 =C3=A0 15:37:26 GMT+02:00 au desti=
nataire sender#mail.com avec l=E2=80=99objet "Mail=
subject" a =C3=A9t=C3=A9 affich=C3=A9. Cela ne signifie aucunement =
que ce mail ait =C3=A9t=C3=A9 lu (ou compris).=
------=_Part_2846322_558173291.1660225060636
Content-Type: message/disposition-notification; charset=utf-8
Content-Transfer-Encoding: 7bit
Reporting-UA: 78.252.48.37; ZimbraWebClient - GC104 (Win)/8.8.15_GA_4257
Original-Recipient: rfc822;sender#mail.com
Final-Recipient: rfc822;sender#mail.com
Original-Message-ID: <YA0XNMBBLHU4.N87S2N70CKU81#dev-crm22-upd1>
Disposition: manual-action/MDN-sent-manually; displayed
------=_Part_2846322_558173291.1660225060636--
--_16f20566-32fe-437d-8fb6-e2fcbadabd01_--
(sorry for the long code)
You can see at line 147 it actually contains the original message, of type "report" (it was a read reciept).
But whatever I try, I can't parse it.
Here is my current code: (message id the mail message as I load if from mailbox)
public static void ProcessReadReceiptNotification(MimeMessage message)
{
/// This part is the "standard way" to find a read-reciept, but it doesn't work
var report = message.Body as MultipartReport;
if (report == null || report.ReportType == null || !report.ReportType.Equals("disposition-notification", StringComparison.OrdinalIgnoreCase))
{
// this is not a read receipt notification message...
Console.WriteLine("this is not a read receipt notification message... will parse parts");
/// Then I tried to iterate all parts of the mail then load the message
foreach (MimeEntity part in message.BodyParts)
{
Console.WriteLine($"A part of type {part.ContentType.MimeType} is found");
if (part.ContentType.MimeType == "message/rfc822")
{
/// Here part.Message private property contains the message
Console.WriteLine("This is a message, we load it");
using MemoryStream ms = new();
part.WriteTo(ms);
ms.Seek(0, SeekOrigin.Begin);
MimeMessage msg = MimeMessage.Load(ms);
/// Here my msg object is empty, or at least doesn't contain message data (subject, body, etc.)
//Console.WriteLine(msg.Body.ToString());
report = msg.Body as MultipartReport;
Console.WriteLine(report?.ToString());
/*
return ProcessReadReceiptNotification(msg);
*/
}
}
Console.Write("Nothing found...");
return;
}
else
{
Console.WriteLine($"Report Type : {report.ReportType}");
// process the report
foreach (var mds in report.OfType<MessageDispositionNotification>())
{
Console.WriteLine($"{mds.Content}");
var messageId = mds.Fields.Single(a => a.Field == "Original-Message-ID");
if (messageId is not null)
{
Console.Write($"Le message {messageId.Value}");
}
var readStatus = mds.Fields.Single(a => a.Field == "Disposition");
if (readStatus is not null)
{
var index = readStatus.Value.IndexOf(";");
Console.WriteLine($" a été {readStatus.Value.Substring(index + 1)}.");
}
return;
}
return;
}
}
How could I load this body part and identify it's a read-reciept (with it's original message id)?
I found that in the part.Message private property I can see the original message. But I can't access to it. part.WriteTo(ms) doesn't copy the message.
I finaly found how to read the original message.
Rather than loading the part as a MimeMessage I just had to load it as a MultipartReport...
foreach (MimeEntity part in message.BodyParts)
{
Console.WriteLine($"A part of type {part.ContentType.MimeType} is found");
if (part.ContentType.MimeType == "message/rfc822")
{
Console.WriteLine("This is a message, we load it");
using MemoryStream ms = new();
part.WriteTo(ms, true);
ms.Seek(0, SeekOrigin.Begin);
report = MimeEntity.Load(ms) as MultipartReport;
Console.WriteLine(report?.ToString());
}
}
There's no need to write the content out to a stream only to re-parse it again.
All you need to do is this:
foreach (MimeEntity part in message.BodyParts)
{
Console.WriteLine($"A part of type {part.ContentType.MimeType} is found");
// MessageParts are message/rfc822 (or equivalent such as message/news
// or message/global which is the UTF-8 version of message/rfc822)
//
// Never use case-sensitive string comparisons like
// part.ContentType.MimeType == "message/rfc822" because MIME does not
// restrict things to lowercase. Instead, the recommended way of checking
// for an exact mime-type is part.ContentType.IsMimeType("message", "rfc822")
// or
// part.ContentType.MimeType.Equals("message/rfc822", StringComparison.OrdinalIgnoreCase).
if (part is MessagePart rfc822)
{
Console.WriteLine("This is a message, lets see if the body is a multipart/report");
if (rfc822.Body is MultipartReport report)
{
// handle the multipart/report which is already in a parsed state
}
}
}
I am using the office api within outlook. I'm trying to set an additional x-header to my mail in the composer scope, so I can identify the mail later on.
I used this documentation here to create my bits of code:
https://learn.microsoft.com/en-us/javascript/api/outlook/office.internetheaders?view=outlook-js-preview
Office.context.mailbox.item.internetHeaders.setAsync({"x-sap-mail-addin-id": this.state.addinMailId}, {
}, (assyRes) => {
Office.context.mailbox.item.internetHeaders.getAsync(["x-sap-mail-addin-id"], { }, (val) => {
console.log(val);
});
console.log(assyRes);
});
As the screens show, the value is set right now.
So I tried to read the mail from the MS Graph (and got it) as follows:
var configuration = provider.GetService<ConfigurationService>();
var clientApp = ConfidentialClientApplicationBuilder
.Create(configuration.AzureAD.ApplicationId)
.WithTenantId(configuration.AzureAD.TenantId)
.WithClientSecret(configuration.AzureAD.AppSecret)
.Build();
var authProvider = new ClientCredentialProvider(clientApp);
var graphClient = new GraphServiceClient(authProvider);
var messageStream = await graphClient.Users["mail2sap-sendmail#gisdev.onmicrosoft.com"].Messages["AAMkADMzNDg3YTFiLWI4NDItNDI5Ni1hNzU1LTE3YmRhYjZkYzFjMwBGAAAAAABc2UL4pp4rRoxnwy3lWAHyBwAmKhkFHv2sRIc0wWWwSW0lAAAAAAEMAAAmKhkFHv2sRIc0wWWwSW0lAAAAAAlEAAA="].Content.Request().GetAsync();
var messageMetaData = await graphClient.Users["mail2sap-sendmail#gisdev.onmicrosoft.com"].Messages.Request().GetAsync();
So I'd have expected the header to be somewhere here:
But neither the Guid nor the attribute name can be found in the entire message text.
Same is true for the meta data from the graph.
What am I doing wrong here?
EDIT: Here is what I got from graph:
Received: from AM0PR09MB4036.eurprd09.prod.outlook.com (2603:10a6:208:19f::13)
by DB8PR09MB4058.eurprd09.prod.outlook.com with HTTPS; Thu, 6 May 2021
07:53:21 +0000
Received: from AM9PR09MB4593.eurprd09.prod.outlook.com (2603:10a6:20b:287::6)
by AM0PR09MB4036.eurprd09.prod.outlook.com (2603:10a6:208:19f::13) with
Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.27; Thu, 6 May
2021 07:53:21 +0000
Received: from AM9PR09MB4593.eurprd09.prod.outlook.com
([fe80::c008:da09:d9b2:47cc]) by AM9PR09MB4593.eurprd09.prod.outlook.com
([fe80::c008:da09:d9b2:47cc%4]) with mapi id 15.20.4108.026; Thu, 6 May 2021
07:53:20 +0000
From: User <User#tenant.onmicrosoft.com>
To: User <User#tenant.onmicrosoft.com>
Subject: 123
Thread-Topic: 123
Thread-Index: AQHXQkdWc7SsFNH9wEqedVXYoSRrXQ==
Date: Thu, 6 May 2021 07:53:20 +0000
Message-ID:
<LONGID#AM9PR09MB4593.eurprd09.prod.outlook.com>
Accept-Language: en-DE, en-GB, en-US, de-DE
Content-Language: aa
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 04
X-MS-Exchange-Organization-AuthSource: AM9PR09MB4593.eurprd09.prod.outlook.com
X-MS-Has-Attach:
X-MS-Exchange-Organization-Network-Message-Id:
MESSAGE_ID
X-MS-Exchange-Organization-SCL: -1
X-MS-TNEF-Correlator:
X-MS-Exchange-Organization-RecordReviewCfmType: 0
x-ms-publictraffictype: Email
X-Microsoft-Antispam-Mailbox-Delivery:
ucf:0;jmr:0;auth:0;dest:I;ENG:(750129)(520011016)(706158)(944506458)(944626604);
X-Microsoft-Antispam-Message-Info:
didRz2nSjLEkd9U7ivulQq20MhG39bFkrSpiT//1gM51su3XDIz+haWsUqAYbfT7XVFmv7/sHNnDbS9pAvqN3lt8juTcmd4kiXLclZf6HsXGy9aBC5BbqSN5dgq5rTQ+1vjMZS6dlbbVvEb96d9B9BkOCTdYexnWDW6y4BQjwqAMthoSs3a9Dlr3TOy9ijC6DltkRQOt9lqQqtPViwoPqLnpF42EC5Lk98xKvWHHomRTcW3tcTL05mpAgvH5bLGZvjvBwllG9tpJvecs+PFXsZjfK3gTRMbEB4/yVw4QaqQcCL2zQsRYgJKNt7r3Vp3Jol6xhR/45FAntpFrJKio2Qwzmh4iQdAXvxZj/tR0e9c=
Content-Type: multipart/alternative;
boundary="_000_AM9PR09MB45936DB89D92E97CAF50EBF2FB589AM9PR09MB4593eurp_"
MIME-Version: 1.0
--_000_AM9PR09MB45936DB89D92E97CAF50EBF2FB589AM9PR09MB4593eurp_
Content-Type: text/plain; charset="us-ascii"
sd
--_000_AM9PR09MB45936DB89D92E97CAF50EBF2FB589AM9PR09MB4593eurp_
Content-Type: text/html; charset="us-ascii"
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
sd</div>
</body>
</html>
--_000_AM9PR09MB45936DB89D92E97CAF50EBF2FB589AM9PR09MB4593eurp_--
You will need to call item.getAllInternetHeadersAsync to get internet headers on the current message in Read mode. This API will get all of the internet headers on the item, and you can filter the asyncResult.value for the header you are interested in.
I've been hunting for this information for a week without any solid success.
I am targeting an Exchange 2010_SP2 server and have an application which sends out Appointments (Meetings) using EWS and inviting users/attendees. Currently when a user forwards their calendar item to another user, Exchange sends my application's email address an automatic notification about the forward. From the information contained within the notification message, I cannot find any information to help me specifically bind to the original appointment. I do have some clues with the user that forwarded it, the title of the event, and the date/time for it, but nothing that is guaranteed to be unique. I was thinking I could embed a unique identifier into the subject, but this seems a little gross. Has anyone else figured out a way to look up the event in context?
(Using C# and Microsoft's EWS Client API)
case EmailMessage fw when fw.ItemClass == "IPM.Schedule.Meeting.Notification.Forward":
EmailMessage message = EmailMessage.Bind(Global.Exchange, fw.Id);
message.Load();
I have attempted to try to query for the conversation, tried attaching customer X-Parameters to the original meeting, and have inspected all the properties I can think of within an EmailMessage object.
Example of a forward notification:
Internet Headers attached to the Email: (some parts redacted using ----)
Received: from FMSEDG002.ED.cps.----.com (10.1.192.134) by
fmsmsx121.amr.corp.----.com (10.18.125.36) with Microsoft SMTP Server (TLS)
id 14.3.439.0; Sat, 13 Jun 2020 14:24:33 -0700
Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.36.54) by
edgegateway.----.com (192.55.55.69) with Microsoft SMTP Server (TLS) id
14.3.439.0; Sat, 13 Jun 2020 14:24:33 -0700
Received: from BYAPR11MB3830.namprd11.prod.outlook.com (2603:10b6:a03:fc::14)
by BYAPR11MB3797.namprd11.prod.outlook.com (2603:10b6:a03:fe::27) with
Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.22; Sat, 13 Jun
2020 21:24:30 +0000
Received: from BYAPR11MB3830.namprd11.prod.outlook.com
([fe80::9d21:2f25:9b76:e341]) by BYAPR11MB3830.namprd11.prod.outlook.com
([fe80::9d21:2f25:9b76:e341%7]) with mapi id 15.20.3088.027; Sat, 13 Jun 2020
21:24:30 +0000
Content-Type: multipart/mixed;
boundary="_000_BYAPR11MB383088E85E5BF51D212384F4F99E0BYAPR11MB3830namp_"
From: ----
To: ----
Subject: Meeting Forward Notification: Dummy Event - Example 3
Thread-Topic: Meeting Forward Notification: Dummy Event - Example
3
Sender: Microsoft Outlook
<MicrosoftExchange32----#----.onmicrosoft.com>
Date: Sat, 13 Jun 2020 21:24:30 +0000
Message-ID: <BYAPR11MB383088E85E5BF51D212384F4F99E0#BYAPR11MB3830.namprd11.prod.outlook.com>
X-MS-Has-Attach:
X-MS-TNEF-Correlator: <BYAPR11MB383088E85E5BF51D212384F4F99E0#BYAPR11MB3830.namprd11.prod.outlook.com>
authentication-results: ----; dkim=none (message not signed)
header.d=none;----; dmarc=none action=none header.from=----;
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 53ede74f-9111-4b3f-01ff-08d80fe028c7
x-ms-traffictypediagnostic: BYAPR11MB3797:
x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr
x-ms-oob-tlc-oobclassifiers: OLM:2089;
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: bevNkvUhwfDB1JTruSgvhewEnlseaRPl5vEl4tx04MJVY/bY7tbeShWgjWHsg2ZEGmWH2ZZN2rjA4NjqI9seC5ei1B9A0m8tvCr7Ij+3IJAUr8vYz0F7LRwVKE2nZB1E7Wy7V3pHvYxyT6tyOvjbxDeHN7Fbs0dvKYwj4g/EWxAEiXNmGFxkPXGowV3I1v2vWT+hBIIO6Sz1Lg8/jzPm7l6d9DZZ7gxjQDQfuAcBgQEUj46RqNlMosWGEK65oBHWTYRC4R2oc3z2qS3Y8VgIzg==
x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:-1;SRV:;IPV:NLI;SFV:SKI;H:BYAPR11MB3830.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:INB;SFP:;
x-ms-exchange-transport-forked: True
MIME-Version: 1.0
X-MS-Exchange-CrossTenant-Network-Message-Id: 53ede74f-9111-4b3f-01ff-08d80fe028c7
X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Jun 2020 21:24:30.0788
(UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3797
X-OrganizationHeadersPreserved: BYAPR11MB3797.namprd11.prod.outlook.com
Return-Path: <>
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 04
X-MS-Exchange-Organization-AuthSource: BYAPR11MB3830.namprd11.prod.outlook.com
X-CrossPremisesHeadersPromoted: ----
X-CrossPremisesHeadersFiltered: ----
X-MS-Exchange-Organization-SCL: -1
X-OriginatorOrg: intel.onmicrosoft.com
X-MS-Exchange-Organization-AVStamp-Mailbox: NAI;60104903;0;novirus
The PidLidCleanGlobalObjectId http://msdn.microsoft.com/en-us/library/cc839502.aspx extended should be set on the notification. You can use that to search for the Appointment eg this is on example of using that property
Appointment newAppointment = new Appointment(service);
newAppointment.Subject = "Test Subject";
newAppointment.Start = new DateTime(2016, 08, 27, 17, 00, 0);
newAppointment.StartTimeZone = TimeZoneInfo.Local;
newAppointment.EndTimeZone = TimeZoneInfo.Local;
newAppointment.End = newAppointment.Start.AddMinutes(30);
newAppointment.Save();
newAppointment.Body = new MessageBody(Microsoft.Exchange.WebServices.Data.BodyType.Text, "test");
newAppointment.RequiredAttendees.Add("attendee#domain.com");
newAppointment.Update(ConflictResolutionMode.AlwaysOverwrite ,SendInvitationsOrCancellationsMode.SendOnlyToAll);
ExtendedPropertyDefinition CleanGlobalObjectId = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Meeting, 0x23, MapiPropertyType.Binary);
PropertySet psPropSet = new PropertySet(BasePropertySet.FirstClassProperties);
psPropSet.Add(CleanGlobalObjectId);
newAppointment.Load(psPropSet);
object CalIdVal = null;
newAppointment.TryGetProperty(CleanGlobalObjectId, out CalIdVal);
Folder AtndCalendar = Folder.Bind(service, new FolderId(WellKnownFolderName.Calendar,"attendee#domain.com"));
SearchFilter sfSearchFilter = new SearchFilter.IsEqualTo(CleanGlobalObjectId, Convert.ToBase64String((Byte[])CalIdVal));
ItemView ivItemView = new ItemView(1);
FindItemsResults<Item> fiResults = AtndCalendar.FindItems(sfSearchFilter, ivItemView);
if (fiResults.Items.Count > 0) {
//do whatever
}
I'm using a thirdparty SMTP service - turboSMTP
And I use it when sending emails from both localhost(when testing) and from the live website and both of them work. But the email sent from the live website always get flagged as spam, while the email from localhost is not flagged as spam.
Even if the sender email is the same. The content is the same. the title is the same and so on.
Does it actually see that I'm sending from a live website or from localhost when I'm sending through a third party SMTP service that isn't related to my webhost?
a cut from my code :
SmtpClient smtpClient = new SmtpClient();
System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
mailMessage.From = new MailAddress(sender);
mailMessage.To.Add(recipient);
mailMessage.Subject = title;
mailMessage.Body = message;
mailMessage.IsBodyHtml = false;
smtpClient.Host = "smtpAddress";
smtpClient.UseDefaultCredentials = false;
smtpClient.EnableSsl = false;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.Port = 587;
smtpClient.Credentials = new NetworkCredential("username", "password");
smtpClient.Send(mailMessage);
Email that got flagged as spam(Sent from live website)
Delivered-To: censoredAddress#gmail.com
Received: by 10.107.132.3 with SMTP id g3csp14274iod;
Thu, 4 Dec 2014 00:02:36 -0800 (PST)
X-Received: by 10.202.225.197 with SMTP id y188mr5614041oig.94.1417680156083;
Thu, 04 Dec 2014 00:02:36 -0800 (PST)
Return-Path: <noreply#censoredDomain.se>
Received: from tbjjbihbhcbji.turbo-smtp.net (tbjjbihbhcbji.turbo-smtp.net. [199.187.172.198])
by mx.google.com with SMTP id x10si17295964oek.84.2014.12.04.00.02.35
for <censoredAddress#gmail.com>;
Thu, 04 Dec 2014 00:02:36 -0800 (PST)
Received-SPF: fail (google.com: domain of noreply#censoredDomain.se does not designate 199.187.172.198 as permitted sender) client-ip=199.187.172.198;
Authentication-Results: mx.google.com;
spf=fail (google.com: domain of noreply#censoredDomain.se does not designate 199.187.172.198 as permitted sender) smtp.mail=noreply#censoredDomain.se;
dkim=temperror (no key for signature) header.i=#
Message-Id: <5480151c.8a283c0a.71e4.678eSMTPIN_ADDED_MISSING#mx.google.com>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=censoredDomain.se; s=turbo-smtp; x=1418284956; h=DomainKey-Signature:
Received:Received:MIME-Version:From:To:Date:Subject:Content-Type:
Content-Transfer-Encoding; bh=7vEAgi0RRzjrn+4Le/fcS1k1+tJ/Ro6XDU
4TKOlZ0JY=; b=Yu5q4UjDuGv2L/Fa3MR+FO4+h3jWj5KHKvDGZFCyJYj0+aB7aV
kgOix5W5zrlaJ0rbl39Ck08AORmO82jdcXzFdtFm5lst6ENG3JaWorxWyxduqWBI
TY7ZSzs9HJb4TBXcMQvvaPdM96VA7FP3i4vb4Q9mkoGX1nD6c9asLirsE=
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;
s=turbo-smtp; d=censoredDomain.se;
h=Received:Received:X-TurboSMTP-Tracking:MIME-Version:From:To:Date:Subject:Content-Type:Content-Transfer-Encoding;
b=ttGj0ZR2T0aPVS+Q+0oEdy5VM4wWzIBm2DtLYvtUFyHhldqWO5n2kVnZN3m1pR
w0gGFX/r67i9FblNhg04ELxvsfO2+mHg0bhyTJgYOAPjS0DjoMBZI1WD2w/CTObN
VMxSkTu8Hq8CDe49SRsduLnVLUdg2zwt86eNxItLLTno0=;
Received: (qmail 1442 invoked from network); 4 Dec 2014 08:02:34 -0000
Received: from unknown (HELO Irwindale) (authenticated#212.247.113.26) by turbo-smtp.com with SMTP; 4 Dec 2014 08:02:34 -0000
X-TurboSMTP-Tracking: 1692405204
MIME-Version: 1.0
From: noreply#censoredDomain.se
To: censoredAddress#gmail.com
Date: 4 Dec 2014 09:02:34 +0100
Subject: Testar igen
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
asdasdasd
Email that did not get flagged as spam(Sent from localhost)
Delivered-To: censoredAddress#gmail.com
Received: by 10.107.132.3 with SMTP id g3csp14413iod;
Thu, 4 Dec 2014 00:03:46 -0800 (PST)
X-Received: by 10.60.150.194 with SMTP id uk2mr5861322oeb.37.1417680226570;
Thu, 04 Dec 2014 00:03:46 -0800 (PST)
Return-Path: <noreply#censoredDomain.se>
Received: from tbjjbihbhcbji.turbo-smtp.net (tbjjbihbhcbji.turbo-smtp.net. [199.187.172.198])
by mx.google.com with SMTP id a140si17357087oib.49.2014.12.04.00.03.45
for <censoredAddress#gmail.com>;
Thu, 04 Dec 2014 00:03:45 -0800 (PST)
Received-SPF: fail (google.com: domain of noreply#censoredDomain.se does not designate 199.187.172.198 as permitted sender) client-ip=199.187.172.198;
Authentication-Results: mx.google.com;
spf=fail (google.com: domain of noreply#censoredDomain.se does not designate 199.187.172.198 as permitted sender) smtp.mail=noreply#censoredDomain.se;
dkim=temperror (no key for signature) header.i=#
Message-Id: <54801561.924dca0a.a7bc.ffffe533SMTPIN_ADDED_MISSING#mx.google.com>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=censoredDomain.se; s=turbo-smtp; x=1418285025; h=DomainKey-Signature:
Received:Received:MIME-Version:From:To:Date:Subject:Content-Type:
Content-Transfer-Encoding; bh=7vEAgi0RRzjrn+4Le/fcS1k1+tJ/Ro6XDU
4TKOlZ0JY=; b=rW/7YJz7bCAsSz8EF2NTfU+JbIsh5A4QLAQ5EgrxJUG3j1vJmt
8aVAMEI+45iC79T/vFpfLrN1e+fuSXCXuiw9MhTgBvHG0w0JIiKpufyHUnIRmNUs
YjNRErfIhaHwtEgAFXL/0ou0sG7QrG2cKu8VP/P2WA7opvoC6tfgIQH6k=
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;
s=turbo-smtp; d=censoredDomain.se;
h=Received:Received:X-TurboSMTP-Tracking:MIME-Version:From:To:Date:Subject:Content-Type:Content-Transfer-Encoding;
b=o5Vxv9MAQeyFm1EqkQ3f56XVgxzSOR2HNB7oqg6GqxP4qPy8QY9hBu2w5DPdf3
8d/HQqJX61zN4Rfnyxgrw2PMPXr5dsrpKnKyB3o1/FsGCLH3meLyO+LYxeQBLRFO
kKtUtQ4vvSy2TN+7Sefe18lQo+E6bUunTcg64kw2I//4E=;
Received: (qmail 11732 invoked from network); 4 Dec 2014 08:03:45 -0000
Received: from unknown (HELO Codecomp-HP) (authenticated#78.70.27.139) by turbo-smtp.com with SMTP; 4 Dec 2014 08:03:45 -0000
X-TurboSMTP-Tracking: 1692407529
MIME-Version: 1.0
From: noreply#censoredDomain.se
To: censoredAddress#gmail.com
Date: 4 Dec 2014 09:03:39 +0100
Subject: Testar igen
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
asdasdasd
You have an SPF fail in you mails:
spf=fail (google.com: domain of noreply#censoredDomain.se does not designate 199.187.172.198 as permitted sender)
Try adding the IP address (range) of the SMTP provider to your SPF record (or remove it completely).
You get that fail on both mails, so I do not know why one gets through, but the one failing is probalby caused by the SPF check.
Also the DKIM signature seems to be not correct:
dkim=temperror (no key for signature) header.i=#
You should check that with the SMTP provider.
I have an email application that creates encrypted emails. It works fine in outlook and all the email counterparties I send the email to reports no issues.
However when I try to decrypt them with Mimekit I get a "Bad data" exception.
Some of the stack trace:
at System.Security.Cryptography.Pkcs.EnvelopedCms.DecryptContent(RecipientInfoCollection recipientInfos, X509Certificate2Collection extraStore)
at System.Security.Cryptography.Pkcs.EnvelopedCms.Decrypt()
at MimeKit.Cryptography.WindowsSecure...
My email mime looks like this:
Received: from Dx ([x]) by
x ([x]) with mapi id
x; Fri, 7 Mar 2014 14:48:49 +0100
From: x <x#x.com>
To: x <x2#x.com>
Subject:
xxxxxxxx
07-03-2014 14:48:46
Thread-Topic:
xxxxxxx
07-03-2014 14:48:46
Thread-Index: AQHPOgv3JHiUE6wuJk+EQu4eAA1oDA==
Date: Fri, 7 Mar 2014 14:48:48 +0100
Message-ID: <x>
Accept-Language: da-DK, en-US
Content-Language: en-US
X-MS-Exchange-Organization-AuthAs: x
X-MS-Exchange-Organization-AuthMechanism: x
X-MS-Exchange-Organization-AuthSource: x
X-MS-Has-Attach: yes
X-MS-Exchange-Organization-SCL: -1
X-MS-TNEF-Correlator:
Content-Type: application/pkcs7-mime; name="smime.p7m";
smime-type=enveloped-data
Content-Disposition: attachment; filename="smime.p7m"
Content-Transfer-Encoding: base64
MIME-Version: 1.0
MIIeOgYJKoZIhvcNAQcDoIIeKzCCHicCAQAxggLnMIIC4wIBADCByjCBxDEfMB0GA1UEChMWRGFu
c2tlIENvbW1vZGl0aWVzIEEvUzEaMBgGA1UECxMRQnVzaW5lc3MgU29mdHdhcmUxNTAzBgkqhkiG
9w0BCQEWJmJ1c2luZXNzY2xlYXJpbmdAZGFuc2tlY29tbW9kaXRpZXMuY29tMQ8wDQYDVQQHEwZB
YXJodXMxEDAOBgNVBAgTB0Rlbm1hcmsxCzAJBgNVBAYTAkRLMR4wHAYDVQQDExVkYW5za2Vjb21t
b2RpdGllcy5jb20CAQEwDQYJKoZIhvcNAQEBBQAEggIAVUeGP1IwgqbTvu6w6bIUkhmCjCRhOTqp
tuzSd/ZMfyI95Y/8cxsYf3ivd6AeLld+cn9cyVtnTp6upZNAmetA8QWD2GbCprMDNZpCApuc8Hwc
+nwaa1UN2KJXRf/ecSl+94G/fIxbZ5/53O8KL5RHGkT0AO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QpBGQnhsB6DslLImiYXSzy6OcHIsUf4kyAGes5tsBxR
i1IfNHcW4G/7i4VUy+530PqA0+TECNkpgiGxrevWk0gF0NgD+DDNgDzZRjJaRpMx0ufbP9twVvv+
6J/meqKiykYcU/NUYV/TuNiERKrOOWZs697IyY/g3nPWHZurZXJbmk9MpND2wn5PZzRTx7qyBVfn
nenl/WtSVMmKA4D1dLnHoeN1hoAyQgrfqS4yymL26UemhCXIV87hAYwwoAbpfr4=
This is how I perform my encryption:
public static string EncryptContent(string content, X509Certificate2 certificate)
{
byte[] contentBytes = Encoding.ASCII.GetBytes(content);
var envelopedCms = new EnvelopedCms(SubjectIdentifierType.IssuerAndSerialNumber, new ContentInfo(contentBytes));
var recipient = new CmsRecipient(SubjectIdentifierType.IssuerAndSerialNumber, certificate);
envelopedCms.Encrypt(recipient);
var encodedData = envelopedCms.Encode();
var encodedDataBase64 = Convert.ToBase64String(encodedData, Base64FormattingOptions.InsertLineBreaks);
return encodedDataBase64;
}
and this is how I attempt to decrypt:
var primarySecureMimeContext = CreateSecureMimeContext(certificateInfo.PrimaryCertificate,
certificateInfo.PrimaryPassword);
var primaryDecryptedEntity = entity.Decrypt(primarySecureMimeContext);
private SecureMimeContext CreateSecureMimeContext(string certificateFilename, string certificatePassword)
{
var secureMimeContext = new WindowsSecureMimeContext();
var certificate = new X509Certificate2(certificateFilename,
certificatePassword);
var bouncyX509Certificate = Org.BouncyCastle.Security.DotNetUtilities.FromX509Certificate(certificate);
secureMimeContext.Import(bouncyX509Certificate);
return secureMimeContext;
}
When I decrypt the content myself using enveloped cms directly, there are no issues.
This is the email after my own decryption:
Content-Type: multipart/mixed;
boundary="5511bd79-26dc-41e5-ac96-7adfdea5f6e5"
--5511bd79-26dc-41e5-ac96-7adfdea5f6e5
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
--5511bd79-26dc-41e5-ac96-7adfdea5f6e5
Content-Type: application/octet-stream;
name="TestFile.txt"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="TestFile.txt"
77u/VGVlZWVlZXN0
--5511bd79-26dc-41e5-ac96-7adfdea5f6e5--
Can anyone see what is causing this?
After having using the DummySecureMimeContext as proposed by jstedfast it works. A more thorough walkthrough can be found here: https://github.com/jstedfast/MimeKit/issues/38
I think the problem is the way you are adding the certificate to the context:
private SecureMimeContext CreateSecureMimeContext(string certificateFilename, string certificatePassword)
{
var secureMimeContext = new WindowsSecureMimeContext();
var certificate = new X509Certificate2(certificateFilename,
certificatePassword);
var bouncyX509Certificate = Org.BouncyCastle.Security.DotNetUtilities.FromX509Certificate(certificate);
secureMimeContext.Import(bouncyX509Certificate);
return secureMimeContext;
}
What this is doing is adding the certificate to the AddressBook certificate store, but where you actually want to add it in order to decrypt it (because you'll need the private key password as well) is the personal cert store.
Try this:
private SecureMimeContext CreateSecureMimeContext (string certificateFilename, string certificatePassword)
{
var secureMimeContext = new WindowsSecureMimeContext ();
using (var stream = File.OpenRead (certificateFilename))
secureMimeContext.Import (stream, certificatePassword);
return secureMimeContext;
}
The exception message you are getting isn't very helpful, but I am guessing that it means that it can't find the certificate and/or private key. I wrote a test program and have been unsuccessful in reproducing this bug, so I could be wrong... but since my certificates/private keys are already imported into my personal cert store, I'm not sure how to remove them to test this theory.
Let me know how that works out for you.
Update: Oops, I done goofed. Just updated CreateSecureMimeContext() above to open the certificate file stream because WindowsSecureMimeContext.Import() takes a stream, not a file name.