Closed lispstudent closed 2 years ago
Hi.
I don't think it is necessary to add that to demo, as it is unrelated to cl-forms. But we can discuss it here if you want.
For what you want to do, you have to fetch the form data, then render it in an email, using some template system.
For example, using cl-template:
Define a template for the email:
(defparameter *email-template*
(cl-template:compile-template "Hello <%= (@ username) %>.
<%= (@ message) %>"))
Let say the form has username and email:
(forms:defform user-form ()
((username :string)
(email :email)))
Handle the form, use form values for rendering the email contents, and send the email:
(let ((user-form (forms:find-form 'user-form)))
(forms:handle-form user-form)
(forms:with-form-field-values (username email) user-form
(let ((email-contents (funcall *email-template* (list :username username :message "Have a nice day"))))
(cl-smtp:send-email "host" "from" email "Hello subject" email-contents)))
Does that help?
Thank you, this helps a lot, not only for pointing to the the right direction. It is instructive to see how you dealt with the issue which it was my main roadblock.
I did not know about cl-template. It was mentioned to be impartial, and not referring to ten or djula
?
Are those much different from cl-template? As a beginner, do I understand correctly I would better start using cl-template
?
Thank you again, very much for your time and the clarity of your help.
There's no better or worse here. You can use whatever template system fits your problem better. For an email template, perhaps it is simple enough to maintain it in a string in your lisp files; you may not need Djula's more advanced features, like inheritance, etc. If you like Djula or Ten more, then go for it.
Cheers,
Thank you, much obliged.
Please, feel free to close this issue, or I can if you wish.
Thank you for
cl-forms
, this is exactly what I have been looking for.I am able to have a contact form rendered. Now I would like to mail the form via SMTP client, but, as a beginner, I have no clue on the next step.
I know this is not part of
cl-forms
, but would it be possible at all to add this action to the demo part, so I can learn?There would be no need to add a dependency to e.g. cl-smtp, just a way to use the system SMTP client, via OS call?
Thank you for considering this!