Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Why can't the block see my variable?
- post "/email/send" do
- @recipient = params[:email]
- Mail.deliver do
- to @recipient # throws error as this is undefined
- from '[email protected]'
- subject 'testing sendmail'
- body 'testing sendmail'
- end
- erb :email_sent
- end
- post "/email/send" do
- Mail.deliver do
- to '[email protected]'
- from '[email protected]'
- subject 'testing sendmail'
- body 'testing sendmail'
- end
- erb :email_sent
- end
- recipient = params[:email]
- Mail.deliver do
- to recipient # 'recipient' is a local variable, not a method, not an instance variable
- ...
- end
- Mail.deliver do
- to @recipient # throws error as this is undefined
- from '[email protected]'
- subject 'testing sendmail'
- body 'testing sendmail'
- end
- Mail.new(
- to: @recipient,
- from: '[email protected]',
- subject: 'testing sendmail',
- body: 'testing sendmail'
- ).deliver!
- Mail.new(
- :to => @recipient,
- :from => '[email protected]',
- :subject => 'testing sendmail',
- :body => 'testing sendmail'
- ).deliver!
- pry(main)> Mail.new(
- pry(main)* to: '[email protected]',
- pry(main)* from: 'me@' << `hostname`.strip,
- pry(main)* subject: 'test mail gem',
- pry(main)* body: 'this is only a test'
- pry(main)* ).deliver!
- => #<Mail::Message:59273220, Multipart: false, Headers: <Date: Fri, 28 Oct 2011 09:01:14 -0700>, <From: [email protected]>, <To: [email protected]>, <Message-ID: <[email protected]>>, <Subject: test mail gem>, <Mime-Version: 1.0>, <Content-Type: text/plain>, <Content-Transfer-Encoding: 7bit>>
- mail = Mail.new
- mail.to = '[email protected]'
- mail[:from] = '[email protected]'
- mail['subject'] = 'This is an email'
- mail.body = 'This is the body'
Add Comment
Please, Sign In to add comment