/// <summary> /// Sends the message using the specified host on the specified port. Secure SASL Authentication is performed according to the requested mechanism. /// </summary> /// <param name="message">The message to be sent.</param> /// <param name="host">The host to be used.</param> /// <param name="username">The username to be used for authentication.</param> /// <param name="password">The password to be used for authentication.</param> /// <param name="mechanism">SASL Mechanism to be used for authentication.</param> /// <param name="port">The port to be used.</param> /// <example> /// <code> /// C# /// /// Message message = new Message(); /// message.Subject = "Test"; /// message.From = new Address("*****@*****.**","John Doe"); /// message.To.Add("*****@*****.**","Mike Johns"); /// message.BodyText.Text = "Hello this is a test!"; /// /// SmtpClient.Send(message,"mail.myhost.com","jdoe1234","tanstaaf",SaslMechanism.CramMd5,8504); /// /// VB.NET /// /// Dim message As New Message /// message.Subject = "Test" /// message.From = New Address("*****@*****.**","John Doe") /// message.To.Add("*****@*****.**","Mike Johns") /// message.BodyText.Text = "Hello this is a test!" /// /// SmtpClient.Send(message,"mail.myhost.com","jdoe1234","tanstaaf",SaslMechanism.CramMd5,8504) /// /// JScript.NET /// /// var message:Message = new Message(); /// message.Subject = "Test"; /// message.From = new Address("*****@*****.**","John Doe"); /// message.To.Add("*****@*****.**","Mike Johns"); /// message.BodyText.Text = "Hello this is a test!"; /// /// SmtpClient.Send(message,"mail.myhost.com","jdoe1234","tanstaaf",SaslMechanism.CramMd5,8504); /// </code> /// </example> public static bool Send(Message message, string host, int port, string username, string password, SaslMechanism mechanism) { // Ensure that the mime part tree is built message.CheckBuiltMimePartTree(); var smtp = new SmtpClient(); smtp.Connect(host,port); smtp.SendEhloHelo(); smtp.Authenticate(username, password, mechanism); if(message.From.Email!=string.Empty) smtp.MailFrom(message.From); else smtp.MailFrom(message.Sender); smtp.RcptTo(message.To); smtp.RcptTo(message.Cc); smtp.RcptTo(message.Bcc); smtp.Data(message.ToMimeString()); smtp.Disconnect(); return true; }
public static bool SendSsl(Message message, string host, int port, string username, string password, SaslMechanism mechanism) { // Ensure that the mime part tree is built message.CheckBuiltMimePartTree(); ActiveUp.Net.Mail.SmtpClient smtp = new ActiveUp.Net.Mail.SmtpClient(); smtp.ConnectSsl(host, port); smtp.SendEhloHelo(); SendMessageWithAuthentication(smtp, username, password, mechanism, message); return true; }
public static bool SendSsl(Message message, string host, int port, string username, string password, SaslMechanism mechanism, EncryptionType enc_type) { // Ensure that the mime part tree is built message.CheckBuiltMimePartTree(); ActiveUp.Net.Mail.SmtpClient smtp = new ActiveUp.Net.Mail.SmtpClient(); switch (enc_type) { case EncryptionType.SSL: smtp.ConnectSsl(host, port); break; case EncryptionType.StartTLS: smtp.Connect(host, port); break; default: throw new ArgumentException("Incompatible EncriptionType with SendSSL: " + enc_type); } smtp.SendEhloHelo(); if (enc_type == EncryptionType.StartTLS) { smtp.StartTLS(host); } SendMessageWithAuthentication(smtp, username, password, mechanism, message); return true; }
public static bool SendSsl(Message message, string server, int port) { // Ensure that the mime part tree is built message.CheckBuiltMimePartTree(); ActiveUp.Net.Mail.SmtpClient smtp = new ActiveUp.Net.Mail.SmtpClient(); smtp.ConnectSsl(server, port); smtp.SendEhloHelo(); SendMessageWith(smtp, message); return true; }