private void Send() { SmtpEmailSender mailSender = new SmtpEmailSender("mail.web-galaxy.com.ua", "*****@*****.**", "WebGalaxyAdmin!"); var body = SmtpEmailSender.GetHtmlRazor(Request, SmtpEmailSender.FormatUrl("UserMailView")); mailSender.Send("*****@*****.**", "Новое сообщение", body); }
public async Task SendEmailEmptyPasswordTaskSpanishKo() { var defaultCulture = Thread.CurrentThread.CurrentUICulture; Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-ES"); var smtp = GetService <IOptionsService <SmtpSettings> >(); smtp.Value.Password = null; var sender = new SmtpEmailSender(smtp); var bytes = await GetPhotoBinary(); var attachment = new EmailAttachment("Adjunto", bytes); Task Action() { return(sender.SendEmailAsync("*****@*****.**", "Testing con adjunto", "Prueba testing con adjunto", attachment)); } var exception = await Assert.ThrowsAsync <EmailException>(Action); //The thrown exception can be used for even more detailed assertions. Assert.Equal(ExceptionCodes.SMT_PASS_EMPTY, exception.Message); Thread.CurrentThread.CurrentUICulture = defaultCulture; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddDbContext <Context>(); services.AddTransient <IDeleteCategoryCommand, EfDeleteCategoryCommand>(); services.AddTransient <IDeleteGenderCommand, EfDeleteGenderCommand>(); services.AddTransient <IDeleteJournalistCommand, EfDeleteJournalistCommand>(); services.AddTransient <IDeleteLogCommand, EfDeleteLogCommand>(); services.AddTransient <IDeleteRoleCommand, EfDeleteRoleCommand>(); services.AddTransient <IDeleteStoryCommand, EfDeleteStoryCommand>(); services.AddTransient <IDeleteUserCommand, EfDeleteUserCommand>(); services.AddTransient <IGetCategoryCommand, EfGetCategoryCommand>(); services.AddTransient <IGetGenderCommand, EfGetGenderCommand>(); services.AddTransient <IGetJournalistCommand, EfGetJournalistCommand>(); services.AddTransient <IGetLogCommand, EfGetLogCommand>(); services.AddTransient <IGetRoleCommand, EfGetRoleCommand>(); services.AddTransient <IGetStoryCommand, EfGetStoryCommand>(); services.AddTransient <IGetUserCommand, EfGetUserCommand>(); services.AddTransient <IGetCategoriesCommand, EfGetCategoriesCommand>(); services.AddTransient <IGetGendersCommand, EfGetGendersCommand>(); services.AddTransient <IGetJournalistsCommand, EfGetJournalistsCommand>(); services.AddTransient <IGetLogsCommand, EfGetLogsCommand>(); services.AddTransient <IGetRolesCommand, EfGetRolesCommand>(); services.AddTransient <IGetStoriesCommand, EfGetStoriesCommand>(); services.AddTransient <IGetUsersCommand, EfGetUsersCommand>(); services.AddTransient <IInsertCategoryCommand, EfInsertCategoryCommand>(); services.AddTransient <IInsertGenderCommand, EfInsertGenderCommand>(); services.AddTransient <IInsertJournalistCommand, EfInsertJournalistCommand>(); services.AddTransient <IInsertLogCommand, EfInsertLogCommand>(); services.AddTransient <IInsertRoleCommand, EfInsertRoleCommand>(); services.AddTransient <IInsertStoryCommand, EfInsertStoryCommand>(); services.AddTransient <IInsertUserCommand, EfInsertUserCommand>(); services.AddTransient <IUpdateCategoryCommand, EfUpdateCategoryCommand>(); services.AddTransient <IUpdateGenderCommand, EfUpdateGenderCommand>(); services.AddTransient <IUpdateJournalistCommand, EfUpdateJournalistCommand>(); services.AddTransient <IUpdateLogCommand, EfUpdateLogCommand>(); services.AddTransient <IUpdateRoleCommand, EfUpdateRoleCommand>(); services.AddTransient <IUpdateStoryCommand, EfUpdateStoryCommand>(); services.AddTransient <IUpdateUserCommand, EfUpdateUserCommand>(); var section = Configuration.GetSection("Email"); var sender = new SmtpEmailSender(section["host"], Int32.Parse(section["port"]), section["fromaddress"], section["password"]); services.AddSingleton <IEmailSender>(sender); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "Info News Api", Version = "v1" }); }); }
public void SendEmailWithAppointmentWorksAsExpected() { // --- Arrange var sender = new SmtpEmailSender(); // --- Act sender.SendEmail("*****@*****.**", "Novák István", new[] { "*****@*****.**" }, "Test Email", "This is a test email", new AppointmentDefinitionDto { OrganizerEmail = "*****@*****.**", OrganizerName = "István Novák", Date = new DateTime(2014, 8, 22), StartHour = 8, StartMinute = 30, EndHour = 9, EndMinute = 45, Subject = "Test megbeszélés", Description = "Megbeszéljuk a tesztet", Location = "Nálunk", Recepients = new[] { "*****@*****.**", "*****@*****.**" }, ReminderMinutesBefore = 15, UseReminder = true }); // --- Assert }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddDbContext <AspProjContext>(); services.AddTransient <IGetCoursesCommand, EfGetCoursesCommand>(); services.AddTransient <IGetCourseCommand, EfGetCourseCommand>(); services.AddTransient <IAddCourseCommand, EfAddCourseCommand>(); services.AddTransient <IEditCourseCommand, EfEditCourseCommand>(); services.AddTransient <IDeleteCourseCommand, EfDeleteCourseCommand>(); services.AddTransient <IGetStudentsCommand, EfGetStudentsCommand>(); services.AddTransient <IGetStudentCommand, EfGetStudentCommand>(); services.AddTransient <IAddStudentCommand, EfAddStudentCommand>(); services.AddTransient <IEditStudentCommand, EfEditStudentCommand>(); services.AddTransient <IDeleteStudentCommand, EfDeleteStudentCommand>(); services.AddTransient <IGetTeachersCommand, EfGetTeachersCommand>(); services.AddTransient <IGetTeacherCommand, EfGetTeacherCommand>(); services.AddTransient <IDeleteTeacherCommand, EfDeleteTeacherCommand>(); services.AddTransient <IAddTeacherCommand, EfAddTeacherCommand>(); services.AddTransient <IEditTeacherCommand, EfEditTeacherCommand>(); var section = Configuration.GetSection("Email"); var sender = new SmtpEmailSender(section["host"], Int32.Parse(section["port"]), section["fromaddress"], section["password"]); services.AddSingleton <IEmailSender>(sender); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "AspProject", Version = "v1" }); }); }
private void Send(UserEmailMessage mail) { SmtpEmailSender mailSender = new SmtpEmailSender("mail.klinikimzentrum.od.ua", "*****@*****.**", "klinikimzentrum!");//Properties.Settings.Default.SmtpServer, Properties.Settings.Default.EmailFrom, Properties.Settings.Default.EmailPassword); var body = SmtpEmailSender.GetHtmlRazor(mail, SmtpEmailSender.FormatUrl("SupportMailView")); mailSender.Send("*****@*****.**", "Новый запрос", body); }
public void Main(string[] args) { var mail = new SmtpEmailSender("smtp.ym.163.com", 25, "Code Comb", "*****@*****.**", "*****@*****.**", "123456"); mail.SendEmailAsync("*****@*****.**", "关于MailSender项目说明", "<html><head><meta http-equiv=\"Content-type\" content=\"text/html;charset=utf-8\"/></head><body>能收到邮件吗</body></html>").Wait(); Console.Read(); }
private void Send() { SmtpEmailSender mailSender = new SmtpEmailSender("mail.texac.od.ua", "*****@*****.**", "tehas21032017!");//Properties.Settings.Default.SmtpServer, Properties.Settings.Default.EmailFrom, Properties.Settings.Default.EmailPassword); var op = new LoadCartOperation(_cartModel, _gameModel); op.ExcecuteTransaction(); FullCartModel model = new FullCartModel { Games = op._games, Products = op._products, Email = new UserEmailMessage { Date = DateTime.Now, Message = _message, Phone = _phone, Username = _name, Type = _type, }, }; var body = SmtpEmailSender.GetHtmlRazor(model, SmtpEmailSender.FormatUrl("OrderMailView")); mailSender.Send("*****@*****.**", "Новый заказ", body); }
public async Task SendEmailOk() { var sender = new SmtpEmailSender(GetService <IOptionsService <SmtpSettings> >()); await sender.SendEmailAsync("Testing", "Prueba testing"); Assert.True(true); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddDbContext <EfContext>(); //categories services.AddTransient <IAddCategoryCommand, EfAddCategoryCommand>(); services.AddTransient <IGetCategoriesCommand, EfGetCategoriesCommand>(); services.AddTransient <IGetCategoryCommand, EfGetCategoryCommand>(); services.AddTransient <IEditCategoryCommand, EfEditCategoryCommand>(); services.AddTransient <IDeleteCategoryCommand, EfDeleteCategoryCommand>(); //users services.AddTransient <IGetUserCommand, EfGetUserCommand>(); services.AddTransient <IGetUsersCommand, EfGetUsersCommand>(); services.AddTransient <IAddUserCommand, EfAddUserCommand>(); services.AddTransient <IEditUserCommand, EfEditUserCommand>(); services.AddTransient <IDeleteUserCommand, EfDeleteUserCommand>(); services.AddTransient <IGetRolesWithoutPaginationCommand, EfGetRolesWithoutPaginationCommand>(); //roles services.AddTransient <IGetRolesCommand, EfGetRolesCommand>(); services.AddTransient <IGetRoleCommand, EfGetRoleCommand>(); services.AddTransient <IAddRoleCommand, EfAddRoleCommand>(); services.AddTransient <IEditRoleCommand, EfEditRoleCommand>(); services.AddTransient <IDeleteRoleCommand, EfDeleteRoleCommand>(); //posts services.AddTransient <IGetPostsCommand, EfGetPostsCommand>(); services.AddTransient <IGetPostCommand, EfGetPostCommand>(); services.AddTransient <IDeletePostCommand, EfDeletePostCommand>(); services.AddTransient <IAddPostCommand, EfAddPostCommand>(); services.AddTransient <IGetCategoriesWithoutPaginationCommand, EfGetCategoriesWithoutPaginationCommand>(); services.AddTransient <IGetUsersWithoutPaginationCommand, EfGetUsersWithoutPaginationCommand>(); services.AddTransient <IGetTagsWithoutPaginationCommand, EfGetTagsWithoutPaginationCommand>(); services.AddTransient <IEditPostCommand, EfEditPostCommand>(); //pagination services.AddCloudscribePagination(); //email var section = Configuration.GetSection("Email"); var sender = new SmtpEmailSender(section["host"], Int32.Parse(section["port"]), section["fromaddress"], section["password"]); services.AddSingleton <IEmailSender>(sender); //login services.AddTransient <ILoginUserCommand, EfLoginUserCommand>(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }
public void SendEmailWorksAsExpected() { // --- Arrange var sender = new SmtpEmailSender(); // --- Act sender.SendEmail("*****@*****.**", "Novák István", new[] { "*****@*****.**" }, "Test Email", "This is a test email"); // --- Assert }
public static void SendICalEmail(IICalendar iCal, MailMessage message, TenantEmailSetting emailServerSettings) { ///// // Create an instance of the iCalendar serializer. ///// var serializer = new iCalendarSerializer( ); ///// // Determine whether an alternate view of type HTML is required. ///// if (message.IsBodyHtml && !string.IsNullOrEmpty(message.Body)) { ///// // Create the html content type. ///// var htmlContentType = new ContentType(MediaTypeNames.Text.Html); ///// // Add the html alternate view. ///// AlternateView htmlAlternateView = AlternateView.CreateAlternateViewFromString(message.Body, htmlContentType); message.AlternateViews.Add(htmlAlternateView); } ///// // Create the calendar content type. ///// var calendarContentType = new ContentType("text/calendar"); if (calendarContentType.Parameters != null) { calendarContentType.Parameters.Add("method", "REQUEST"); } ///// // Add the calendar alternate view. ///// AlternateView calendarAlternateView = AlternateView.CreateAlternateViewFromString(serializer.SerializeToString(iCal), calendarContentType); message.AlternateViews.Add(calendarAlternateView); ///// // Get a list of MailMessage instances. ///// var messages = new List <MailMessage> { message }; var emailsender = new SmtpEmailSender(emailServerSettings); emailsender.SendMessages(messages); }
/// <summary> /// 发送信件 /// </summary> /// <param name="input">实体</param> /// <returns></returns> public void SendMailMessage(MailMessage input) { try { SmtpEmailSender emailSender = new SmtpEmailSender(_smtpEmialSenderConfig); emailSender.Send(input); } catch (Exception e) { throw new UserFriendlyException((int)ErrorCode.HttpPortErr, "发信失败:" + e.Message); } }
public bool SendEmail() { //emailManager.SendMailToAdmin("title", "Hello"); //return true; var emailSender = new SmtpEmailSender( smtpEmailSenderConfiguration); string body = "<h1>This is HTML</h1>"; emailSender.Send("*****@*****.**", "*****@*****.**", "This is a test", body, true); return(true); }
/// <summary> /// 发送邮件 /// </summary> private async Task SendEmail(string to, string body, bool isHtml = true) { try { SmtpEmailSender emailSender = new SmtpEmailSender(_smtpEmailSenderConfiguration); await emailSender.SendAsync(to, "密码重置链接", body, isHtml); } catch (Exception e) { throw new UserFriendlyException(e.Message); } }
public void SendEmail(int teamLeaderId, string name) { if (_abpSession.TenantId == null) { return; } var user = _userRepository.Get(ObjectMapper.Map <long>(teamLeaderId)); SmtpEmailSender emailSender = new SmtpEmailSender(_smtpEmialSenderConfig); string message = "Be aware of you task project -- " + name + ", which is approaching its deliver time."; emailSender.Send("*****@*****.**", user.EmailAddress, "New Todo item", message); }
public async Task SendEmailWithAttachmentOk() { var sender = new SmtpEmailSender(GetService <IOptionsService <SmtpSettings> >()); var bytes = await GetPhotoBinary(); var attachment = new EmailAttachment("Adjunto.jpg", bytes); await sender.SendEmailAsync("Testing con adjunto", "Prueba testing con adjunto", attachment); Assert.True(true); }
/// <summary> /// 发送信件 /// </summary> /// <param name="input">实体</param> /// <returns></returns> public bool SendEMail(SendEmailInput input) { try { SmtpEmailSender emailSender = new SmtpEmailSender(_smtpEmialSenderConfig); emailSender.Send(input.From, input.To, input.Subject, input.Body, input.IsBodyHtml); return(true); } catch (Exception e) { throw new UserFriendlyException((int)ErrorCode.HttpPortErr, "发信失败:" + e.Message); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddDbContext <AdsContext>(); services.AddTransient <ICreateCategoryCommand, EfCreateCategoryCommand>(); services.AddTransient <ICreateAdCommand, EfCreateAdCommand>(); services.AddTransient <IGetCategoriesCommand, EfGetCategoriesCommand>(); services.AddTransient <IGetAdsCommand, EfGetAdsCommands>(); services.AddTransient <IJwtFactory, JwtFactory>(); services.AddTransient <IDeleteAdCommand, EfDeleteAdCommand>(); services.AddTransient <IEditAdCommand, EfEditAdCommand>(); services.AddTransient <ICreateRemoveFollowerCommand, EfCreateRemoveFollowerCommand>(); services.AddTransient <IGetFollowersCommand, EfGetFollowersCommand>(); services.AddTransient <ICreateOfferCommand, EfCreateOfferCommand>(); services.AddTransient <IDeleteOfferCommand, EfDeleteOfferCommand>(); services.AddTransient <IEditOfferCommand, EfEditOfferCommand>(); services.AddTransient <IGetAdOffersCommand, EfGetAdOffersCommand>(); services.AddTransient <ICreateCommentCommand, EfCreateCommentCommand>(); services.AddTransient <IEditCommentCommand, EfEditCommentCommand>(); services.AddTransient <IGetCommentCommand, EfGetCommentCommand>(); services.AddTransient <IGetAdCommentsCommand, EfGetAdCommentsCommand>(); services.AddTransient <IEmailSender, SmtpEmailSender>(); services.AddTransient <IGetOfferByIdCommand, EfGetOfferByIdCommand>(); services.AddTransient <IGetOfferCommand, EfGetOfferCommand>(); var section = Configuration.GetSection("Email"); var sender = new SmtpEmailSender(section["host"], Int32.Parse(section["port"]), section["fromaddress"], section["password"]); services.AddSingleton <IEmailSender>(sender); services.AddIdentity <ApplicationUser, IdentityRole>(config => { config.Password.RequireDigit = false; config.Password.RequiredLength = 4; config.Password.RequireLowercase = false; config.Password.RequireNonAlphanumeric = false; config.Password.RequireUppercase = false; config.User.RequireUniqueEmail = true; }).AddEntityFrameworkStores <AdsContext>() .AddDefaultTokenProviders(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddDbContext <NewsContext>(); services.AddDistributedMemoryCache(); services.AddTransient <UserDto>(); services.AddSession(options => { // Set a short timeout for easy testing. options.IdleTimeout = TimeSpan.FromSeconds(60); options.Cookie.HttpOnly = true; // Make the session cookie essential options.Cookie.IsEssential = true; }); services.AddTransient <IGetUserFromLoginForm, EfGetUserCommnd>(); services.AddTransient <IAddCommentCommand, EfAddCommentCommand>(); services.AddTransient <IGetCommentsCommand, EfGetCommentsCommand>(); services.AddTransient <IGetCommentCommand, EfGetCommentCommand>(); services.AddTransient <IDeleteCommentCommand, EfDeleteCommentCommand>(); services.AddTransient <IEditCommentCommand, EfEditCommentCommand>(); services.AddTransient <IGetNewsCommand, EfGetNewsCommand>(); services.AddTransient <IGetNewCommand, EfGetNewCommand>(); services.AddTransient <IAddNewsCommand, EfCreateNewsCommand>(); services.AddTransient <IEditNewsCommand, EfEditNewsCommand>(); services.AddTransient <IDeleteNewsCommand, EfDeleteNewsCommand>(); services.AddTransient <IGetCategoriesCommand, EfGetCategoriesCommand>(); services.AddSingleton <IFileProvider>( new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/uploads"))); var section = Configuration.GetSection("Email"); var sender = new SmtpEmailSender(section["host"], Int32.Parse(section["port"]), section["fromaddress"], section["password"]); services.AddSingleton <IEmailSender>(sender); }
public static bool SendMail(IEmail email) { ISmtpEmailServerAppConfiguration config = new SmtpEmailServerAppConfiguration(); IEmailServerConfiguration server = new SmtpEmailServerConfiguration(config); IEmailSender sender = new SmtpEmailSender(server); try { return(sender.SendEmail(email)); } catch { } return(false); }
public void SendSimpleMail() { IEmailSender emailSender = new SmtpEmailSender(() => { SmtpSettings settings = new SmtpSettings(); settings.SmtpMailServer = "smtp.gmail.com"; settings.SmtpPort = 465; settings.SenderLogin = "******"; settings.SenderDisplayName = "dmi yermachenko"; settings.SenderPassword = "******"; settings.SenderEmail = "*****@*****.**"; return(settings); }, null); emailSender.SendEmailAsync("*****@*****.**", "Your test was succees", "Reporting entry").Wait(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddDbContext <ForumContext>(); // Categories Block services.AddTransient <IGetCategoryCommand, EfGetCategoryCommand>(); services.AddTransient <IGetCategoriesCommand, EfGetCategoriesCommand>(); services.AddTransient <IAddCategoryCommand, EfAddCategoryCommand>(); services.AddTransient <IDeleteCategoryCommand, EfDeleteCategoryCommand>(); services.AddTransient <IUpdateCategoryCommand, EfUpdateCategoryCommand>(); // Topics Block services.AddTransient <IGetTopicCommand, EfGetTopicCommand>(); services.AddTransient <IGetTopicsCommand, EfGetTopicsCommand>(); services.AddTransient <IAddTopicCommand, EfAddTopicCommand>(); services.AddTransient <IDeleteTopicCommand, EfDeleteTopicCommand>(); services.AddTransient <IUpdateTopicCommand, EfUpdateTopicCommand>(); // Comments Block services.AddTransient <IGetCommentCommand, EfGetCommentCommand>(); services.AddTransient <IGetCommentsCommand, EfGetCommentsCommand>(); services.AddTransient <IAddCommentCommand, EfAddCommentCommand>(); services.AddTransient <IDeleteCommentCommand, EfDeleteCommentCommand>(); services.AddTransient <IUpdateCommentCommand, EfUpdateCommentCommand>(); // Users Block services.AddTransient <IGetUserCommand, EfGetUserCommand>(); services.AddTransient <IGetUsersCommand, EfGetUsersCommand>(); services.AddTransient <IAddUserCommand, EfAddUserCommand>(); services.AddTransient <IDeleteUserCommand, EfDeleteUserCommand>(); services.AddTransient <IUpdateUserCommand, EfUpdateUserCommand>(); // Roles Block services.AddTransient <IGetRolesCommand, EfGetRolesCommand>(); services.AddTransient <IGetRoleCommand, EfGetRoleCommand>(); var section = Configuration.GetSection("Email"); var sender = new SmtpEmailSender(section["host"], Int32.Parse(section["port"]), section["fromaddress"], section["password"]); services.AddSingleton <IEmailSender>(sender); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "Forum API", Version = "v1" }); var xmlFile = $"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Name}.xml"; c.IncludeXmlComments(System.IO.Path.Combine(AppContext.BaseDirectory, xmlFile)); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddDbContext <WebNewsContext>(); services.AddTransient <IGetArticlesCommand, EfGetArticlesCommand>(); services.AddTransient <IGetArticleCommand, EfGetArticleCommand>(); services.AddTransient <ICreateArticleCommand, EfCreateArticleCommand>(); services.AddTransient <IEditArticleCommand, EfEditArticleCommand>(); services.AddTransient <IDeleteArticleCommand, EfDeleteArticleCommand>(); services.AddTransient <IGetCategoriesCommand, EfGetCategoriesCommand>(); services.AddTransient <IGetCategoryCommand, EfGetCategoryCommand>(); services.AddTransient <ICreateCategoryCommand, EfCreateCategoryCommand>(); services.AddTransient <IEditCategoryCommand, EfEditCategoryCommand>(); services.AddTransient <IDeleteCategoryCommand, EfDeleteCategoryCommand>(); services.AddTransient <IGetCommentsCommand, EfGetCommentsCommand>(); services.AddTransient <IGetCommentCommand, EfGetCommentCommand>(); services.AddTransient <ICreateCommentCommand, EfCreateCommentCommand>(); services.AddTransient <IEditCommentCommand, EfEditCommentCommand>(); services.AddTransient <IDeleteCommentCommand, EfDeleteCommentCommand>(); services.AddTransient <IGetHashtagsCommand, EfGetHashtagsCommand>(); services.AddTransient <IGetHashtagCommand, EfGetHashtagCommand>(); services.AddTransient <ICreateHashtagCommand, EfCreateHashtagCommand>(); services.AddTransient <IEditHashtagCommand, EfEditHashtagCommand>(); services.AddTransient <IDeleteHashtagCommand, EfDeleteHashtagCommand>(); services.AddTransient <IGetRolesCommand, EfGetRolesCommand>(); services.AddTransient <IGetRoleCommand, EfGetRoleCommand>(); services.AddTransient <ICreateRoleCommand, EfCreateRoleCommand>(); services.AddTransient <IEditRoleCommand, EfEditRoleCommand>(); services.AddTransient <IDeleteRoleCommand, EfDeleteRoleCommand>(); services.AddTransient <IGetUsersCommand, EfGetUsersCommand>(); services.AddTransient <IGetUserCommand, EfGetUserCommand>(); services.AddTransient <ICreateUserCommand, EfCreateUserCommand>(); services.AddTransient <IEditUserCommand, EfEditUserCommand>(); services.AddTransient <IDeleteUserCommand, EfDeleteUserCommand>(); var section = Configuration.GetSection("Email"); var sender = new SmtpEmailSender(section["host"], int.Parse(section["port"]), section["fromaddress"], section["password"]); services.AddSingleton <IEmailSender>(sender); }
public void SendEmailTest() { IEmail email = new Email(); email.Tos = new string[] { "*****@*****.**" }; email.Subject = "Prueba de correo"; email.Body = "Esta un una prueba para el envio de correo."; /*La configuración del servidor de correo se encuentra en el webconfig */ ISmtpEmailServerAppConfiguration config = new SmtpEmailServerAppConfiguration(); IEmailServerConfiguration server = new SmtpEmailServerConfiguration(config); IEmailSender sender = new SmtpEmailSender(server); var send = sender.SendEmail(email); Assert.IsTrue(send); }
public SmtpEmailSender_Tests() { var configuration = Substitute.For <ISmtpEmailSenderConfiguration>(); configuration.DefaultFromAddress.Returns("..."); configuration.DefaultFromDisplayName.Returns("..."); configuration.Host.Returns("..."); configuration.Port.Returns(25); //configuration.Domain.Returns("..."); configuration.UserName.Returns("..."); configuration.Password.Returns("..."); //configuration.EnableSsl.Returns(false); //configuration.UseDefaultCredentials.Returns(false); _smtpEmailSender = new SmtpEmailSender(configuration); }
public async Task SendEmailWithAttachmentNotFilenameExtensionKo() { var sender = new SmtpEmailSender(GetService <IOptionsService <SmtpSettings> >()); var bytes = await GetPhotoBinary(); var attachment = new EmailAttachment("Adjunto", bytes); Task Action() { return(sender.SendEmailAsync("*****@*****.**", "Testing con adjunto", "Prueba testing con adjunto", attachment)); } var exception = await Assert.ThrowsAsync <EmailException>(Action); //The thrown exception can be used for even more detailed assertions. Assert.Equal(ExceptionCodes.EMAIL_ATTACH_EXT, exception.Message); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(options => options.AddPolicy("MyCORSPolicy", builder => { builder.WithOrigins("http://localhost:4200") .AllowAnyMethod().AllowAnyHeader(); })); services.AddDbContext <BlogDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("MyConnection"))); services.AddIdentity <User, IdentityRole>().AddEntityFrameworkStores <BlogDbContext>(); services.AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer(options => { var jwtConfig = Configuration.GetSection("JWT"); var symmetricKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtConfig["BaseKey"])); options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidateAudience = true, ValidateIssuerSigningKey = true, ValidIssuer = jwtConfig["Issuer"], ValidAudience = jwtConfig["Audience"], IssuerSigningKey = symmetricKey }; }); var section = Configuration.GetSection("Email"); var sender = new SmtpEmailSender(section["host"], int.Parse(section["port"]), section["fromaddress"], section["password"]); services.AddSingleton <IEmailSender>(sender); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "Web API", Version = "v1" }); }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddScoped <IUnitOfWork, UnitOfWork>(); services.AddMemoryCache(option => option.ExpirationScanFrequency = TimeSpan.FromMinutes(5)); }
private SmtpEmailSender CreateSender(bool isValidEmail, string password = null) { if (string.IsNullOrWhiteSpace(password)) { password = _password; } var mockValidator = new Mock <IEmailValidator>(); mockValidator.Setup(ev => ev.IsValidEmail(It.IsAny <string>())).Returns(isValidEmail); var sender = new SmtpEmailSender( _email, _port, _username, password, mockValidator.Object, _mockLogger.Object ); return(sender); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddDbContext <MyDbContext>(); services.AddTransient <IGetCarsCommand, EfGetCarsCommand>(); services.AddTransient <IGetCarCommand, EfGetCarCommand>(); services.AddTransient <IDeleteCarCommand, EfDeleteCarCommand>(); services.AddTransient <IGetUsersCommand, EfGetUsersCommand>(); services.AddTransient <IGetUserCommand, EfGetUserCommand>(); services.AddTransient <IAddNewUserCommand, EfAddNewUserCommand>(); services.AddTransient <IEditUserCommand, EfEditUserCommand>(); services.AddTransient <IDeleteUserCommand, EfDeleteUserCommand>(); services.AddTransient <IGetBrandsCommand, EfGetBrandsCommand>(); services.AddTransient <IGetTypesCommand, EfGetTypesCommand>(); services.AddTransient <IGetModelsCommand, EfGetModelsCommand>(); services.AddTransient <IGetCategoriesCommand, EfGetCategoriesCommand>(); services.AddTransient <IGetFuelsCommand, EfGetFuelsCommand>(); services.AddTransient <IGetModelsOfBrandCommand, EfGetModelsOfBrandCommand>(); var section = Configuration.GetSection("Email"); var sender = new SmtpEmailSender(section["host"], Int32.Parse(section["port"]), section["fromaddress"], section["password"]); services.AddSingleton <IEmailSender>(sender); }
public void Main(string[] args) { var mail = new SmtpEmailSender("smtp.ym.163.com", 25, "Code Comb", "*****@*****.**", "*****@*****.**", "123456"); mail.SendEmailAsync("*****@*****.**","关于MailSender项目说明", "<html><head><meta http-equiv=\"Content-type\" content=\"text/html;charset=utf-8\"/></head><body>能收到邮件吗</body></html>").Wait(); Console.Read(); }