public static PostmarkBounceDump GetBounceDump(this PostmarkClient client, string bounceId) { return(client.GetBounceDumpAsync(int.Parse(bounceId)).WaitForResult()); }
protected override void Setup() { _client = new PostmarkClient(READ_LINK_TRACKING_TEST_SERVER_TOKEN); }
protected override void Setup() { _client = new PostmarkClient(READ_SELENIUM_OPEN_TRACKING_TOKEN); }
protected override void Setup() { _client = new PostmarkClient(READ_SELENIUM_OPEN_TRACKING_TOKEN, requestTimeoutInSeconds: 60); }
protected override void Setup() { _client = new PostmarkClient(READ_SELENIUM_TEST_SERVER_TOKEN, requestTimeoutInSeconds: 60); }
protected override void Setup() { _client = new PostmarkClient(READ_SELENIUM_TEST_SERVER_TOKEN); }
public void Send(Email email) { var mail = CreateMailMessageFromEmail(email); try { if (SystemBehaviorConfig.OutboundEmailType == OutboundEmailTypes.Postmark) { if (mail.From != null && mail.From.Address.Contains("resgrid.com") && mail.From.Address != "*****@*****.**" && mail.From.Address != "*****@*****.**" && mail.From.Address != "*****@*****.**" && email.To.First() != "*****@*****.**" && email.To.First() != "*****@*****.**" && email.To.First() != "*****@*****.**") { var to = new StringBuilder(); foreach (var t in email.To) { if (to.Length == 0) { to.Append(t); } else { to.Append("," + t); } } //var message = new PostmarkMessage(email.From, to.ToString(), email.Subject, email.HtmlBody); var message = new PostmarkMessage("", to.ToString(), email.Subject, email.HtmlBody); var newClient = new PostmarkClient(Config.OutboundEmailServerConfig.PostmarkApiKey); message.From = null; //var response = newClient.SendMessage(message); //var response = newClient.SendMessageAsync(email.From, to.ToString(), email.Subject, email.HtmlBody).Result; var response = newClient.SendMessage(email.From, to.ToString(), email.Subject, email.HtmlBody); if (response.ErrorCode != 200 && response.ErrorCode != 406 && response.Message != "OK" && !response.Message.Contains("You tried to send to a recipient that has been marked as inactive")) { Logging.LogError(string.Format("Error from PostmarkEmailSender->Send: {3} {0} FromEmail:{1} ToEmail:{2}", response.Message, mail.From.Address, mail.To.First().Address, response.ErrorCode)); } } else { try { using (var smtpClient = new SmtpClient { DeliveryMethod = SmtpDeliveryMethod.Network, Host = Config.OutboundEmailServerConfig.Host }) { if (!String.IsNullOrWhiteSpace(OutboundEmailServerConfig.UserName) && !String.IsNullOrWhiteSpace(OutboundEmailServerConfig.Password)) { smtpClient.Credentials = new System.Net.NetworkCredential(OutboundEmailServerConfig.UserName, OutboundEmailServerConfig.Password); } smtpClient.Send(mail); } } catch (Exception ex) { Logging.LogException(ex); } } } else { try { using (var smtpClient = new SmtpClient { DeliveryMethod = SmtpDeliveryMethod.Network, Host = OutboundEmailServerConfig.Host }) { if (!String.IsNullOrWhiteSpace(OutboundEmailServerConfig.UserName) && !String.IsNullOrWhiteSpace(OutboundEmailServerConfig.Password)) { smtpClient.Credentials = new System.Net.NetworkCredential(OutboundEmailServerConfig.UserName, OutboundEmailServerConfig.Password); } smtpClient.Send(mail); } } catch (Exception ex) { Logging.LogException(ex); } } } catch (PostmarkValidationException) { } catch (Exception) { try { using (var smtpClient = new SmtpClient { DeliveryMethod = SmtpDeliveryMethod.Network, Host = Config.OutboundEmailServerConfig.Host }) { smtpClient.Credentials = new System.Net.NetworkCredential(Config.OutboundEmailServerConfig.UserName, Config.OutboundEmailServerConfig.Password); smtpClient.Send(mail); } } catch (Exception ex) { if (!ex.ToString().Contains("You tried to send to a recipient that has been marked as inactive.")) { Logging.LogException(ex); } } } }
public static PostmarkResponse EndSendMessage(this PostmarkClient client, IAsyncResult asyncResult) { return(asyncResult.UnwrapResult <PostmarkResponse>()); }
public static PostmarkInboundMessageList GetInboundMessages(this PostmarkClient client, string recipient, string fromemail, string subject, string mailboxhash, int count, int offset) { return(client.GetInboundMessagesAsync(offset, count, recipient, fromemail, subject, mailboxhash).WaitForResult()); }
public static MessageDump GetOutboundMessageDump(this PostmarkClient client, string messageID) { return(client.GetOutboundMessageDumpAsync(messageID).WaitForResult()); }
public static PostmarkInboundMessageList GetInboundMessages(this PostmarkClient client, string fromemail, int count, int offset) { return(client.GetInboundMessagesAsync(offset, count, fromemail: fromemail).WaitForResult()); }
public static PostmarkOutboundMessageList GetOutboundMessages(this PostmarkClient client, string recipient, string fromemail, string tag, string subject, int count, int offset) { return(client.GetOutboundMessagesAsync(offset, count, recipient, fromemail, tag, subject).WaitForResult()); }
public static PostmarkOutboundMessageList GetOutboundMessages(this PostmarkClient client, int count, int offset) { return(client.GetOutboundMessagesAsync(offset, count).WaitForResult()); }
public static PostmarkBounceActivation ActivateBounce(this PostmarkClient client, string bounceId) { return(client.ActivateBounceAsync(int.Parse(bounceId)).WaitForResult()); }
/*========================================================================================================================== | CONSTRUCTOR \-------------------------------------------------------------------------------------------------------------------------*/ /// <summary> /// Initializes a new instance of the <see cref="SendGridSmtpService"/> with necessary dependencies. /// </summary> /// <returns>A new instance of the <see cref="SendGridSmtpService"/>.</returns> public PostmarkSmtpService(PostmarkClient postmarkClient) { _smptClient = postmarkClient?? throw new ArgumentNullException(nameof(postmarkClient)); }
public static InboundMessageDetail GetInboundMessageDetail(this PostmarkClient client, string messageID) { return(client.GetInboundMessageDetailsAsync(messageID).WaitForResult()); }
/*========================================================================================================================== | CONSTRUCTOR \-------------------------------------------------------------------------------------------------------------------------*/ /// <summary> /// Establishes a new instance of the <see cref="GoldSimActivator"/>, including any shared dependencies to be used /// across instances of controllers. /// </summary> /// <remarks> /// The constructor is responsible for establishing dependencies with the singleton lifestyle so that they are available /// to all requests. /// </remarks> public GoldSimActivator(IConfiguration configuration, IWebHostEnvironment webHostEnvironment) { /*------------------------------------------------------------------------------------------------------------------------ | Verify dependencies \-----------------------------------------------------------------------------------------------------------------------*/ Contract.Requires(configuration, nameof(configuration)); Contract.Requires(webHostEnvironment, nameof(webHostEnvironment)); /*------------------------------------------------------------------------------------------------------------------------ | SAVE STANDARD DEPENDENCIES \-----------------------------------------------------------------------------------------------------------------------*/ _configuration = configuration; _webHostEnvironment = webHostEnvironment; var connectionString = configuration.GetConnectionString("OnTopic"); var sqlTopicRepository = new SqlTopicRepository(connectionString); var cachedTopicRepository = new CachedTopicRepository(sqlTopicRepository); /*------------------------------------------------------------------------------------------------------------------------ | PRELOAD REPOSITORY \-----------------------------------------------------------------------------------------------------------------------*/ _topicRepository = cachedTopicRepository; _typeLookupService = new GoldSimTopicViewModelLookupService(); _topicMappingService = new TopicMappingService(_topicRepository, _typeLookupService); _topicRepository.Load(); /*------------------------------------------------------------------------------------------------------------------------ | INITIALIZE EDITOR COMPOSER \-----------------------------------------------------------------------------------------------------------------------*/ _standardEditorComposer = new StandardEditorComposer(_topicRepository, _webHostEnvironment); /*------------------------------------------------------------------------------------------------------------------------ | CONSTRUCT SMTP CLIENT \-----------------------------------------------------------------------------------------------------------------------*/ //var sendGridApiKey = _configuration.GetValue<string>("SendGrid:ApiKey"); //var sendGridClient = new SendGridClient(sendGridApiKey); //_smtpService = new SendGridSmtpService(sendGridClient); var postmarkApiKey = _configuration.GetValue<string>("Postmark:ApiKey"); var postmarkClient = new PostmarkClient(postmarkApiKey); _smtpService = new PostmarkSmtpService(postmarkClient); /*------------------------------------------------------------------------------------------------------------------------ | CONSTRUCT HIERARCHICAL TOPIC MAPPING SERVICES \-----------------------------------------------------------------------------------------------------------------------*/ _hierarchicalTopicMappingService = new CachedHierarchicalTopicMappingService<NavigationTopicViewModel>( new HierarchicalTopicMappingService<NavigationTopicViewModel>( _topicRepository, _topicMappingService ) ); _coursewareTopicMappingService = new CachedHierarchicalTopicMappingService<TrackedNavigationTopicViewModel>( new HierarchicalTopicMappingService<TrackedNavigationTopicViewModel>( _topicRepository, _topicMappingService ) ); }
public static IAsyncResult BeginGetDeliveryStats(this PostmarkClient client) { return(client.GetDeliveryStatsAsync()); }
protected override async Task SetupAsync() { _client = new PostmarkClient(WRITE_TEST_SERVER_TOKEN); await CompletionSource; }
public static PostmarkDeliveryStats EndGetDeliveryStats(this PostmarkClient client, IAsyncResult asyncResult) { return(asyncResult.UnwrapResult <PostmarkDeliveryStats>()); }
protected override void Setup() { _adminClient = new PostmarkAdminClient(WRITE_ACCOUNT_TOKEN, BASE_URL); _server = TestUtils.MakeSynchronous(() => _adminClient.CreateServerAsync($"integration-test-suppressions-{Guid.NewGuid()}")); _client = new PostmarkClient(_server.ApiTokens.First(), BASE_URL); }
public static IAsyncResult BeginGetBounces(this PostmarkClient client, bool?inactive, string emailFilter, string tag, int offset, int count) { return(client.GetBouncesAsync(offset, count, null, inactive, emailFilter, tag)); }
public async Task <bool> SendCallMail(string email, string subject, string title, string priority, string natureOfCall, string mapPage, string address, string dispatchedOn, int callId, string userId, string coordinates, string shortenedAudioUrl) { string callQuery = String.Empty; try { callQuery = HttpUtility.UrlEncode(SymmetricEncryption.Encrypt(callId.ToString(), Config.SystemBehaviorConfig.ExternalLinkUrlParamPassphrase)); } catch { } var templateModel = new Dictionary <string, object> { { "subject", title }, { "date", dispatchedOn }, { "nature", HtmlToTextHelper.ConvertHtml(natureOfCall) }, { "priority", priority }, { "address", address }, { "map_page", mapPage }, { "action_url", $"{Config.SystemBehaviorConfig.ResgridBaseUrl}/User/Dispatch/CallExportEx?query={callQuery}" }, { "userId", userId }, { "coordinates", coordinates } }; if (!String.IsNullOrWhiteSpace(shortenedAudioUrl)) { templateModel.Add("hasCallAudio", "true"); templateModel.Add("callAudio_url", shortenedAudioUrl); } if (SystemBehaviorConfig.OutboundEmailType == OutboundEmailTypes.Postmark) { var message = new TemplatedPostmarkMessage { From = DONOTREPLY_EMAIL, To = email, TemplateId = Config.OutboundEmailServerConfig.PostmarkCallEmailTemplateId, TemplateModel = templateModel }; var client = new PostmarkClient(Config.OutboundEmailServerConfig.PostmarkApiKey); try { PostmarkResponse response = await client.SendMessageAsync(message); if (response.Status != PostmarkStatus.Success) { return(false); } return(true); } catch (Exception) { } } else { var template = Mustachio.Parser.Parse(GetTempate("Call.html")); var content = template(templateModel); Email newEmail = new Email(); newEmail.HtmlBody = content; newEmail.Sender = FROM_EMAIL; newEmail.To.Add(email); return(await _emailSender.Send(newEmail)); } return(false); }
public static IAsyncResult BeginGetBounces(this PostmarkClient client, PostmarkBounceType type, int offset, int count) { return(client.GetBouncesAsync(offset, count, type)); }
protected override void Setup() { _client = new PostmarkClient(READ_SELENIUM_TEST_SERVER_TOKEN); _lastMonth = TESTING_DATE - TimeSpan.FromDays(30); _windowStartDate = TESTING_DATE - TimeSpan.FromDays(35); }
public static IAsyncResult BeginGetBounces(this PostmarkClient client, bool?inactive, int offset, int count) { return(client.GetBouncesAsync(offset, count, inactive: inactive)); }
protected override void Setup() { _client = new PostmarkClient(WRITE_TEST_SERVER_TOKEN); }
public PostmarkEmailProvider(string serverToken) { _client = new PostmarkClient(serverToken); }
protected override void Setup() { _adminClient = new PostmarkAdminClient(WRITE_ACCOUNT_TOKEN, BASE_URL); _server = _adminClient.CreateServerAsync($"integration-test-webhooks-{Guid.NewGuid()}").Result; _client = new PostmarkClient(_server.ApiTokens.First(), BASE_URL); }
public static IEnumerable <string> GetBounceTags(this PostmarkClient client) { return(client.GetBounceTagsAsync().WaitForResult()); }