# Question on creating small mailing list within large applica

**URL:** <https://www.ruby-forum.com/t/question-on-creating-small-mailing-list-within-large-applica/91330>\
**Category:** Rails\
**Created:** [April 6, 2007, 9:23pm UTC](https://www.ruby-forum.com/t/question-on-creating-small-mailing-list-within-large-applica/91330 "2007-04-06T21:23:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![steve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://www.ruby-forum.com/u/steve)\
**Post date:** [April 6, 2007, 9:23pm UTC](https://www.ruby-forum.com/t/question-on-creating-small-mailing-list-within-large-applica/91330/1 "2007-04-06T21:23:18Z")

</div>

I am relatively new to Ruby on Rails and so I am finding myself stuck  
on an issue for a web site I am currently designing.

I would like to create a simple mailing list form that just sends the  
information from the form fields straight to an email account. I want  
this form to be inside of a larger application which is much like a  
blog. What is the best way of going about this?

---

<div class="post-metadata">

**Author:** ![steve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://www.ruby-forum.com/u/steve)\
**Post date:** [April 6, 2007, 10:12pm UTC](https://www.ruby-forum.com/t/question-on-creating-small-mailing-list-within-large-applica/91330/2 "2007-04-06T22:12:23Z")

</div>

Rails has a built in mailing mechanism known as ActionMailer… there  
are  
TONS of good resources on setting this up correctly, and I’ll leave that  
part to our friend Google.

Basically, you can do this two ways: set up this form, and have it post  
to  
an action that takes the information, sends it over to your already set  
up  
action mailer, and then redirects you to a page telling you your mail  
was  
succesfully sent. However, if you don’t want to interrupt the flow of  
your  
program to much, this is an almost perfect use case for getting into  
some  
AJAX. Simply have the submit button on your form use AJAX instead of a  
regular submit, and it will do all the mailing in the background, and  
then  
come back and tell your page that it is done mailing.

If you’re talking about having the same form perform more than one  
action  
(such as, when they click on post to post a blog entry, it also sends an  
email), it is simple to have your action you are sending the blog post  
information to also create an email out of what you have sent… in the  
application I’m currently working on, we use the wonderful Rails method  
render\_to\_string to accomplish this, as that allows us to even use a  
view,  
layout, etc just like normal, and pass the resulting nicely formatted  
HTML  
stuff off to an action mailer.

---

<div class="post-metadata">

**Author:** ![steve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://www.ruby-forum.com/u/steve)\
**Post date:** [April 6, 2007, 11:32pm UTC](https://www.ruby-forum.com/t/question-on-creating-small-mailing-list-within-large-applica/91330/3 "2007-04-06T23:32:31Z")

</div>

Thanks Luke
