using System.Configuration;
using System.Net.Security;
using System.Security.Authentication;
-#if NET_4_5
using System.Threading.Tasks;
-#endif
namespace System.Net.Mail {
public class SmtpClient
-#if NET_4_0
: IDisposable
-#endif
{
#region Fields
if (cfg != null) {
this.host = cfg.Network.Host;
this.port = cfg.Network.Port;
-#if NET_4_0
this.enableSsl = cfg.Network.EnableSsl;
-#endif
TargetName = cfg.Network.TargetName;
if (this.TargetName == null)
TargetName = "SMTPSVC/" + (host != null ? host : "");
}
#endif
-#if NET_4_0
public
-#endif
string TargetName { get; set; }
public ICredentialsByHost Credentials {
#endregion // Events
#region Methods
-#if NET_4_0
public void Dispose ()
{
Dispose (true);
{
// TODO: We should close all the connections and abort any async operations here
}
-#endif
private void CheckState ()
{
if (messageInProcess != null)
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);
Send (new MailMessage (from, to, subject, body));
}
-#if NET_4_5
public Task SendMailAsync (MailMessage message)
{
var tcs = new TaskCompletionSource<object> ();
source.SetResult (null);
}
-#endif
private void SendDot()
{
CheckCancellation ();
if (escapeDots) {
- int i;
- for (i = 0; i < line.Length; i++) {
- if (line[i] != '.')
- break;
- }
- if (i > 0 && i == line.Length) {
- line += ".";
+ if (line.Length > 0 && line[0] == '.') {
+ line = "." + line;
}
}
writer.Write (line);