- (line-orig (smtp 'get-line)))
- (if (string? line-orig)
- (let ((line (string-downcase line-orig)))
- (print "got " line)
- (cond
- ((string-prefix? "helo" line)
- (message-helo-set! msg (string-drop line (string-length "helo")))
- (smtp 'ok)
- (loop msg (smtp 'get-line)))
- ((string-prefix? "mail from:" line)
- (message-from-set! msg (string-drop line (string-length "mail from:")))
- (smtp 'ok)
- (loop msg (smtp 'get-line)))
- ((string-prefix? "rcpt to:" line)
- (message-to-set! msg (string-drop line (string-length "rcpt to:")))
- (smtp 'ok)
- (loop msg (smtp 'get-line)))
- ((string-prefix? "data" line)
- (smtp 'intermediate)
- (let text-loop ((text-line (smtp 'get-line))
- (text ""))
+ (received-messages '()))
+ (let ((line (smtp-session 'get-line)))
+ (when (string? line)
+ (print "got " line)
+ (cond
+ ((smtp-command? "helo" line)
+ (smtp-session 'send "250 ok")
+ (loop msg received-messages))
+ ((smtp-command? "ehlo" line)
+ (smtp-session 'send
+ "250-" (config-host config)
+ " Hello " (smtp-command-args "ehlo" line))
+ (smtp-session 'send "250 AUTH PLAIN")
+ ;; (smtp-session 'send "250 STARTTLS")
+ (loop msg received-messages))
+ ((smtp-command? "auth plain" line)
+ (let* ((auth-string (smtp-command-args "auth plain" line))
+ (auth-decoded (base64-decode auth-string))
+ (auth-list (string-split auth-decoded "\x00"))
+ (user (car auth-list))
+ (password (cadr auth-list)))
+ (smtp-session 'set-user! user)
+ (smtp-session 'set-password! password)
+ (print "Attempted login, user: " user ", password: " password)
+ (smtp-session 'send "235 authentication successful")
+ (loop msg received-messages)))
+ ((smtp-command? "mail from:" line)
+ (message-from-set! msg (smtp-command-args "mail from:" line))
+ (smtp-session 'send "250 ok")
+ (loop msg received-messages))
+ ((smtp-command? "rcpt to:" line)
+ (message-to-set! msg (smtp-command-args "rcpt to:" line))
+ (smtp-session 'send "250 ok")
+ (loop msg received-messages))
+ ((smtp-command? "data" line)
+ (smtp-session 'send "354 intermediate")
+ (let text-loop ((text (conc "Received: from " (smtp-session 'helo)
+ " by " (config-host)
+ " for " (message-from msg)
+ "; " (time-stamp))))
+ (let ((text-line (smtp-session 'get-line)))