Created
July 8, 2016 18:47
-
-
Save davidleandro/2f97fe11be3147eade56fcf9f524fe66 to your computer and use it in GitHub Desktop.
Add mailer to a Ruby on rails project
This file contains 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
// -------------- | |
// DONT FORGET TO CHANGE THE COLORS AND BRAND URL AND SAVE BRAND IMAGE IN PUBLIC FOLDER | |
// -------------- | |
// -------------------------------------- | |
// # FONTS | |
// -------------------------------------- | |
@import url(http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300|Open+Sans:400italic,300,600,400) | |
$font-base: 'Open Sans', 'sans-serif' | |
$font-base-condensed: 'Open Sans Condensed', 'sans-serif' | |
// -------------------------------------- | |
// # COLORS | |
// -------------------------------------- | |
$color-gray: #666566 | |
$color-primary: #EB5D40 | |
$color-light-gray: #F7F5F5 | |
$color-light: #FFF | |
// -------------------------------------- | |
// # BASE | |
// -------------------------------------- | |
body | |
margin: 0 | |
.mailer | |
h1,h2,h3,h4,h5,h6, p, a | |
font-family: $font-base | |
font-weight: 100 | |
margin: 0 | |
h1 | |
border-bottom: solid 1px $color-primary | |
color: $color-gray | |
display: inline-block | |
font-family: $font-base-condensed | |
font-size: 53px | |
font-weight: 100 | |
margin-bottom: 23px | |
padding: 0 10px 0 0 | |
h2 | |
font-size: 22px | |
font-weight: 300 | |
h3 | |
font-size: 20px | |
font-weight: 600 | |
line-height: 22px | |
h6 | |
font-size: 12px | |
margin-top: 50px | |
text-align: center | |
span | |
color: $color-primary | |
p | |
font-size: 16px | |
.button | |
background-image: -webkit-linear-gradient(0deg, darken($color-primary, 10%) 0%, $color-primary 50%) | |
background-image: linear-gradient(0deg, darken($color-primary, 10%) 0%, $color-primary 50%) | |
box-shadow: 0px 2px 0px $color-light-gray | |
box-sizing: content-box | |
color: $color-light | |
display: block | |
font-size: 18px | |
height: 22px | |
line-height: 22px | |
margin: 0 auto | |
padding: 5px 20px | |
text-align: center | |
text-decoration: none | |
width: 415px | |
.container | |
width: 750px | |
margin: 0 auto | |
padding: 0 40px | |
.row | |
padding: 45px 0 | |
ul | |
list-style-type: none | |
padding: 0 0 40px | |
li | |
margin-bottom: 25px | |
overflow: hidden | |
p | |
width: 165px | |
float: left | |
h3, .text | |
width: 498px | |
float: left | |
img | |
max-width: 690px | |
.text | |
width: 485px | |
background: $color-light-gray | |
color: $color-gray | |
font-size: 14px | |
line-height: 18px | |
padding: 30px | |
font-style: italic | |
p | |
width: 100% | |
p+p | |
margin-bottom: 20px | |
.button | |
width: 100px | |
margin-left: 165px | |
.footer | |
width: 100% | |
height: 93px | |
background: $color-gray | |
overflow: hidden | |
.brand | |
display: block | |
width: 98px | |
height: 67px | |
margin: 28px auto | |
background: url("http://COMPANYNAME.COM.BR/image.png") bottom center no-repeat | |
background-size: contain |
This file contains 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
# -------------- | |
# DONT FORGET TO CHANGE THE COMPANYNAME AND EMAIL | |
# -------------- | |
class UserMailer < ActionMailer::Base | |
default from: 'COMPANYNAME <MAIL@COMPANYNAME.COM.BR>' | |
def _create_user(user) | |
@user = user | |
mail( to: @user.email, subject: 'SUBJECT') | |
end | |
end |
This file contains 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
// -------------- | |
// DONT FORGET TO CHANGE EMAIL AND BODY MESSAGE | |
// -------------- | |
doctype 5 | |
html | |
head | |
= stylesheet_link_tag 'contact_mailer' | |
body | |
.mailer | |
.container | |
.row | |
h1 Obrigado por cadastrar em nosso site! | |
h2 Olá #{@user.name}, muito obrigado por cadastrar em nosso site. Esperamos goste da nossa plataforma. | |
.row | |
= link_to 'Clique aqui e acesse o nosso site', root_url, class: 'button', target: 'blank' | |
h6 Dúvidas ou problemas? Entre em contato. <span>MAIL@COMPANYNAME.COM.BR</span> | |
.footer | |
.brand |
This file contains 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
# -------------- | |
# ADD PRECOMPILE AND RESTART THE SERVER | |
# -------------- | |
config.assets.precompile += %w(contact_mailer.css) |
This file contains 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
# -------------- | |
# DONT FORGET TO CHANGE THE COMPANYNAME.COM.BR, MAIL AND PASSWORD | |
# -------------- | |
ActionMailer::Base.asset_host = 'http://COMPANYNAME.COM.BR' | |
ActionMailer::Base.default_url_options = { host: 'COMPANYNAME.COM.BR' } | |
ActionMailer::Base.smtp_settings = { | |
address: 'smtp.gmail.com', | |
port: 587, | |
authentication: :plain, | |
domain: 'COMPANYNAME.COM.BR', | |
user_name: 'MAIL@COMPANYNAME.COM.BR', | |
password: 'MYPASSWORD', | |
enable_starttls_auto: true | |
} |
This file contains 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
# -------------- | |
# Call UserMailer | |
# -------------- | |
UserMailer._create_user(@user).deliver |
This file contains 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
# -------------- | |
# REMOVE ROADIE AND ADD PREMAILER | |
# -------------- | |
- gem 'roadie', '~> 2.4.3' | |
+ gem 'premailer-rails' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment