public void When_sending_a_rejection_email()
        {
            var email = S<IEmailService>();

            var organizer = new User("organizer")
            {
                Email = "*****@*****.**"
            };

            var callForSpeakers = new CallForSpeakers
            {
                Organizer = organizer,
                EventName = "event"
            };

            var speaker = new User("foo")
            {
                Email = "*****@*****.**"
            };

            var submission = new Submission(speaker, new SubmissionViewModel {Title = "title"}, callForSpeakers)
            {
                RejectionReason = "rejection reason"
            };

            var sender = new DomainEmailSender(email);
            sender.SubmissionRejection(submission);

            emailMessage = (EmailMessage) email.GetArgumentsForCallsMadeOn(x => x.Send(null))[0][0];
        }
예제 #2
0
        public void SubmissionRejection(Submission submission)
        {
            var msg = new EmailMessage
            {
                To = new[] { submission.Submitter.Email },
                Subject = "Your submission to " + submission.CallForSpeakers.EventName,
                Cc = new[] { submission.CallForSpeakers.Organizer.Email },
                Text = string.Format("Your submission \"{0}\" has been rejected by the organizer: {1}", submission.Title, submission.RejectionReason)
            };

            _emailService.Send(msg);
        }
예제 #3
0
        public void SubmissionAcceptance(Submission submission)
        {
            var msg = new EmailMessage
            {
                To = new[] { submission.Submitter.Email },
                Subject = "Your submission to " + submission.CallForSpeakers.EventName,
                Cc = new[] { submission.CallForSpeakers.Organizer.Email },
                Text = string.Format("Congratulations! Your submission \"{0}\" has been accepted!", submission.Title)
            };

            _emailService.Send(msg);
        }
예제 #4
0
        public void Test_email()
        {
            var email = new EmailMessage()
            {
                To = new[] { "*****@*****.**" },
                From = "*****@*****.**",
                Text = "this is a test",
                Subject = "test subject",
                Cc = new[]{"*****@*****.**"},
                Bcc = new[]{"*****@*****.**"},
                Html = "<b>HTML!</b>"
            };

            var emailService = new EmailService(new ApplicationSettings());
            emailService.Send(email);

            // http://www.mailinator.com/maildir.jsp?email=test34
            // http://www.mailinator.com/maildir.jsp?email=test34-bcc
        }    
예제 #5
0
        public void Send(EmailMessage message)
        {
            // http://documentation.mailgun.net/api-sending.html

            var domain = _settings.MailgunDomain();
            var apiKey = _settings.MailgunApiKey();

            var restClient = new RestClient("https://api.mailgun.net/v2")
            {
                Authenticator = new HttpBasicAuthenticator("api", apiKey)
            };

            var request = new RestRequest
            {
                Method = Method.POST,
                Resource = "{domain}/messages"
            };

            request.AddParameter("domain", domain, ParameterType.UrlSegment);
            request.AddParameter("from", message.From ?? GetNoReply());
            foreach (var to in message.To)
            {
                request.AddParameter("to", to);
            }
            foreach (var cc in message.Cc)
            {
                request.AddParameter("cc", cc);
            }
            foreach (var bcc in message.Bcc)
            {
                request.AddParameter("bcc", bcc);
            }
            request.AddParameter("subject", message.Subject);
            request.AddParameter("text", message.Text);
            request.AddParameter("html", message.Html);

            var response = restClient.Execute(request);
        }