I realized that when I send mails(letters) on localhost site via local postfix server, they were sent successfully, but each time I need to include the letter link to my logo stored in:
public/castle.jpg
app/mailers/review_mailer.rb:
class ReviewMailer < ApplicationMailer
default from: 'no-reply@kalinin.ru'
def welcome_email(review)
@review = review
mail(to: 'bla@bla.ru', subject: 'New review create')
end
end
views/review_mailer/welcome_email.html.erb:
<!DOCTYPE html>
<html>
...........................
<p>logo: <%= image_tag 'public/castle.jpg' %></p>
</body>
</html>
application.rb:
config.action_mailer.default_url_options = { host: 'localhost' }
development.rb:
config.action_mailer.raise_delivery_errors = false
config.action_mailer.delivery_method = :sendmail
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
reviews_controller:
def create
@review = current_user.reviews.build(review_params)
if @review.save
ReviewMailer.welcome_email(@review).deliver_now
redirect_to root_path
end
after creating a new review, here is the console output:
ReviewMailer#welcome_email: processed outbound mail in 205.9ms
Sent mail to bla@bla.ru (73.5ms)
Date: Tue, 22 Sep 2015 12:47:11 +0300
From: no-reply@kalinin.ru
To: prozaik81-2@yandex.ru
Message-ID: <5601239fdd0d3_18b43f823a7394382836b@kalinin.mail>
Subject: New review create
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_5601239fdbc22_18b43f823a73943828272";
charset=UTF-8
Content-Transfer-Encoding: 7bit
----==_mimepart_5601239fdbc22_18b43f823a73943828272
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<html>
<body>
<!DOCTYPE html>
<html>
....................
<p>logo: <img src="/images/public/castle.jpg" alt="Castle" /></p>
</body>
</html>
</body>
</html>
----==_mimepart_5601239fdbc22_18b43f823a73943828272--
Redirected to http://localhost:3000/
Completed 302 Found in 601ms (ActiveRecord: 301.4ms)
Mail(letter) is not being sent, what can possibly be wrong?