Ejemplo n.º 1
0
        /// <summary>
        /// Verifies the environment, called before the send process
        /// starts to verify that important settings and infrastructure
        /// is in place.
        /// </summary>
        /// <returns>An EnvironmentVerification object, holding all the verification tests that has been run</returns>
        public virtual EnvironmentVerification VerifyEnvironment()
        {
            EnvironmentVerification env = new EnvironmentVerification();

            // Verify all the settings

            // Get the registered filter for working with recipients
            RecipientsUtility recipUtil = new RecipientsUtility();

            SmtpClient client = EPiMailEngine.GetConfiguredSmtpClient();

            // Need an smtp server specified
            if (string.IsNullOrEmpty(client.Host) == true)
            {
                env.VerificationItems.Add(VerificationType.Error, "Missing Smtp host setting in web.config. The aspnetEmail component requires a SMTP server to be specified.");
            }

            // Verify license file
            if (DoesLicenseFileExist() == false)
            {
                env.VerificationItems.Add(VerificationType.Error, "Can't find aspNetEmail License file: " + GetLocalLicenseFilePath());
            }

            return(env);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Verifies the environment, called before the send process
        /// starts to verify that important settings and infrastructure
        /// is in place.
        /// </summary>
        /// <returns>An EnvironmentVerification object, holding all the verification tests that has been run</returns>
        public virtual EnvironmentVerification VerifyEnvironment()
        {
            EnvironmentVerification env = new EnvironmentVerification();

            SmtpClient client = EPiMailEngine.GetConfiguredSmtpClient();

            // Need an smtp server specified
            if (string.IsNullOrEmpty(client.Host) && string.IsNullOrEmpty(client.PickupDirectoryLocation))
            {
                env.VerificationItems.Add(VerificationType.Error, "Missing Smtp settings in web.config. You need to configure smtp network host or a pickup directory.");
            }

            return(env);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Does the actual send action for the emails, using the System.Web.Mail namespace
        /// </summary>
        /// <param name="mail"></param>
        /// <param name="onlyTestDontSendMail"></param>
        /// <returns></returns>
        internal bool SendMail(MailMessage mail, bool onlyTestDontSendMail)
        {
            //don't send mail if localhost is set to smtp-server (probably in development enviroment)
            // 20051219 SC: Comment above is sound, but there is no test for it
            if (!onlyTestDontSendMail)
            {
                // mail. .UrlContentBase = SiteDefinition.Current.SiteUrl.ToString();
                mail.BodyEncoding = System.Text.Encoding.UTF8;

                SmtpClient client = EPiMailEngine.GetConfiguredSmtpClient();
                client.Send(mail);

                return(true);
            }

            return(false);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes the mail settings.
        /// </summary>
        /// <param name="mail">The mail.</param>
        protected void InitializeMailSettings(ref EmailMessage mail)
        {
            SmtpClient client = EPiMailEngine.GetConfiguredSmtpClient();

            // Server
            mail.Server = client.Host;

            // Port
            mail.Port = client.Port;

            //// User/password may both be empty -- in that case just ignore everything...
            //if (string.IsNullOrEmpty(userName) == false ||
            //    string.IsNullOrEmpty(password) == false)
            //{
            //    // If one has been defined, the other must also be defined
            //    if (string.IsNullOrEmpty(userName))
            //        throw new EPiServerException("Undefined username");
            //    if (string.IsNullOrEmpty(password))
            //        throw new EPiServerException("Undefined password");

            //    mail.Username = userName;
            //    mail.Password = password;
            // }
        }