if (cfg != null) {
this.host = cfg.Network.Host;
this.port = cfg.Network.Port;
+ TargetName = cfg.Network.TargetName;
+ if (this.TargetName == null)
+ TargetName = "SMTPSVC/" + (host != null ? host : "");
+
+
if (cfg.Network.UserName != null) {
string password = String.Empty;
if (cfg.From != null)
defaultFrom = new MailAddress (cfg.From);
}
+#else
+ // Just to eliminate the warning, this codepath does not end up in production.
+ defaultFrom = null;
#endif
if (!String.IsNullOrEmpty (host))
}
#endif
+#if NET_4_0
+ public
+#endif
+ string TargetName { get; set; }
+
public ICredentialsByHost Credentials {
get { return credentials; }
set {
SendHeader ("Priority", v);
if (message.Sender != null)
SendHeader ("Sender", EncodeAddress (message.Sender));
- if (message.ReplyTo != null)
- SendHeader ("ReplyTo", EncodeAddress (message.ReplyTo));
-
+ if (message.ReplyToList.Count > 0)
+ SendHeader ("Reply-To", EncodeAddresses (message.ReplyToList));
+
+#if NET_4_0
+ foreach (string s in message.Headers.AllKeys)
+ SendHeader (s, ContentType.EncodeSubjectRFC2047 (message.Headers [s], message.HeadersEncoding));
+#else
foreach (string s in message.Headers.AllKeys)
SendHeader (s, message.Headers [s]);
-
+#endif
+
AddPriorityHeader (message);
boundaryIndex = 0;
Send (message);
} catch (Exception ex) {
ea.Result = ex;
+ throw ex;
}
};
worker.WorkerSupportsCancellation = true;
alt_boundary = GenerateBoundary ();
contentType = new ContentType ("multipart/related");
contentType.Boundary = alt_boundary;
- contentType.Parameters ["type"] = "application/octet-stream";
+
+ contentType.Parameters ["type"] = av.ContentType.ToString ();
StartSection (inner_boundary, contentType);
+ StartSection (alt_boundary, av.ContentType, av.TransferEncoding);
} else {
contentType = new ContentType (av.ContentType.ToString ());
StartSection (inner_boundary, contentType, av.TransferEncoding);
private void SendLinkedResources (MailMessage message, LinkedResourceCollection resources, string boundary)
{
foreach (LinkedResource lr in resources) {
- ContentType contentType = new ContentType (lr.ContentType.ToString ());
- StartSection (boundary, contentType, lr.TransferEncoding);
+ StartSection (boundary, lr.ContentType, lr.TransferEncoding, lr);
switch (lr.TransferEncoding) {
case TransferEncoding.Base64:
SendData (string.Empty);
}
+ private void StartSection(string section, ContentType sectionContentType, TransferEncoding transferEncoding, LinkedResource lr)
+ {
+ SendData (String.Format("--{0}", section));
+ SendHeader ("content-type", sectionContentType.ToString ());
+ SendHeader ("content-transfer-encoding", GetTransferEncodingName (transferEncoding));
+
+ if (lr.ContentId != null && lr.ContentId.Length > 0)
+ SendHeader("content-ID", "<" + lr.ContentId + ">");
+
+ SendData (string.Empty);
+ }
+
private void StartSection (string section, ContentType sectionContentType, TransferEncoding transferEncoding, ContentDisposition contentDisposition) {
SendData (String.Format ("--{0}", section));
SendHeader ("content-type", sectionContentType.ToString ());
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors) {
+ // honor any exciting callback defined on ServicePointManager
+ if (ServicePointManager.ServerCertificateValidationCallback != null)
+ return ServicePointManager.ServerCertificateValidationCallback (sender, certificate, chain, sslPolicyErrors);
+ // otherwise provide our own
if (sslPolicyErrors != SslPolicyErrors.None)
throw new InvalidOperationException ("SSL authentication error: " + sslPolicyErrors);
return true;