Ejemplo n.º 1
0
        private void NotifyIdeaUpdate(int id, string reason)
        {
            string       url      = string.Format("{0}Idea/View/{1}", BaseUrl, id);
            MailSettings settings = GetEmailSettings();

            ProcessFactory.GetNotificationProcess(settings, UserId).IdeaUpdated(id, reason, url);
        }
Ejemplo n.º 2
0
        public ResponseModel ValidateUpdateMailSettings(MailSettings settings)
        {
            ResponseModel result = new ResponseModel();

            if (string.IsNullOrWhiteSpace(settings.Mail))
            {
                result.Message = "Email adresi zorunludur!";
                return(result);
            }

            if (string.IsNullOrWhiteSpace(settings.Password))
            {
                result.Message = "Email şifresi zorunludur!";
                return(result);
            }

            if (settings.Port <= 0)
            {
                result.Message = "Post numarası zorunludur!";
                return(result);
            }

            if (string.IsNullOrWhiteSpace(settings.SmtpAddress))
            {
                result.Message = "SMTP adres zorunludur!";
                return(result);
            }

            result.IsSuccess = true;
            return(result);
        }
Ejemplo n.º 3
0
 public DebugController(IServiceScopeFactory scopeFactory, IBidsManager bidsManager, IOptions <MailSettings> mailSettings, IOptions <MailSecrets> mailSecrets, BidsUpdateJobs bidsUpdateJobs)
 {
     this.bidsManager  = bidsManager;
     this.ScopeFactory = scopeFactory;
     MailSettings      = mailSettings.Value;
     MailSecrets       = mailSecrets.Value;
 }
Ejemplo n.º 4
0
        private void NotifyOwners(int id)
        {
            string       url      = string.Format("{0}Idea/View/{1}", BaseUrl, id);
            MailSettings settings = GetEmailSettings();

            ProcessFactory.GetNotificationProcess(settings, UserId).IdeaCreated(url, id);
        }
