Problem with Rails Action Mailer

Hi all,

I have a problem with my action mailer .!

When i send mail in the email it shows the html tags same written as in
mailer view html

here is my code:

In the Model :----------------

class CronjobMailer < ActionMailer::Base
def cronjob(sender,recipients, subject, message, late_commers)
   @bcc = recipients
   @recipients = 'support@eabyas.in'
   @from = sender
   @subject = subject
   @late_commers = late_commers
   @sent_on = Time.now
   @body[:message] = message
end
end

:----------------

In the Cronjob_mailer view in cronjob.html.erb

<!DOCTYPE html>
<html>
<head>
   <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
   <h1>Welcome to example.com</h1>
   <p>
     You have successfully signed up to example.com,
     your username is: .<br/>
   </p>
   <p>
     To login to the site, just follow this link: .
   </p>
   <p>Thanks for joining and have a great day!</p>
</body>
</html>

and here is how i am initiating the mailer

CronjobMailer::deliver_cronjob(sender,recipient_list,@subject,@messege,
@late_commers)

when i deliver mail in the email it gives me the same code instead of
html output .

Please help me
Thanks in advance

Rajesh B. wrote in post #1032117:

Hi all,

I have a problem with my action mailer .!

When i send mail in the email it shows the html tags same written as in
mailer view html

and here is how i am initiating the mailer

CronjobMailer::deliver_cronjob(sender,recipient_list,@subject,@messege,
@late_commers)

when i deliver mail in the email it gives me the same code instead of
html output .

Interesting. What version of Rails are you using? I'm still in 3.0 and I
deliver stuff like in the rails guide:

UserMailer.welcome_email(@user).deliver

In your case I would see it like
CronjobMailer.cronjob(sender,recipient_list,@subject,@messege,
@late_commers).deliver have you tried something like that?

I am using rails 2.3.8
Do i require any other gem ?

Rajesh B. wrote in post #1032142:

I am using rails 2.3.8
Do i require any other gem ?

Well it is long time ago since I used Rails 2.3
For sure the Rails guide that I suggested is for Rails 3.0.x and the
mailer logic was changed and improved from 2.3 to 3.0. Many things
changed there.

If you are just starting the project I would recommend upgrading at
least to Rails 3.0 and if you dare even to Rails 3.1 which is the new
beast. If you need to stick to rails 2.3 maybe this is old enough
http://railscasts.com/episodes/61-sending-email

Cheers.

I have added @content_type = 'text/plain' in the mailer method it
worked.

:slight_smile:

I have added @content_type = 'text/html' in the mailer method it
worked.