Thymeleaf - Configure mail subject in template - thymeleaf

I am using Thymeleaf templates for generating email contents and send using spring mailSender. Is there any option to specify the email subject within the thymeleaf template itself?

You can define fragments in your template and render those parts only.
<div th:fragment="subject">
Mail subject
</div>
<div th:fragment="body">
Mail body
</div>

That's a basic HTML thing
Send mail
you can add also the ?body= if you want to add content in your mail.
Edit: According to your comment, you want to put a input on a page and write a subject and get it in Java.
Put a form with an input in your thymeleaf template and post it to your server, get the value in your controller and use it to send your mail.
Do you need code example for this ?

Related

How does ruby on rails decide the Header[Content-Type] of an email in ActionMailer

I'm currently trying to make a mailer that sends a plain text, so I fill my content in a .txt.erb file. In this case, I assume that the Content-Type is text/plain.
If now I want to use some HTML layout as a signature, (<%= render :partial => '/layouts/mail/signature.html.erb' %> ), and this HTML file contains some img tag. So what is the Content-Type of this email when Rails sending it?
Anything .html.X is assumed to be HTML.
The way the view filename parsing goes is by specifying type (e.g. .html) and then zero or more handlers, like .erb or .haml.
If you want more control over the format there's documentation on how to do that.

Mailboxer html formattting

How can I allow Mailboxer gem to send HTML formatted messages?
For example, I want the first message user A sends to user B to be pre-formatted with certain text and HTML tags. Currently any kind of markup is escaped..
EDIT: My question is basically how can I "patch" the send_message functionality? Or create a new send_message2 that behaves the way I want?

Mandrill - Rules overriding with blank html content

I am very new to Mandrill and whilst trying to use the Rules Engine (via SMTP integration without using Headers, with the incoming email being text), I have configured an open rule that states:
if
sender's email matches scott***#****.com
then
set template to TestTemplate using template block body
but instead of the incoming message being inserted into the body block, as per the following html that's in the TestTemplate
<div mc:edit="header">
<h2>Testing Testing</h2>
</div>
<div mc:edit="**body**" style="color:#000000;">
<h2>123 123</h2>
</div>
<div mc:edit="footer">
Company contact information will go here.
</div>
The 123 123 is being overwritten with blank content i.e. not what's being passed in on the original email message
Any ideas?

Using Render in my .rb file

Hi I have some html in a file called (a partial):
_quotemail.html.erb
I Am sending an email to a user and I want to put this html in the email. I am using mailgun.
I can define my email body like so:
body = "text to go in email"
which works great but I want to instead include the HTML I have in my quotemail partial.
Whats the best way to do this?

How to put a button to action in an email template in RoR

My application sends notification emails to users, I would like to put a button in the email that links to a certain action in a controller?
When I put regular html code (like <input type="button" .... />, I get it in the received email as string, that is, I find the html code in the email) How can I skip this trap?
It's not a perfect idea to send messages as html. By default I turn off html in my email account.
Look this screencast for a beginning: http://railscasts.com/episodes/206-action-mailer-in-rails-3. You just need to specify different view formats: html or text for plain text. But in any case it will rely on reciever email settings which format will be choosen.

Resources