Created
March 25, 2011 23:11
-
-
Save andrellima/887828 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SendMail < ActionMailer::Base | |
def contact(nome, fone, email, assunto, corpo) | |
recipients '[email protected]' | |
from "SITE: | |
subject assunto | |
sent_on Time.now | |
content_type "text/html" | |
@nome = nome | |
@email = email | |
@fone = fone | |
@corpo = corpo | |
template "entrar_em_contato" | |
end | |
def franquia(email, sexo, nome, nascimento, telefone, celular, outro_telefone, endereco, pais, uf, cidade_de_interesse, capital_de_investimento, mensagem) | |
recipients '[email protected]' | |
from "SITE: " | |
subject 'CADASTRO DE FRANQUIAS' | |
sent_on Time.now | |
content_type "text/html" | |
@email = email | |
@sexo = sexo | |
@nome = nome | |
@nascimento = nascimento | |
@telefone = telefone | |
@celular = celular | |
@outro_telefone = outro_telefone | |
@endereco = endereco | |
@pais = pais | |
@uf = uf | |
@cidade_de_interesse = cidade_de_interesse | |
@capital_de_investimento = capital_de_investimento | |
@mensagem = mensagem | |
template "cadastro_franquia" | |
end | |
end | |
config.action_mailer.delivery_method = :smtp | |
ActionMailer::Base.smtp_settings = { | |
:address => "smtp.gmail.com", | |
:port => 587, | |
:domain => "localhost", | |
:user_name => "user", | |
:password => "pas", | |
:authentication => "plain", | |
:enable_starttls_auto => true | |
} | |
ActionMailer::Base.default_url_options[:host] = "localhost:3000" | |
class PublicController < ApplicationController | |
def contact | |
render :partial => 'formulario_contato' | |
end | |
def send_contact | |
nome = params[:contato]['nome'] | |
fone = params[:contato]['telefone'] | |
email = params[:contato]['email'] | |
assunto = params[:contato]['assunto'] | |
corpo = params[:contato]['corpo'] | |
UserMailer.contact(nome, fone, email, assunto, corpo).deliver | |
render :text => '<h1> Formulário enviado com sucesso </h1>' | |
end | |
def cadastro_franquia | |
render :partial => 'formulario_franquias' | |
end | |
def send_cadastro_franquia | |
email = params[:franquia_cadastro]['email'] | |
sexo = params[:franquia_cadastro]['sexo'] | |
nome = params[:franquia_cadastro]['nome'] | |
nascimento = params[:franquia_cadastro]['nascimento'] | |
telefone = params[:franquia_cadastro]['telefone'] | |
celular = params[:franquia_cadastro]['celular'] | |
outro_telefone = params[:franquia_cadastro]['outro_telefone'] | |
endereco = params[:franquia_cadastro]['endereco'] | |
pais = params[:franquia_cadastro]['pais'] | |
uf = params[:franquia_cadastro]['uf'] | |
cidade_de_interesse = params[:franquia_cadastro]['cidade_de_interesse'] | |
capital_de_investimento = params[:franquia_cadastro]['capital_de_investimento'] | |
mensagem = params[:franquia_cadastro]['mensagem'] | |
UserMailer.franquia(email, sexo, nome, nascimento, telefone, celular, outro_telefone, endereco, pais, uf, cidade_de_interesse, capital_de_investimento, mensagem).deliver | |
render :text => '<h1> Formulário enviado com sucesso </h1>' | |
end | |
def contact_sent | |
render :text => '<h1> Formulário enviado com sucesso </h1>' | |
end | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="" method="get"> | |
<div class="item_form" style="width:480px;"> | |
Nome:<br /> | |
<input name="contato[nome]" type="text" style="width:480px;"/> | |
</div> | |
<div class="item_form" style="width:480px;"> | |
Email:<br /> | |
<input name="contato[email]" type="text" style="width:480px;"/> | |
</div> | |
<div class="item_form" style="width:480px;"> | |
Telefone:<br /> | |
<input name="contato[telefone]" type="text" style="width:480px;"/> | |
</div> | |
<div class="item_form" style="width:480px;"> | |
Assunto:<br /> | |
<input name="contato[assunto]" type="text" style="width:480px;"/> | |
</div> | |
<div class="item_form" style="width:480px;"> | |
Mensagem: | |
<textarea style="width:480px; height: 100px;" name="contato[corpo]"></textarea> | |
</div> | |
<%= submit_to_remote 'send', 'Enviar', :url => { :action => 'send_contact' }, | |
:before => "$('load_form_contato').show();", | |
:update => { :success => "ajax_form_contato", :failure => "fail" }, :html => {:class => 'btn'} %> | |
<%= submit_to_remote 'clear', 'Limpar', :url => { :action => 'contact' }, | |
:before => "$('load_form_contato').show();", | |
:update => { :success => "ajax_form_contato", :failure => "fail" }, :html => {:class => 'btn', :style => 'padding-left: 10px;'} %> | |
</form> | |
<div style="position: absolute; margin-left: 550px; margin-top: -200px; display: none;" id="load_form_contato"> | |
<img src="/images/loading.gif" /> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment