Hi, i am using ruby 1.8.7 and rails 2.3.3 i can send emails using gmail smtp my config is: ActionMailer::Base.raise_delivery_errors = true ActionMailer::Base.perform_deliveries = true ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.default_charset = ''utf-8'' ActionMailer::Base.smtp_settings = { :enable_starttls_auto => true, :address => "smtp.gmail.com", :port => 587, :domain => "gmail.com", :authentication => :plain, :user_name => "bla-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org", :password => "bla", :default_content_type => "text/html" } I am composing email using tiny mce editor On sending it.. I see it on gmail as <html><p>lndglds</p> <p>sfglfs</p> <p> </p></html> instead of the html rendered. Does any one kno why?
how do you send the email? Is there a controller action that sends the email? On Aug 28, 10:19 am, Ritvvij <ritvi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > i am using ruby 1.8.7 and rails 2.3.3 > i can send emails using gmail smtp > my config is: > > ActionMailer::Base.raise_delivery_errors = true > ActionMailer::Base.perform_deliveries = true > ActionMailer::Base.delivery_method = :smtp > ActionMailer::Base.default_charset = ''utf-8'' > ActionMailer::Base.smtp_settings = { > :enable_starttls_auto => true, > :address => "smtp.gmail.com", > :port => 587, > :domain => "gmail.com", > :authentication => :plain, > :user_name => "b...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org", > :password => "bla", > :default_content_type => "text/html" > > } > > I am composing email using tiny mce editor > On sending it.. > > I see it on gmail as > <html><p>lndglds</p> > <p>sfglfs</p> > <p> </p></html> > > instead of the html rendered. > > Does any one kno why?
Ya,,, Controller Code def sendmail recipient = params[:email][:recipient] subject = params[:email][:subject] message = params[:email][:message] cc = "" Emailer.deliver_contact(recipient, subject, message, "Administrator", cc) if request.xhr? flash[:notice] = ''Error sending message. Please try again later.'' else flash[:notice] = ''Message sent successfully!'' end redirect_to :back rescue flash[:notice] = ''Error sending message. Please try again later.'' redirect_to :back end Which goes to Model code def contact(recipient, subject, message, sent_by, cc, sent_at Time.now) @subject = subject @cc = cc @recipients = recipient @sent_by = sent_by @from = ''no-reply-v7AWNi131Hdg9lCyfuaLCQ@public.gmane.org'' @sent_on = sent_at @body["title"] = ''This is title'' @body["email"] = ''no-reply-v7AWNi131Hdg9lCyfuaLCQ@public.gmane.org'' @body["message"] = message @headers = {} end On Aug 28, 2:11 pm, heimdull <fre...-RCI/mp9mI1I6GGFevw1D/A@public.gmane.org> wrote:> how do you send the email? Is there a controller action that sends the > email? > > On Aug 28, 10:19 am, Ritvvij <ritvi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > > i am using ruby 1.8.7 and rails 2.3.3 > > i can send emails using gmail smtp > > my config is: > > > ActionMailer::Base.raise_delivery_errors = true > > ActionMailer::Base.perform_deliveries = true > > ActionMailer::Base.delivery_method = :smtp > > ActionMailer::Base.default_charset = ''utf-8'' > > ActionMailer::Base.smtp_settings = { > > :enable_starttls_auto => true, > > :address => "smtp.gmail.com", > > :port => 587, > > :domain => "gmail.com", > > :authentication => :plain, > > :user_name => "b...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org", > > :password => "bla", > > :default_content_type => "text/html" > > > } > > > I am composing email using tiny mce editor > > On sending it.. > > > I see it on gmail as > > <html><p>lndglds</p> > > <p>sfglfs</p> > > <p> </p></html> > > > instead of the html rendered. > > > Does any one kno why?
Can anyone please advise on how to send emails in HTML format instead of plain text? On Aug 29, 7:28 pm, Ritvvij <ritvi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Ya,,, > > Controller Code > def sendmail > recipient = params[:email][:recipient] > subject = params[:email][:subject] > message = params[:email][:message] > cc = "" > Emailer.deliver_contact(recipient, subject, message, > "Administrator", cc) > if request.xhr? > flash[:notice] = ''Error sending message. Please try again > later.'' > else > flash[:notice] = ''Message sent successfully!'' > end > redirect_to :back > rescue > flash[:notice] = ''Error sending message. Please try again later.'' > redirect_to :back > end > > Which goes to Model code > > def contact(recipient, subject, message, sent_by, cc, sent_at > Time.now) > @subject = subject > @cc = cc > @recipients = recipient > @sent_by = sent_by > @from = ''no-re...-v7AWNi131Hdg9lCyfuaLCQ@public.gmane.org'' > @sent_on = sent_at > @body["title"] = ''This is title'' > @body["email"] = ''no-re...-v7AWNi131Hdg9lCyfuaLCQ@public.gmane.org'' > @body["message"] = message > @headers = {} > end > > On Aug 28, 2:11 pm, heimdull <fre...-RCI/mp9mI1I6GGFevw1D/A@public.gmane.org> wrote: > > > how do you send the email? Is there a controller action that sends the > > email? > > > On Aug 28, 10:19 am, Ritvvij <ritvi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi, > > > > i am using ruby 1.8.7 and rails 2.3.3 > > > i can send emails using gmail smtp > > > my config is: > > > > ActionMailer::Base.raise_delivery_errors = true > > > ActionMailer::Base.perform_deliveries = true > > > ActionMailer::Base.delivery_method = :smtp > > > ActionMailer::Base.default_charset = ''utf-8'' > > > ActionMailer::Base.smtp_settings = { > > > :enable_starttls_auto => true, > > > :address => "smtp.gmail.com", > > > :port => 587, > > > :domain => "gmail.com", > > > :authentication => :plain, > > > :user_name => "b...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org", > > > :password => "bla", > > > :default_content_type => "text/html" > > > > } > > > > I am composing email using tiny mce editor > > > On sending it.. > > > > I see it on gmail as > > > <html><p>lndglds</p> > > > <p>sfglfs</p> > > > <p> </p></html> > > > > instead of the html rendered. > > > > Does any one kno why?
Next time, try reading the documentation first. From the ActionMailer::Base docs: To send mail as HTML, make sure your view (the .erb file) generates HTML and set the content type to html. class MyMailer < ActionMailer::Base def signup_notification(recipient) recipients recipient.email_address_with_name subject "New account information" from "system-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org" body :account => recipient content_type "text/html" end end --Matt Jones On Aug 30, 8:21 am, Ritvvij <ritvi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Can anyone please advise on how to send emails in HTML format instead > of plain text? > > On Aug 29, 7:28 pm, Ritvvij <ritvi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Ya,,, > > > Controller Code > > def sendmail > > recipient = params[:email][:recipient] > > subject = params[:email][:subject] > > message = params[:email][:message] > > cc = "" > > Emailer.deliver_contact(recipient, subject, message, > > "Administrator", cc) > > if request.xhr? > > flash[:notice] = ''Error sending message. Please try again > > later.'' > > else > > flash[:notice] = ''Message sent successfully!'' > > end > > redirect_to :back > > rescue > > flash[:notice] = ''Error sending message. Please try again later.'' > > redirect_to :back > > end > > > Which goes to Model code > > > def contact(recipient, subject, message, sent_by, cc, sent_at > > Time.now) > > @subject = subject > > @cc = cc > > @recipients = recipient > > @sent_by = sent_by > > @from = ''no-re...-v7AWNi131Hdg9lCyfuaLCQ@public.gmane.org'' > > @sent_on = sent_at > > @body["title"] = ''This is title'' > > @body["email"] = ''no-re...-v7AWNi131Hdg9lCyfuaLCQ@public.gmane.org'' > > @body["message"] = message > > @headers = {} > > end > > > On Aug 28, 2:11 pm, heimdull <fre...-RCI/mp9mI1I6GGFevw1D/A@public.gmane.org> wrote: > > > > how do you send the email? Is there a controller action that sends the > > > email? > > > > On Aug 28, 10:19 am, Ritvvij <ritvi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi, > > > > > i am using ruby 1.8.7 and rails 2.3.3 > > > > i can send emails using gmail smtp > > > > my config is: > > > > > ActionMailer::Base.raise_delivery_errors = true > > > > ActionMailer::Base.perform_deliveries = true > > > > ActionMailer::Base.delivery_method = :smtp > > > > ActionMailer::Base.default_charset = ''utf-8'' > > > > ActionMailer::Base.smtp_settings = { > > > > :enable_starttls_auto => true, > > > > :address => "smtp.gmail.com", > > > > :port => 587, > > > > :domain => "gmail.com", > > > > :authentication => :plain, > > > > :user_name => "b...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org", > > > > :password => "bla", > > > > :default_content_type => "text/html" > > > > > } > > > > > I am composing email using tiny mce editor > > > > On sending it.. > > > > > I see it on gmail as > > > > <html><p>lndglds</p> > > > > <p>sfglfs</p> > > > > <p> </p></html> > > > > > instead of the html rendered. > > > > > Does any one kno why?
Thank you. On Aug 30, 11:41 am, Matt Jones <al2o...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Next time, try reading the documentation first. From the > ActionMailer::Base docs: > > To send mail as HTML, make sure your view (the .erb file) generates > HTML and set the content type to html. > class MyMailer < ActionMailer::Base > def signup_notification(recipient) > recipients recipient.email_address_with_name > subject "New account information" > from "sys...-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org" > body :account => recipient > content_type "text/html" > end > end > > --Matt Jones > > On Aug 30, 8:21 am, Ritvvij <ritvi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Can anyone please advise on how to send emails in HTML format instead > > of plain text? > > > On Aug 29, 7:28 pm, Ritvvij <ritvi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Ya,,, > > > > Controller Code > > > def sendmail > > > recipient = params[:email][:recipient] > > > subject = params[:email][:subject] > > > message = params[:email][:message] > > > cc = "" > > > Emailer.deliver_contact(recipient, subject, message, > > > "Administrator", cc) > > > if request.xhr? > > > flash[:notice] = ''Error sending message. Please try again > > > later.'' > > > else > > > flash[:notice] = ''Message sent successfully!'' > > > end > > > redirect_to :back > > > rescue > > > flash[:notice] = ''Error sending message. Please try again later.'' > > > redirect_to :back > > > end > > > > Which goes to Model code > > > > def contact(recipient, subject, message, sent_by, cc, sent_at > > > Time.now) > > > @subject = subject > > > @cc = cc > > > @recipients = recipient > > > @sent_by = sent_by > > > @from = ''no-re...-v7AWNi131Hdg9lCyfuaLCQ@public.gmane.org'' > > > @sent_on = sent_at > > > @body["title"] = ''This is title'' > > > @body["email"] = ''no-re...-v7AWNi131Hdg9lCyfuaLCQ@public.gmane.org'' > > > @body["message"] = message > > > @headers = {} > > > end > > > > On Aug 28, 2:11 pm, heimdull <fre...-RCI/mp9mI1I6GGFevw1D/A@public.gmane.org> wrote: > > > > > how do you send the email? Is there a controller action that sends the > > > > email? > > > > > On Aug 28, 10:19 am, Ritvvij <ritvi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Hi, > > > > > > i am using ruby 1.8.7 and rails 2.3.3 > > > > > i can send emails using gmail smtp > > > > > my config is: > > > > > > ActionMailer::Base.raise_delivery_errors = true > > > > > ActionMailer::Base.perform_deliveries = true > > > > > ActionMailer::Base.delivery_method = :smtp > > > > > ActionMailer::Base.default_charset = ''utf-8'' > > > > > ActionMailer::Base.smtp_settings = { > > > > > :enable_starttls_auto => true, > > > > > :address => "smtp.gmail.com", > > > > > :port => 587, > > > > > :domain => "gmail.com", > > > > > :authentication => :plain, > > > > > :user_name => "b...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org", > > > > > :password => "bla", > > > > > :default_content_type => "text/html" > > > > > > } > > > > > > I am composing email using tiny mce editor > > > > > On sending it.. > > > > > > I see it on gmail as > > > > > <html><p>lndglds</p> > > > > > <p>sfglfs</p> > > > > > <p> </p></html> > > > > > > instead of the html rendered. > > > > > > Does any one kno why?
Ritvvij wrote:> Can anyone please advise on how to send emails in HTML format instead > of plain text?Just don''t. HTML belongs on Web pages, not in e-mail. (If you really need to, I believe you will have to set a content header on the e-mail so that the HTML is parsed. But there are few good reasons to send HTML mail in the first place.) Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
If you want to send a HTML email have a look at the Rails documentation it is very well documented. Here is a snip: Mailer views are located in the app/views/name_of_mailer_class directory. The specific mailer view is known to the class because it’s name is the same as the mailer method. So for example, in our example from above, our mailer view for the welcome_email method will be in app/views/user_mailer/welcome_email.text.html.erb for the HTML version and welcome_email.text.plain.erb for the plain text version. The action mailer basics should have all you need... http://guides.rubyonrails.org/action_mailer_basics.html But the short version is in the naming of the views text.html.erb and text.plain.erb and then you have the content_type that can be set too "text/html", Rails send multipart emails if you have a text and html view.