Ejemplo n.º 1
0
        public override void SendTicket(String to, PdfDocument.Pdf ticket)
        {
            _log.LogInformation("[FakeSender] Sending ticket to {0}", to);
            IEnumerable <FakeEmail> emails = new List <FakeEmail>
            {
                new FakeEmail
                {
                    to         = to,
                    subject    = "Билет The Cellophane Heads - X лет",
                    html       = "",
                    attachment = ticket.ToBytes().ToString()
                }
            };

            Task
            .Run(() => _client.PostAsync(
                     "api/emails",
                     new StringContent(
                         JsonSerializer.Serialize(emails, _options),
                         Encoding.UTF8,
                         "application/json"
                         )))
            .Wait();
            _log.LogInformation("[FakeSender] Successfully send ticket to {0}", to);
        }
Ejemplo n.º 2
0
        public override void SendTicket(String to, PdfDocument.Pdf ticket)
        {
            var builder = new BodyBuilder
            {
                TextBody = "Билеты во вложении",
            };

            builder.Attachments.Add($"Ticket-{DateTime.Now}.pdf", ticket.ToBytes(), new ContentType("application", "pdf"));

            var message = new MimeMessage();

            message.From.Add(new MailboxAddress("no-reply", "*****@*****.**"));
            message.To.Add(new MailboxAddress(to));
            message.Subject = "Билеты от Чертополоха";
            message.Body    = builder.ToMessageBody();

            _log.LogInformation("Send ticket to @{0}", to);

            using (var smtpClient = new SmtpClient())
            {
                _log.LogInformation("Create new SmtpClient");
                smtpClient.ServerCertificateValidationCallback = (s, c, h, e) => true;
                smtpClient.Connect("smtp.yandex.ru", 465, true);
                _log.LogInformation("Authenticate via SmtpClient");
                smtpClient.Authenticate(_smtpUsername, _smtpPassword);
                _log.LogInformation("Send email via Yandex account");
                smtpClient.Send(message);
                _log.LogInformation("Disconnect and dispose");
                smtpClient.Disconnect(true);
            }
        }
Ejemplo n.º 3
0
 public abstract void SendTicket(String to, PdfDocument.Pdf ticket);