Ejemplo n.º 5
0
        // GET: Task
        public TaskController(IHelperService helperService, ISmsService smsSvc, IEnrolleeService enrolleeService, ILogAdminService loggersvc, IProviderService providersvc, ISession session, IEmailSender emailSender, SiteSettings siteSettings, Site site, IPlanService planService, IUniquePageService uniquepageService, IPageMessageSvc pageMessageSvc, IServicesService serviceSvc, IProviderService Providersvc, ILogAdminService logger, ICompanyService companyService, UserService userService, IRoleService roleService, MailSettings mailSettings, Services.ClaimService claimserv)
        {
            _helperSvc       = helperService;
            _enrolleeService = enrolleeService;
            _smsservice      = smsSvc;
            _logger          = loggersvc;
            _providerservice = providersvc;

            _session           = session;
            _emailSender       = emailSender;
            _siteSettings      = siteSettings;
            _site              = site;
            _planService       = planService;
            _uniquePageService = uniquepageService;
            _pageMessageSvc    = pageMessageSvc;

            _serviceSvc  = serviceSvc;
            _providerSvc = Providersvc;
            _logger      = logger;
            _companySvc  = companyService;
            _userservice = userService;
            _rolesvc     = roleService;

            _mailSettings = mailSettings;

            _claimservice = claimserv;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Send Email
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public static async System.Threading.Tasks.Task SendMailAsync(string[] args)
        {
            try
            {
                var configuration = new ConfigurationBuilder()
                                    .AddJsonFile("SendMailSettings.json")
                                    .Build();
                Dictionary <string, string> MailSettings;
                MailSettings = configuration.GetSection("MailSettings").GetChildren().ToDictionary(x => x.Key, x => x.Value);
                MailSettings.Add("to", args[0]);
                MailSettings.Add("link", args[1]);
                GoogleClientSecrets gSecrets = GetSecretsFromEnvironment();
                string         credPath      = "token.json";
                UserCredential gcredential   = await GoogleWebAuthorizationBroker.AuthorizeAsync(
                    gSecrets.Secrets,
                    Scopes,
                    MailSettings["account"],
                    CancellationToken.None,
                    new FileDataStore(credPath, true));

                var service = new GmailService(new BaseClientService.Initializer()
                {
                    HttpClientInitializer = gcredential,
                    ApplicationName       = ApplicationName,
                });

                SendConfirmationEmail(service, MailSettings);
                Console.WriteLine($"Succesfully sent registration email to {args[0]}");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 7
0
    public string SendNewMail(NewMail mail, List <Group> groups, string sitename)
    {
        mail.groupEmails = GetEmailsFromGroups(groups);
        mail.date        = DateTime.Today;
        MailSettings settings = GetMailSettings(sitename);

        try {
            SmtpClient Smtp_Server = new SmtpClient();
            Smtp_Server.UseDefaultCredentials = false;
            Smtp_Server.Credentials           = new NetworkCredential(settings.email, settings.password);
            Smtp_Server.Port = Convert.ToInt32(settings.serverPort);


            Smtp_Server.EnableSsl = true;
            Smtp_Server.Host      = settings.serverHost;
            MailMessage mailMessage = new MailMessage();
            if (!string.IsNullOrWhiteSpace(mail.email))
            {
                mailMessage.To.Add(mail.email);
            }
            foreach (var x in mail.groupEmails)
            {
                mailMessage.To.Add(x.email);
            }
            mailMessage.From    = new MailAddress(settings.email);
            mailMessage.Subject = mail.subject;
            mailMessage.Body    = mail.message;
            Smtp_Server.Send(mailMessage);
            Save(mail);
            return("Poruka uspješno poslana.");
        }
        catch (Exception e) { return("Error: " + e); }
    }
Ejemplo n.º 8
0
        public static bool SendMail(MailSettings datosContacto)
        {
            try
            {
                MailMessage mailMessage = new MailMessage(Coder.Base64Decode(Settings.MailFrom), Coder.Base64Decode(Settings.MailTo))
                {
                    IsBodyHtml = true,
                    //mailMessage.Subject = Resources.resource.Mail_Subject;
                    Body = GetUpdatedMailContent(datosContacto)
                };

                SmtpClient smtpClient = new SmtpClient(Coder.Base64Decode(Settings.MailHost), int.Parse(Coder.Base64Decode(Settings.MailPort)));
                //smtpClient.EnableSsl = bool.Parse(Settings.MailEnableSsl);

                var credentials = new NetworkCredential(Coder.Base64Decode(Settings.MailUser), Coder.Base64Decode(Settings.MailPassword));

                smtpClient.Credentials = credentials;
                smtpClient.Send(mailMessage);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        public static ApplicationSettings Read(string configurationPath = "")
        {
            ApplicationSettings configuration = new ApplicationSettings();
            FileInfo            configurationFile;

            if (!String.IsNullOrWhiteSpace(configurationPath))
            {
                configurationFile = new FileInfo(configurationPath);
            }
            else
            {
                configurationFile = ConfigurationFile;
            }

            if (configurationFile.Exists)
            {
                XmlDocument document = new XmlDocument();
                document.Load(configurationFile.FullName);

                configuration.configPath = MCAD.XmlCommon.XmlTools.ReadString(document.DocumentElement, "configuration_path");
                configuration.LogLevel   = MCADCommon.LogCommon.Utils.ParseLogLevel(MCAD.XmlCommon.XmlTools.SafeReadString(document.DocumentElement, "log_level").IsSome ? MCAD.XmlCommon.XmlTools.ReadString(document.DocumentElement, "log_level") : "info");

                Option <XmlElement> vaultElement = MCAD.XmlCommon.XmlTools.SafeGetElement(document.DocumentElement, "vault_settings");
                configuration.VaultInfo = vaultElement.IsSome ? VaultSettings.Read(vaultElement.Get()).AsOption() : Option.None;

                Option <XmlElement> mailElement = MCAD.XmlCommon.XmlTools.SafeGetElement(document.DocumentElement, "mail_settings");
                configuration.MailInfo = mailElement.IsSome ? MailSettings.Read(mailElement.Get(), PassPhrase).AsOption() : Option.None;


                configuration.ExcludePaths                = MCAD.XmlCommon.XmlTools.ReadStringValues(document.DocumentElement, "exclude_paths", "path", false);
                configuration.IncludePaths                = MCAD.XmlCommon.XmlTools.ReadStringValues(document.DocumentElement, "include_paths", "path", false);
                configuration.ExcludeFiles                = MCAD.XmlCommon.XmlTools.ReadStringValues(document.DocumentElement, "exclude_files", "file", false);
                configuration.IncludeFiles                = MCAD.XmlCommon.XmlTools.ReadStringValues(document.DocumentElement, "include_files", "file", false);
                configuration.IncludeFilePatterns         = MCAD.XmlCommon.XmlTools.ReadStringValues(document.DocumentElement, "include_patterns", "expression", false).Select(e => new Regex(e + "$", RegexOptions.IgnoreCase)).ToList();
                configuration.PossiblyLockedFiles         = MCAD.XmlCommon.XmlTools.ReadStringValues(document.DocumentElement, "possible_locked_files", "file", false);
                configuration.DeleteFiles                 = MCAD.XmlCommon.XmlTools.ReadStringValues(document.DocumentElement, "delete_files", "file", false);
                configuration.FolderMappings              = GetFolderMappings(MCAD.XmlCommon.XmlTools.SafeGetElement(document.DocumentElement, "folder_mappings"));
                configuration.OutputPath                  = MCAD.XmlCommon.XmlTools.ReadString(document.DocumentElement, "output_path");
                configuration.OnlyRecreateFolderStructure = MCAD.XmlCommon.XmlTools.SafeReadString(document.DocumentElement, "only_recreate_folders").IsSome ? MCAD.XmlCommon.XmlTools.ReadString(document.DocumentElement, "only_recreate_folders").Equals("True", StringComparison.InvariantCultureIgnoreCase) : false;
                configuration.VersionToDownload           = MCAD.XmlCommon.XmlTools.SafeReadString(document.DocumentElement, "version_to_download").IsSome ? MCAD.XmlCommon.XmlTools.ReadString(document.DocumentElement, "version_to_download") : "latest";
                configuration.DownloadOnState             = MCAD.XmlCommon.XmlTools.SafeReadString(document.DocumentElement, "download_on_state");
                configuration.NetworkRetries              = MCAD.XmlCommon.XmlTools.SafeReadString(document.DocumentElement, "network_retries").IsSome ? Convert.ToInt32(MCAD.XmlCommon.XmlTools.ReadString(document.DocumentElement, "network_retries")) : 5;

                if (VaultEagle.VaultUtils.HandleNetworkErrors(() => File.Exists(Path.Combine(configuration.configPath, "last_sync_time.txt")), configuration.NetworkRetries))
                {
                    try { configuration.LastSyncTime = DateTime.ParseExact(VaultEagle.VaultUtils.HandleNetworkErrors(() => File.ReadLines(Path.Combine(configuration.configPath, "last_sync_time.txt")).First(), configuration.NetworkRetries), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); }
                    catch { configuration.LastSyncTime = DateTime.ParseExact("1990-01-01 00:00:00", "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); }
                }
                else
                {
                    configuration.LastSyncTime = DateTime.ParseExact("1990-01-01 00:00:00", "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
                }
            }
            else
            {
                configuration.configPath = "";
            }

            return(configuration);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Handle the upload functionality.
 /// </summary>
 /// <param name="mailSettings"></param>
 /// <param name="errorSettings"></param>
 /// <param name="documentRepository"></param>
 /// <param name="generalSettings"></param>
 public UploadHelperFunctionsUtility(IOptions <MailSettings> mailSettings, IOptions <ErrorSettings> errorSettings, IDocumentRepository documentRepository, IOptions <GeneralSettings> generalSettings)
 {
     this.mailSettings       = mailSettings.Value;
     this.errorSettings      = errorSettings.Value;
     this.documentRepository = documentRepository;
     this.generalSettings    = generalSettings.Value;
 }
Ejemplo n.º 11
0
 public void Send(MailSettings content)
 {
     new EfNotificationRepository().Add(new Notification
     {
         Text = "Email send."
     });
 }
Ejemplo n.º 12
0
        public static void sendMailUsingDBSettings(LeaveManagerContext database, string to, string subject, string body)
        {
            try
            {
                MailSettings ms = new MailSettings();
                ms = database.MailSettings.First();

                MailMessage message = new MailMessage();
                message.From = new MailAddress(ms.Username);
                message.To.Add(new MailAddress(to));
                message.IsBodyHtml   = true;
                message.BodyEncoding = Encoding.UTF8;
                message.Subject      = subject;
                message.Body         = body;

                using (var smtp = new SmtpClient())
                {
                    var credential = new NetworkCredential
                    {
                        UserName = ms.Username,
                        Password = ms.Password
                    };
                    smtp.UseDefaultCredentials = false;
                    smtp.Credentials           = credential;
                    smtp.Host      = ms.Host;
                    smtp.Port      = ms.Port;
                    smtp.EnableSsl = true;
                    smtp.Send(message);
                }
            }
            catch {
            }
        }
Ejemplo n.º 13
0
        public static void SendEmail(WorkshopSettings workshopSettings, MailSettings mailSettings, Document document, string attachmentPath)
        {
            if (workshopSettings == null)
            {
                throw new ArgumentNullException(nameof(workshopSettings));
            }
            if (mailSettings == null)
            {
                throw new ArgumentNullException(nameof(mailSettings));
            }
            if (document == null)
            {
                return;
            }

            string recipient = GetRecipientEmailAddresses(workshopSettings, mailSettings, document.CustomerContact);

            if (string.IsNullOrEmpty(recipient))
            {
                return;
            }

            recipient.Split(';').ForEach(c =>
            {
                CreateEmailTask(mailSettings, attachmentPath, c);
            });
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Send an email to a single recipient
        /// </summary>
        /// <param name="to">To.</param>
        /// <param name="from">From.</param>
        /// <param name="subject">The subject.</param>
        /// <param name="htmlContent">Content of the HTML.</param>
        /// <param name="textContent">Content of the text.</param>
        /// <param name="trackOpens">if set to <c>true</c> [track opens].</param>
        /// <param name="trackClicks">if set to <c>true</c> [track clicks].</param>
        /// <param name="subscriptionTracking">The subscription tracking.</param>
        /// <param name="replyTo">The reply to.</param>
        /// <param name="attachments">The attachments.</param>
        /// <param name="templateId">The template identifier.</param>
        /// <param name="sections">The sections.</param>
        /// <param name="headers">The headers.</param>
        /// <param name="categories">The categories.</param>
        /// <param name="customArgs">The custom arguments.</param>
        /// <param name="sendAt">The send at.</param>
        /// <param name="batchId">The batch identifier.</param>
        /// <param name="unsubscribeOptions">The unsubscribe options.</param>
        /// <param name="ipPoolName">Name of the ip pool.</param>
        /// <param name="mailSettings">The mail settings.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The message id.
        /// </returns>
        /// <remarks>
        /// This is a convenience method with simplified parameters.
        /// If you need more options, use the <see cref="SendAsync" /> method.
        /// </remarks>
        /// <exception cref="Exception">Email exceeds the size limit</exception>
        public Task <string> SendToSingleRecipientAsync(
            MailAddress to,
            MailAddress from,
            string subject,
            string htmlContent,
            string textContent,
            bool trackOpens  = true,
            bool trackClicks = true,
            SubscriptionTrackingSettings subscriptionTracking = null,
            MailAddress replyTo = null,
            IEnumerable <Attachment> attachments = null,
            string templateId = null,
            IEnumerable <KeyValuePair <string, string> > sections = null,
            IEnumerable <KeyValuePair <string, string> > headers  = null,
            IEnumerable <string> categories = null,
            IEnumerable <KeyValuePair <string, string> > customArgs = null,
            DateTime?sendAt = null,
            string batchId  = null,
            UnsubscribeOptions unsubscribeOptions = null,
            string ipPoolName                   = null,
            MailSettings mailSettings           = null,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            var recipients = new[] { to };

            return(SendToMultipleRecipientsAsync(recipients, from, subject, htmlContent, textContent, trackOpens, trackClicks, subscriptionTracking, replyTo, attachments, templateId, sections, headers, categories, customArgs, sendAt, batchId, unsubscribeOptions, ipPoolName, mailSettings, cancellationToken));
        }
Ejemplo n.º 15
0
        public static void SendMail(string bodyMsg, string errors, MailSettings settings)
        {
            var    fromAddress  = new MailAddress(settings.Email, settings.SenderName);
            var    toAddress    = new MailAddress(settings.ToEmail, settings.ToName);
            string fromPassword = settings.Password;
            string subject      = $"CRM job report - {DateTime.Now:dd.MM.yyyy}";
            string body         = bodyMsg;

            var smtp = new SmtpClient
            {
                Host                  = settings.SmtpHost,
                Port                  = settings.Port,
                EnableSsl             = settings.EnableSsl,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(fromAddress.Address, fromPassword)
            };

            using (var message = new MailMessage(fromAddress, toAddress)
            {
                Subject = subject,
                Body = body,
                IsBodyHtml = true
            })
            {
                if (errors != string.Empty)
                {
                    message.Attachments.Add(Attachment.CreateAttachmentFromString(errors, $"error_log_{DateTime.Now:yyyyMMdd}.txt"));
                }
                smtp.Send(message);
            }
        }
Ejemplo n.º 16
0
        public async Task SendEmailResponseAsync(string subject, string message, string email)
        {
            var    apiKey       = _configuration.GetValue <string>("Sendgrid:SendGridKey");
            string sandBoxMode  = _configuration.GetValue <string>("Sendgrid:UseSandbox");
            string userSendgrid = _configuration.GetValue <string>("Sendgrid:SendGridUser");


            var client = new SendGridClient(apiKey);
            var from   = new EmailAddress(userSendgrid);
            var to     = new EmailAddress(email);
            var msg    = MailHelper.CreateSingleEmail(from, to, subject, "", message);

            if (sandBoxMode == "true")
            {
                var MailSettings = new MailSettings();
                MailSettings.SandboxMode        = new SandboxMode();
                MailSettings.SandboxMode.Enable = true;
                msg.MailSettings = MailSettings;
            }

            var response = await client.SendEmailAsync(msg);

            if (response.StatusCode.ToString() != "Accepted")
            {
                throw new SendEmailBadRequestException(_localizer);
            }
        }
        private bool FetchInfoAndSendMail(FileInfo file)
        {
            MailContent  mailContent  = FetchMailContent(file);
            MailSettings mailSettings = FetchMailSettings();

            return(SendMail(mailContent, mailSettings));
        }
 public FeedbackController(MakerTrackerContext context, IMapper mapper, SendGridClient sendGridClient, MailSettings mailSettings, IConfiguration config) : base(context)
 {
     _mapper        = mapper;
     SendGridClient = sendGridClient;
     MailSettings   = mailSettings;
     Config         = config;
 }
Ejemplo n.º 19
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            MailSettings mailSettings = new MailSettings();

            mailSettings.User     = txtUserName.Text;
            mailSettings.Pass     = txtPass.Text;
            mailSettings.Port     = Convert.ToInt32(txtPort.Text);
            mailSettings.Smtptext = txtSmtp.Text;
            mailSettings.Ssl      = chkSSL.Checked;

            MailParams mailParams = new MailParams();

            mailParams.Totxt   = txtTo.Text;
            mailParams.Cctxt   = txtCC.Text;
            mailParams.Subject = txtSubject.Text;
            mailParams.Msgbody = txtMessage.Text;

            try
            {
                mailRepository.PizzeriaSendOrder(mailSettings, mailParams);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Send the same email to multiple recipients without using a template (which means you must provide the subject, html content and text content).
        /// </summary>
        /// <param name="recipients">The recipients.</param>
        /// <param name="from">From.</param>
        /// <param name="subject">The subject.</param>
        /// <param name="htmlContent">Content of the HTML.</param>
        /// <param name="textContent">Content of the text.</param>
        /// <param name="trackOpens">if set to <c>true</c> [track opens].</param>
        /// <param name="trackClicks">if set to <c>true</c> [track clicks].</param>
        /// <param name="subscriptionTracking">The subscription tracking.</param>
        /// <param name="replyTo">The reply to.</param>
        /// <param name="attachments">The attachments.</param>
        /// <param name="sections">The sections.</param>
        /// <param name="headers">The headers.</param>
        /// <param name="categories">The categories.</param>
        /// <param name="customArgs">The custom arguments.</param>
        /// <param name="sendAt">The send at.</param>
        /// <param name="batchId">The batch identifier.</param>
        /// <param name="unsubscribeOptions">The unsubscribe options.</param>
        /// <param name="ipPoolName">Name of the ip pool.</param>
        /// <param name="mailSettings">The mail settings.</param>
        /// <param name="priority">The priority.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The message id.
        /// </returns>
        /// <remarks>
        /// This is a convenience method with simplified parameters.
        /// If you need more options, use the <see cref="SendAsync" /> method.
        /// </remarks>
        /// <exception cref="ArgumentOutOfRangeException">Too many recipients.</exception>
        /// <exception cref="Exception">Email exceeds the size limit.</exception>
        public Task <string> SendToMultipleRecipientsAsync(
            IEnumerable <MailAddress> recipients,
            MailAddress from,
            string subject,
            string htmlContent,
            string textContent,
            bool trackOpens  = true,
            bool trackClicks = true,
            SubscriptionTrackingSettings subscriptionTracking = null,
            MailAddress replyTo = null,
            IEnumerable <Attachment> attachments = null,
            IEnumerable <KeyValuePair <string, string> > sections = null,
            IEnumerable <KeyValuePair <string, string> > headers  = null,
            IEnumerable <string> categories = null,
            IEnumerable <KeyValuePair <string, string> > customArgs = null,
            DateTime?sendAt = null,
            string batchId  = null,
            UnsubscribeOptions unsubscribeOptions = null,
            string ipPoolName                   = null,
            MailSettings mailSettings           = null,
            MailPriority priority               = MailPriority.Normal,
            CancellationToken cancellationToken = default)
        {
            var personalizations = new[]
            {
                new MailPersonalization
                {
                    To = recipients.ToArray()
                }
            };

            var contents = new List <MailContent>();

            if (!string.IsNullOrEmpty(textContent))
            {
                contents.Add(new MailContent("text/plain", textContent));
            }
            if (!string.IsNullOrEmpty(htmlContent))
            {
                contents.Add(new MailContent("text/html", htmlContent));
            }

            var trackingSettings = new TrackingSettings
            {
                ClickTracking = new ClickTrackingSettings
                {
                    EnabledInHtmlContent = trackClicks,
                    EnabledInTextContent = trackClicks
                },
                OpenTracking = new OpenTrackingSettings {
                    Enabled = trackOpens
                },
                GoogleAnalytics = new GoogleAnalyticsSettings {
                    Enabled = false
                },
                SubscriptionTracking = subscriptionTracking
            };

            return(SendAsync(personalizations, subject, contents, from, replyTo, attachments, null, sections, headers, categories, customArgs, sendAt, batchId, unsubscribeOptions, ipPoolName, mailSettings, trackingSettings, priority, cancellationToken));
        }
Ejemplo n.º 21
0
        public static bool Send(MailMessage message)
        {
            try
            {
                string       _mailsetting = ConfigurationManager.AppSettings["MailSettings"].ToString();
                MailSettings _setting     = JsonConvert.DeserializeObject <MailSettings>(_mailsetting);
                if (_setting.CopyAddresses.Count > 0)
                {
                    foreach (string address in _setting.CopyAddresses)
                    {
                        message.Bcc.Add(new MailAddress(address));
                    }
                }
                //var smtpClient = new SmtpClient
                //{
                //    Host = _setting.Host,
                //    Port = _setting.Port,
                //    EnableSsl = _setting.EnableSsl,
                //    DeliveryMethod = _setting.DeliveryMethod,
                //    UseDefaultCredentials = _setting.UseDefaultCredentials,
                //    Credentials = new NetworkCredential(_setting.Credentials.Username, _setting.Credentials.Password)
                //};

                SmtpClient smtpClient = new SmtpClient("smtp.sendgrid.net", Convert.ToInt32(587));
                System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("sendgridusername", "sendgridPassword");
                smtpClient.Credentials = credentials;

                smtpClient.Send(message);
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Ejemplo n.º 22
0
 public MailService(IOptions <MailSettings> mailSettings)
 {
     _mailSettings          = mailSettings.Value;
     _mailSettings.Mail     = DotEnv.Read()["MAIL"];
     _mailSettings.Password = DotEnv.Read()["MAIL_PASSWORD"];
     //TODO: check if we could load .env and not use Read anymore
 }
Ejemplo n.º 23
0
        public string SendMail(MailBody mailBody, MailSettings mailSettings)
        {
            string result = string.Empty;
            string path   = ".\\Private$\\MailBack";

            try
            {
                if (!MessageQueue.Exists(path))
                {
                    MessageQueue.Create(path);
                }
                //连接到本地的队列
                MessageQueue       myQueue   = new MessageQueue(path);
                Message            myMessage = new Message();
                MailBodyAndSetting body      = new MailBodyAndSetting(mailBody, mailSettings);
                myMessage.Body      = body;
                myMessage.Formatter = new BinaryMessageFormatter();
                //发送消息到队列中
                myQueue.Send(myMessage);
            }
            catch (Exception e)
            {
                result = e.Message;
            }
            return(result);
        }
Ejemplo n.º 24
0
 public RegularUserController(ApplicationDbContext context, UserManager <RegisteredUser> userManager,
                              IOptions <MailSettings> mailSettings)
 {
     _context      = context;
     _userManager  = userManager;
     _mailSettings = mailSettings.Value;
 }
Ejemplo n.º 25
0
 public EmailSender(
     IOptions <SiteSettings> siteSettings,
     IHostingEnvironment env)
 {
     this.mailSettings = siteSettings.Value.MailSettings;
     _env = env;
 }
Ejemplo n.º 26
0
        private void NotifyUserOfStatusUpdate(int id)
        {
            string       url      = string.Format("{0}Idea/View/{1}", BaseUrl, id);
            MailSettings settings = GetEmailSettings();

            ProcessFactory.GetNotificationProcess(settings, UserId).IdeaStatusUpdate(url, id);
        }
Ejemplo n.º 27
0
        public void MailSettings_SetViewData_ShouldNotThrow()
        {
            var mailSettings = new MailSettings();

            this.Invoking(tests => mailSettings.SetViewData(A.Fake <ISession>(), A.Fake <ViewDataDictionary>()))
            .ShouldNotThrow();
        }
Ejemplo n.º 28
0
        public ResponseModel UpdateMailSettings(MailSettings updObj)
        {
            ResponseModel result = new ResponseModel();

            result = ValidateUpdateMailSettings(updObj);

            if (!result.IsSuccess)
            {
                return(result);
            }

            bool value = _mailRepo.Update(updObj);

            result.IsSuccess = value;

            if (updObj.ApproveSendMailNewUser)
            {
                var sms_ = _smsRepo.GetAll().FirstOrDefault();
                sms_.RequiredIsRegister = false;
                _smsRepo.Update(sms_);
            }

            if (result.IsSuccess)
            {
                result.Message = "Bilgiler başarı ile güncellendi!";
            }
            StaticSettings.ReloadSettings();
            return(result);
        }
Ejemplo n.º 29
0
 public FormPostingHandler(IDocumentService documentService, IFileService fileService, MailSettings mailSettings, ISession session)
 {
     _documentService = documentService;
     _session         = session;
     _fileService     = fileService;
     _mailSettings    = mailSettings;
 }
Ejemplo n.º 30
0
        public Task SendMail(string email, string subject, string text, string[] attachments)
        {
            return(Task.Run(() =>
            {
                MailSettings mailSettings = Formatter.GetSettings <MailSettings>(@"Settings\MailSettings.mconf");

                MailAddress from = new MailAddress(mailSettings.ServiceHost);
                MailAddress to = new MailAddress(email);
                MailMessage mailMessage = new MailMessage(from, to);

                mailMessage.Subject = subject;
                mailMessage.Body = text;

                if (attachments != null)
                {
                    foreach (var attachment in attachments)
                    {
                        mailMessage.Attachments.Add(new Attachment(attachment));
                    }
                }

                SmtpClient smtpClient = new SmtpClient();

                smtpClient.Host = mailSettings.SMTPHost;
                smtpClient.Port = mailSettings.SMTPPort;
                smtpClient.UseDefaultCredentials = false;
                smtpClient.DeliveryMethod = mailSettings.DeliveryMethod;
                smtpClient.Credentials = new NetworkCredential(from.Address, mailSettings.ServicePassword);
                smtpClient.EnableSsl = mailSettings.EnableSSL;
                smtpClient.Timeout = mailSettings.Timeout;

                smtpClient.Send(mailMessage);
            }));
        }
Ejemplo n.º 31
0
        } // End Function GetAlternativeView

        private static void SendAttachment(MailSettings ms, System.Collections.Generic.IEnumerable <System.Net.Mail.Attachment> attachments)
        {
            using (System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage())
            {
                mail.HeadersEncoding = System.Text.Encoding.UTF8;

                mail.SubjectEncoding = System.Text.Encoding.UTF8;
                mail.Subject         = "Test-Mail mit Anlage 你好,世界";

                mail.BodyEncoding         = System.Text.Encoding.UTF8;
                mail.BodyTransferEncoding = System.Net.Mime.TransferEncoding.Base64;
                mail.IsBodyHtml           = true;
                mail.Body = System.IO.File.ReadAllText("mail_template.htm");
                mail.AlternateViews.Add(GetAlternativeView(mail.Body, "logo.png"));

                foreach (System.Net.Mail.Attachment thisAttachment in attachments)
                {
                    mail.Attachments.Add(thisAttachment);
                } // Next i

                mail.From = new System.Net.Mail.MailAddress(ms.FromAddress, ms.FromName);

                mail.To.Add(new System.Net.Mail.MailAddress(RedmineMailService.Trash.UserData.info, "A"));
                // mail.To.Add(new System.Net.Mail.MailAddress("*****@*****.**", "B"));
                // mail.To.Add(new System.Net.Mail.MailAddress("*****@*****.**", "B"));

                mail.ReplyToList.Add(new System.Net.Mail.MailAddress(RedmineMailService.Trash.UserData.ReplyTo, "Catch22"));

                Send(ms, mail);
            } // End Using mail
        }     // End Sub SendAttachment
Ejemplo n.º 32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Email"/> class.
 /// </summary>
 public Email()
 {
     mailSettings = MessagingCache.GetMailSettings();
       smtpClient = new SmtpClient(mailSettings.Host, mailSettings.Port);
       if (mailSettings.RequireAuthentication) {
     smtpClient.Credentials = new NetworkCredential(mailSettings.UserName, mailSettings.Password);
       }
       if (mailSettings.RequireSsl) {
     smtpClient.EnableSsl = true;
       }
 }
Ejemplo n.º 33
0
 /// <summary>
 /// Configure email for sending IPCam images.
 /// </summary>
 public void SetMail(MailSettings settings)
 {
     RovioResponse response = this.Request("/SetMail.cgi",
         new RequestItem("Enable", settings.Enabled ? "true" : "false"),
         new RequestItem("MailServer", settings.MailServer),
         new RequestItem("Port", settings.Port),
         new RequestItem("Sender", settings.Sender),
         new RequestItem("Receiver", settings.Receiver),
         new RequestItem("Subject", settings.Subject),
         new RequestItem("Body", settings.Body),
         new RequestItem("User", settings.UserName),
         new RequestItem("PassWord", settings.Password),
         new RequestItem("CheckFlag", settings.AuthRequired ? "CHECK" : ""),
         new RequestItem("Interval", settings.Interval));
 }
Ejemplo n.º 34
0
        /// <summary>
        /// Get email settings.
        /// </summary>
        /// <returns></returns>
        public MailSettings GetMail()
        {
            RovioResponse response = this.Request("/GetMail.cgi");

            MailSettings settings = new MailSettings();
            settings.MailServer = response["MailServer"];
            settings.Port = int.Parse(response["Port"]);
            settings.Sender = response["Sender"];
            settings.Receiver = response["Receiver"];
            settings.Subject = response["Subject"];
            settings.Body = response["Body"];
            settings.UserName = response["User"];
            settings.Password = response["PassWord"];
            settings.AuthRequired = RovioAPI.GetBoolean(int.Parse(response["CheckFlag"]));

            settings.Enabled = RovioAPI.GetBoolean(int.Parse(response["Enable"]));

            return settings;
        }
Ejemplo n.º 35
0
 public void AddToMailSettingsSet(MailSettings mailSettings)
 {
     base.AddObject("MailSettingsSet", mailSettings);
 }
Ejemplo n.º 36
0
 public static MailSettings CreateMailSettings(int ID, byte[] rowVersion, string smtpServer, int port, string username, string password, string senderAddress)
 {
     MailSettings mailSettings = new MailSettings();
     mailSettings.Id = ID;
     mailSettings.RowVersion = rowVersion;
     mailSettings.SmtpServer = smtpServer;
     mailSettings.Port = port;
     mailSettings.Username = username;
     mailSettings.Password = password;
     mailSettings.SenderAddress = senderAddress;
     return mailSettings;
 }