Esempio n. 1
0
                    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;
                    }