func (s *Session) Rcpt(to string) error {
	// If running in gateway mode then it will check that the receipient
	// belongs to bitmaelum network
	if s.IsGateway {
		// Check that the mails goes to @bitmaelum.network
		if strings.HasSuffix(to, "@"+config.Bridge.Server.SMTP.Domain) {
			s.To = common.EmailToAddr(to)
			return nil
		}

		logrus.Tracef("SMTP: discarding incoming mail to %s, address is not for ", config.Bridge.Server.SMTP.Domain)
		return errInvalidAddress
	}

	// Check if the recipient is in email format or bitmaelum format
	if !strings.Contains(to, "@") {
		if !strings.HasSuffix(to, "!") {
			return errInvalidDomain
		}
	} else {
		if !strings.HasSuffix(to, "@"+config.Bridge.Server.SMTP.Domain) {
			// If recipient is outside bitmaelum network then send the message to
			// the default gateway address
			if !isEmailValid(to) {
				return errInvalidAddress
			}

			if config.Bridge.Server.SMTP.GatewayAccount == "" {
				s.To = common.DefaultGatewayAccount
			} else {
				s.To = config.Bridge.Server.SMTP.GatewayAccount
			}

			return nil
		}
	}

	s.To = common.EmailToAddr(to)

	return nil
}
// Rcpt is called when doing a "RCPT TO:"
Rcpt is called when doing a "RCPT TO:"
// Rcpt is called when doing a " RCPT TO : "
func (s *Session) Rcpt(to string) error {
	if s.IsGateway {
		if strings.HasSuffix(to, "@"+config.Bridge.Server.SMTP.Domain) {
			s.To = common.EmailToAddr(to)
			return nil
		}
		logrus.Tracef("SMTP: discarding incoming mail to %s, address is not for ", config.Bridge.Server.SMTP.Domain)
		return errInvalidAddress
	}
	if !strings.Contains(to, "@") {
		if !strings.HasSuffix(to, "!") {
			return errInvalidDomain
		}
	} else {
		if !strings.HasSuffix(to, "@"+config.Bridge.Server.SMTP.Domain) {
			if !isEmailValid(to) {
				return errInvalidAddress
			}
			if config.Bridge.Server.SMTP.GatewayAccount == "" {
				s.To = common.DefaultGatewayAccount
			} else {
				s.To = config.Bridge.Server.SMTP.GatewayAccount
			}
			return nil
		}
	}
	s.To = common.EmailToAddr(to)
	return nil
}
func ( s * Session ) Rcpt ( to string ) error { if s . IsGateway { if strings . HasSuffix ( to , " " + config . Bridge . Server . SMTP . Domain ) { s . To = common . EmailToAddr ( to ) return nil } logrus . Tracef ( " " , config . Bridge . Server . SMTP . Domain ) return errInvalidAddress } if ! strings . Contains ( to , " " ) { if ! strings . HasSuffix ( to , " " ) { return errInvalidDomain } } else { if ! strings . HasSuffix ( to , " " + config . Bridge . Server . SMTP . Domain ) { if ! isEmailValid ( to ) { return errInvalidAddress } if config . Bridge . Server . SMTP . GatewayAccount == " " { s . To = common . DefaultGatewayAccount } else { s . To = config . Bridge . Server . SMTP . GatewayAccount } return nil } } s . To = common . EmailToAddr ( to ) return nil }
Rcpt is called when doing a "RCPT TO:"
Rcpt is called when doing a " RCPT TO : "
// If running in gateway mode then it will check that the receipient // belongs to bitmaelum network // Check that the mails goes to @bitmaelum.network // Check if the recipient is in email format or bitmaelum format // If recipient is outside bitmaelum network then send the message to // the default gateway address