January 2010
2 posts
4 tags
Send mail with attachment via ruby SMTP
Vediamo come inviare una mail con allegato usando l’API di Ruby per SMTP.
Di seguito il codice:
def send_newsletter
body = "Testo del messaggio"
filecontent = File.read("allegato.pdf")
encodedcontent = [filecontent].pack("m") # base64
marker = "AUNIQUEMARKER"
# Define the main headers.
part1 =<<EOF
From: from@mail.com <Pioz>
To: <to@mail.it>
Subject: Oggetto...
Inline RJS on controller
Beh, renderizziamo un rjs direttamente dal controller… easy:
def index
@polli = Polli.all
render(:update) { |page| page.alert('Yeah') }
end