Beispiel #1
0
        public IActionResult Test()
        {
            var mail = new TestMail();

            throw new System.Exception("Error");
            

            mail.Test = "test test";

            return new EmailResult(mail);
        }
Beispiel #2
0
        public IActionResult Test()
        {
            var mail = new TestMail();

            throw new System.Exception("Error");


            mail.Test = "test test";

            return(new EmailResult(mail));
        }
Beispiel #3
0
        public void TestAddCandidateAndMailTogether()
        {
            TestCandidate candidate = new TestCandidate();

            candidate.Name = "Mohan";
            TestMail mail = new TestMail();

            mail.Subject = "Static Test";

            Relation.Add(candidate, mail);

            candidate = SaveAndReFetch(candidate);

            Assert.AreEqual(Relation.Count <TestMail>(candidate), 1);
        }
Beispiel #4
0
        public void Do_not_create_duplicate_pending_logs()
        {
            var supplier = TestSupplier.CreateNaked(session);
            var mail     = new TestMail(supplier);

            session.Save(mail);
            client.CreateUser(session);
            foreach (var user in client.Users)
            {
                session.Save(new TestMailSendLog(user, mail));
            }
            session.CreateSQLQuery("delete from Logs.PendingMailLogs").ExecuteUpdate();
            exporter.ExportDb();
            Assert.AreEqual(1, session.Query <PendingMailLog>().Count());
        }
        public override void Execute(ISession session)
        {
            var user     = User(session);
            var supplier = user.GetActivePrices(session)[0].Supplier;

            Mail = new TestMail(supplier);
            Mail.Attachments.Add(new TestAttachment(Mail, "отказ.txt"));
            if (IsSpecial)
            {
                Mail.IsVIPMail     = true;
                Mail.SupplierEmail = "*****@*****.**";
            }
            session.Save(Mail);
            Log = new TestMailSendLog(user, Mail);
            session.Save(Log);
            File.WriteAllText(Path.Combine(Config.AttachmentsPath, Mail.Attachments[0].GetSaveFileName()), "тест");
        }
Beispiel #6
0
        public void Test_GetAny_Object()
        {
            TestCandidate candidate1 = new TestCandidate();

            candidate1.Name = "Mohan";
            TestMail mail1 = new TestMail();

            mail1.Subject = "Static Test";

            Relation.Add(candidate1, mail1);

            candidate1 = SaveAndReFetch(candidate1);

            AnyTypeRepository repo = new AnyTypeRepository();

            TestCandidate candidate2 = (TestCandidate)repo.GetAnyObject(typeof(TestCandidate), candidate1.ObjectId);
            TestMail      mail2      = (TestMail)repo.GetAnyObject(typeof(TestMail), mail1.PrimaryKey);

            Assert.AreEqual(candidate1, candidate2);
            Assert.AreEqual(mail1.Subject, mail2.Subject);
        }
 public void Start()
 {
     try {
         // ask the user for SMTP server, port and the type of connection
         Console.Write("Host to connect to: ");
         string server = Console.ReadLine().Trim();
         Console.Write("Port: ");
         string port = Console.ReadLine().Trim();
         Console.Write("Connection type [0 = normal connection, 1 = direct TLS connection, 2 = indirect TLS connection (using STARTTLS command)]: ");
         string type = Console.ReadLine().Trim();
         if (Array.IndexOf(new string[] { "0", "1", "2" }, type) == -1)
         {
             Console.WriteLine("Invalid connection type.");
             return;
         }
         Console.WriteLine("Please enter the email address you wish to send an email to:");
         string address = Console.ReadLine().Trim();
         // create a new SecurityOptions instance
         SecurityOptions options = new SecurityOptions(SecureProtocol.None);
         // allow only secure ciphers to be used. Currently, the seure ciphers are:
         // the AES algorithm [128 or 256 bit keys], the RC4 algorithm [128 bit keys]
         // or TipleDES [168 bit keys]
         options.AllowedAlgorithms = SslAlgorithms.SECURE_CIPHERS;
         // the SecureSocket should be a client socket
         options.Entity = ConnectionEnd.Client;
         // we will use manual verification of the server certificate
         options.VerificationType = CredentialVerification.Manual;
         // when the server certificate is receives, the SecureSocket should call
         // the OnVerify method
         options.Verifier = new CertVerifyEventHandler(OnVerify);
         // use the default flags
         options.Flags = SecurityFlags.Default;
         // the common name is the domain name or IP address of the server
         options.CommonName = server;
         // if the user chose a direct TLS connection, set the protocol to TLS1
         if (type == "1")
         {
             options.Protocol = SecureProtocol.Tls1;
         }
         // create the new secure socket
         Connection = new SecureSocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp, options);
         // connect to the SMTP server
         Connection.Connect(new IPEndPoint(Dns.Resolve(server).AddressList[0], int.Parse(port)));
         // wait for the server hello message
         if (!IsReplyOK(Receive()))
         {
             Console.WriteLine("Server disallowed connection.");
             return;
         }
         // if the user selected an indirect TLS connection, issue
         // a EHLO command. Otherwise, stick to the standard HELO command.
         if (type == "2")             // STARTTLS connection
         {
             Send("EHLO SmtpClient.Mentalis.org\r\n");
         }
         else
         {
             Send("HELO SmtpClient.Mentalis.org\r\n");
         }
         if (!IsReplyOK(Receive()))
         {
             Console.WriteLine("HELLO failed.");
             return;
         }
         // if the user selected an indirect TLS connection, issue
         // the STARTTLS command
         if (type == "2")
         {
             // send the STARTTLS command to the server
             Send("STARTTLS\r\n");
             // make sure the server supports the STARTTLS command
             if (!IsReplyOK(Receive()))
             {
                 Console.WriteLine("STARTTLS failed.");
                 return;
             }
             // change the protocol from SecureProtocol.None
             // to SecureProtocol.Tls1
             options.Protocol = SecureProtocol.Tls1;
             // start the TLS handshake
             Connection.ChangeSecurityProtocol(options);
             // after this line, we're using an encrypted TLS connection
         }
         // from here on, act as if the SecureSocket is a normal Socket
         Send("MAIL FROM: [email protected]\r\n");             // [email protected] is not a real email address
         if (!IsReplyOK(Receive()))
         {
             Console.WriteLine("MAIL FROM failed.");
             return;
         }
         Send("RCPT TO:" + address + "\r\n");
         if (!IsReplyOK(Receive()))
         {
             Console.WriteLine("RCPT TO failed.");
             return;
         }
         Send("DATA\r\n");
         if (!IsReplyOK(Receive()))
         {
             Console.WriteLine("DATA failed.");
             return;
         }
         Send(TestMail.Replace("#ADDRESS#", address) + "\r\n.\r\n");
         if (!IsReplyOK(Receive()))
         {
             Console.WriteLine("Sending of e-mail failed.");
             return;
         }
         Send("QUIT\r\n");
         if (!IsReplyOK(Receive()))
         {
             Console.WriteLine("QUIT failed.");
         }
         Connection.Shutdown(SocketShutdown.Both);
     } catch (Exception e) {
         Console.WriteLine("An error occurred [" + e.Message + "]");
         Console.WriteLine(e);
     } finally {
         if (Connection != null)
         {
             Connection.Close();
         }
     }
 }