Commit 47262405 by Urvil Shah

Send Email Via Send grid.

parent b4c93d26
Pipeline #7245 passed with stages
in 23 minutes 10 seconds
......@@ -26,7 +26,11 @@ namespace Mobile.Search.Web.Controllers
private readonly Dynamo _dynamoClient;
private static readonly string AwsAccessKey = ConfigUtilities.GetAppSetting("AWSAccessKey");
private static readonly string AwsSecretKey = ConfigUtilities.GetAppSetting("AWSSecretKey");
private static readonly string SmtpHost = ConfigUtilities.GetAppSetting("SMTPHost");
private static readonly string SmtpMinboxHost = ConfigUtilities.GetAppSetting("SMTPMinboxHost");
private static readonly string SmtpSendGridHost = ConfigUtilities.GetAppSetting("SMTPSendGridHost");
private static readonly string SmtpSendGridUsername = ConfigUtilities.GetAppSetting("SMTPSendGridUser");
private static readonly string SmtpSendGridPassword = ConfigUtilities.GetAppSetting("SMTPSendGridPass");
private static readonly int Port = int.Parse(ConfigUtilities.GetAppSetting("Port"));
private static readonly string FromEmail = ConfigUtilities.GetAppSetting("FromMailAddress");
......@@ -142,6 +146,7 @@ namespace Mobile.Search.Web.Controllers
{
try
{
string url = "http://config.minbox.email/Offer/Create/";
var d = new Dictionary<string, object>
{
{"templateKey", key.ToLower()},
......@@ -166,8 +171,10 @@ namespace Mobile.Search.Web.Controllers
{
_dynamoClient.WriteSingle("prd_2click_templates", d);
}
url = url+ key;
return RedirectToAction("Index");
return Redirect(url);
}
catch (Exception x)
{
......@@ -189,23 +196,41 @@ namespace Mobile.Search.Web.Controllers
MailMessage message = new MailMessage(from, to);
message.Subject = "Template Testing Via Html Editor";
message.Body = value;
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient(SmtpHost);
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.Port = Port;
if(email_id.Contains("minbox"))
{
client.Host = SmtpMinboxHost;
}
else
{
client.Host = SmtpSendGridHost;
System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(SmtpSendGridUsername,SmtpSendGridPassword);
client.Credentials = credentials;
}
// client.Port = Port;
try
{
client.Send(message);
return true;
}
catch (SmtpFailedRecipientException ex)
{
// ex.FailedRecipient and ex.GetBaseException() should give you enough info.
return false;
}
catch (Exception ex)
{
Console.WriteLine("Exception caught in CreateTestMessage4(): {0}",
ex.ToString());
return false;
}
return true;
}
}
......
......@@ -11,6 +11,9 @@
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<connectionStrings>
<add name="TopKeywordsRedshiftConnection" connectionString="Server=mobile-email.cejry5nesllx.us-west-2.redshift.amazonaws.com; Database=mobileemail; UID=mobsearch; PWD=44remember/TOKYO/shouted44; Port=5439" />
<add name="EmailConfigCampaign" connectionString="data source=54.189.228.250;Initial Catalog=EmailConfig;Persist Security Info=True;User ID=campaign_management;Password=Children is learning!;MultipleActiveResultSets=True;App=EntityFramework;Connection Timeout=25" providerName="System.Data.SqlClient" />
<add name="EmailConfig" connectionString="data source=54.189.228.250;Initial Catalog=EmailConfig;Persist Security Info=True;User ID=chuck;Password=Is our children learning?;MultipleActiveResultSets=True;App=EntityFramework;Connection Timeout=25" providerName="System.Data.SqlClient" />
<add name="MobileEmailRedshift" connectionString="Server=mobile-email.cejry5nesllx.us-west-2.redshift.amazonaws.com; Database=mobileemail; UID=chuck; PWD=1Sourchildrenlearning?; Port=5439; Pooling=false;" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
......@@ -30,7 +33,10 @@
<add key="YahooSourceTag" value="adknowledge_mobile_1click_c_search" />
<add key="AWSAccessKey" value="AKIAILPIR54LYZXOAXEA" />
<add key="AWSSecretKey" value="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" />
<add key="SMTPHost" value="smtp.email.minbox.email" />
<add key="SMTPMinboxHost" value="smtp.email.minbox.email" />
<add key="SMTPSendGridHost" value="smtp.sendgrid.net" />
<add key="SMTPSendGridUser" value="adkmobile" />
<add key="SMTPSendGridPass" value="Sh0w me the money!" />
<add key="Port" value="587" />
<add key="FromMailAddress" value="offers@minbox.email" />
<!-- temp for stats d counters -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment