public IEnumerable <IMailReference> GetAllMailForDomain(string domain) { return(References.Where( r => string.Equals( MailUtilities.GetDomainFromMailbox(r.Recipients[0]), domain, StringComparison.OrdinalIgnoreCase))); }
private string GetFolderPath(string mailbox, string folder, string status) { // Turn foo/bar into .foo.bar, because that's what maildir says string folderPart = string.Join( "", folder.Split(FolderSeparator, StringSplitOptions.RemoveEmptyEntries) .Select(s => "." + s) .ToArray() ); var nameFromMailbox = MailUtilities.GetNameFromMailbox(mailbox); return(Path.Combine( _settings.MailLocalPath, MailUtilities.GetDomainFromMailbox(mailbox), StripExtension(nameFromMailbox), folderPart, status)); }
public IEnumerable <string> GetAllPendingDomains() { return(References.Select(r => MailUtilities.GetDomainFromMailbox(r.Recipients[0])).Distinct()); }
public override Task ExecuteAsync(CancellationToken token) { if (_builder.PendingMail != null) { return(_channel.SendReplyAsync(SmtpReplyCode.BadSequence, "MAIL not allowed now", CancellationToken.None)); } Match fromMatch = s_fromExpression.Match(Arguments); if (!fromMatch.Success) { return(_channel.SendReplyAsync( SmtpReplyCode.InvalidArguments, "Bad FROM address", CancellationToken.None)); } string sourceRoute = fromMatch.Groups[1].Value; string mailbox = fromMatch.Groups[2].Value; string parameterText = fromMatch.Groups[3].Value; if (!string.IsNullOrEmpty(sourceRoute)) { return(_channel.SendReplyAsync( SmtpReplyCode.InvalidArguments, "Return path not supported", CancellationToken.None)); } if (!TryProcessParameterValue(_channel, parameterText, out Task errorReport, token)) { return(errorReport); } if (_channel.IsAuthenticated && !_userStore.CanUserSendAs(_channel.AuthenticatedUser, mailbox)) { return(_channel.SendReplyAsync(SmtpReplyCode.MailboxUnavailable, "Invalid Mailbox", token)); } if (!_channel.IsAuthenticated && _settings.LocalDomains?.Any( d => string.Equals( d.Name, MailUtilities.GetDomainFromMailbox(mailbox), StringComparison.OrdinalIgnoreCase) ) == true ) { return(_channel.SendReplyAsync( SmtpReplyCode.InvalidArguments, "Must be signed in to send from domain", token)); } _builder.PendingMail = new SmtpMailMessage( new SmtpPath( mailbox)); return(_channel.SendReplyAsync(SmtpReplyCode.Okay, token)); }