public IMailConfiguration SmtpDeliveryFormat(SmtpDeliveryFormat deliveryFormat) { _mail.Settings.DeliveryFormat = deliveryFormat; return(this); }
void Initialize() { if (port == defaultPort || port == 0) { new SmtpPermission(SmtpAccess.Connect).Demand(); } else { new SmtpPermission(SmtpAccess.ConnectToUnrestrictedPort).Demand(); } transport = new SmtpTransport(this); if (Logging.On) Logging.Associate(Logging.Web, this, transport); onSendCompletedDelegate = new SendOrPostCallback(SendCompletedWaitCallback); if (MailConfiguration.Smtp != null) { if (MailConfiguration.Smtp.Network != null) { if (host == null || host.Length == 0) { host = MailConfiguration.Smtp.Network.Host; } if (port == 0) { port = MailConfiguration.Smtp.Network.Port; } transport.Credentials = MailConfiguration.Smtp.Network.Credential; transport.EnableSsl = MailConfiguration.Smtp.Network.EnableSsl; if (MailConfiguration.Smtp.Network.TargetName != null) targetName = MailConfiguration.Smtp.Network.TargetName; // If the config file contains a domain to be used for the // domain element in the client's EHLO or HELO message, // use it. // // We do not validate whether the domain specified is valid. // It is up to the administrators or user to use the right // value for their scenario. // // Note: per section 4.1.4 of RFC2821, the domain element of // the HELO/EHLO should be used for logging purposes. An // SMTP server should not decide to route an email based on // this value. clientDomain = MailConfiguration.Smtp.Network.ClientDomain; } deliveryFormat = MailConfiguration.Smtp.DeliveryFormat; deliveryMethod = MailConfiguration.Smtp.DeliveryMethod; if (MailConfiguration.Smtp.SpecifiedPickupDirectory != null) pickupDirectoryLocation = MailConfiguration.Smtp.SpecifiedPickupDirectory.PickupDirectoryLocation; } if (host != null && host.Length != 0) { host = host.Trim(); } if (port == 0) { port = defaultPort; } if (this.targetName == null) targetName = "SMTPSVC/" + host; if (clientDomain == null) { // We use the local host name as the default client domain // for the client's EHLO or HELO message. This limits the // information about the host that we share. Additionally, the // FQDN is not available to us or useful to the server (internal // machine connecting to public server). // SMTP RFC's require ASCII only host names in the HELO/EHLO message. string clientDomainRaw = IPGlobalProperties.InternalGetIPGlobalProperties().HostName; IdnMapping mapping = new IdnMapping(); try { clientDomainRaw = mapping.GetAscii(clientDomainRaw); } catch (ArgumentException) { } // For some inputs GetAscii may fail (bad Unicode, etc). If that happens // we must strip out any non-ASCII characters. // If we end up with no characters left, we use the string "LocalHost". This // matches Outlook behavior. StringBuilder sb = new StringBuilder(); char ch; for (int i = 0; i < clientDomainRaw.Length; i++) { ch = clientDomainRaw[i]; if ((ushort)ch <= 0x7F) sb.Append(ch); } if (sb.Length > 0) clientDomain = sb.ToString(); else clientDomain = "LocalHost"; } }
public static SmtpClient SetDeliveryFormat(this SmtpClient client, SmtpDeliveryFormat value) { client.DeliveryFormat = value; return(client); }
void Initialize() { if (port == defaultPort || port == 0) { new SmtpPermission(SmtpAccess.Connect).Demand(); } else { new SmtpPermission(SmtpAccess.ConnectToUnrestrictedPort).Demand(); } transport = new SmtpTransport(this); if (Logging.On) { Logging.Associate(Logging.Web, this, transport); } onSendCompletedDelegate = new SendOrPostCallback(SendCompletedWaitCallback); if (MailConfiguration.Smtp != null) { if (MailConfiguration.Smtp.Network != null) { if (host == null || host.Length == 0) { host = MailConfiguration.Smtp.Network.Host; } if (port == 0) { port = MailConfiguration.Smtp.Network.Port; } transport.Credentials = MailConfiguration.Smtp.Network.Credential; transport.EnableSsl = MailConfiguration.Smtp.Network.EnableSsl; if (MailConfiguration.Smtp.Network.TargetName != null) { targetName = MailConfiguration.Smtp.Network.TargetName; } // If the config file contains a domain to be used for the // domain element in the client's EHLO or HELO message, // use it. // // We do not validate whether the domain specified is valid. // It is up to the administrators or user to use the right // value for their scenario. // // Note: per section 4.1.4 of RFC2821, the domain element of // the HELO/EHLO should be used for logging purposes. An // SMTP server should not decide to route an email based on // this value. clientDomain = MailConfiguration.Smtp.Network.ClientDomain; } deliveryFormat = MailConfiguration.Smtp.DeliveryFormat; deliveryMethod = MailConfiguration.Smtp.DeliveryMethod; if (MailConfiguration.Smtp.SpecifiedPickupDirectory != null) { pickupDirectoryLocation = MailConfiguration.Smtp.SpecifiedPickupDirectory.PickupDirectoryLocation; } } if (host != null && host.Length != 0) { host = host.Trim(); } if (port == 0) { port = defaultPort; } if (this.targetName == null) { targetName = "SMTPSVC/" + host; } if (clientDomain == null) { // We use the local host name as the default client domain // for the client's EHLO or HELO message. This limits the // information about the host that we share. Additionally, the // FQDN is not available to us or useful to the server (internal // machine connecting to public server). // SMTP RFC's require ASCII only host names in the HELO/EHLO message. string clientDomainRaw = IPGlobalProperties.InternalGetIPGlobalProperties().HostName; IdnMapping mapping = new IdnMapping(); try { clientDomainRaw = mapping.GetAscii(clientDomainRaw); } catch (ArgumentException) { } // For some inputs GetAscii may fail (bad Unicode, etc). If that happens // we must strip out any non-ASCII characters. // If we end up with no characters left, we use the string "LocalHost". This // matches Outlook behavior. StringBuilder sb = new StringBuilder(); char ch; for (int i = 0; i < clientDomainRaw.Length; i++) { ch = clientDomainRaw[i]; if ((ushort)ch <= 0x7F) { sb.Append(ch); } } if (sb.Length > 0) { clientDomain = sb.ToString(); } else { clientDomain = "LocalHost"; } } }
private void Initialize() { if (this.port == SmtpClient.defaultPort || this.port == 0) new SmtpPermission(SmtpAccess.Connect).Demand(); else new SmtpPermission(SmtpAccess.ConnectToUnrestrictedPort).Demand(); this.transport = new SmtpTransport(this); if (Logging.On) Logging.Associate(Logging.Web, (object) this, (object) this.transport); this.onSendCompletedDelegate = new SendOrPostCallback(this.SendCompletedWaitCallback); if (SmtpClient.MailConfiguration.Smtp != null) { if (SmtpClient.MailConfiguration.Smtp.Network != null) { if (this.host == null || this.host.Length == 0) this.host = SmtpClient.MailConfiguration.Smtp.Network.Host; if (this.port == 0) this.port = SmtpClient.MailConfiguration.Smtp.Network.Port; this.transport.Credentials = (ICredentialsByHost) SmtpClient.MailConfiguration.Smtp.Network.Credential; this.transport.EnableSsl = SmtpClient.MailConfiguration.Smtp.Network.EnableSsl; if (SmtpClient.MailConfiguration.Smtp.Network.TargetName != null) this.targetName = SmtpClient.MailConfiguration.Smtp.Network.TargetName; this.clientDomain = SmtpClient.MailConfiguration.Smtp.Network.ClientDomain; } this.deliveryFormat = SmtpClient.MailConfiguration.Smtp.DeliveryFormat; this.deliveryMethod = SmtpClient.MailConfiguration.Smtp.DeliveryMethod; if (SmtpClient.MailConfiguration.Smtp.SpecifiedPickupDirectory != null) this.pickupDirectoryLocation = SmtpClient.MailConfiguration.Smtp.SpecifiedPickupDirectory.PickupDirectoryLocation; } if (this.host != null && this.host.Length != 0) this.host = this.host.Trim(); if (this.port == 0) this.port = SmtpClient.defaultPort; if (this.targetName == null) this.targetName = "SMTPSVC/" + this.host; if (this.clientDomain != null) return; string unicode = IPGlobalProperties.InternalGetIPGlobalProperties().HostName; IdnMapping idnMapping = new IdnMapping(); try { unicode = idnMapping.GetAscii(unicode); } catch (ArgumentException ex) { } StringBuilder stringBuilder = new StringBuilder(); for (int index = 0; index < unicode.Length; ++index) { char ch = unicode[index]; if ((int) ch <= (int) sbyte.MaxValue) stringBuilder.Append(ch); } if (stringBuilder.Length > 0) this.clientDomain = ((object) stringBuilder).ToString(); else this.clientDomain = "LocalHost"; }
public StmpClientHelper DeliveryFormat(SmtpDeliveryFormat smtpDeliveryMethod) { _deliveryFormat = smtpDeliveryMethod; return(this); }