{"id":18,"date":"2010-11-15T22:47:35","date_gmt":"2010-11-15T21:47:35","guid":{"rendered":"http:\/\/luciole.local\/~flo\/wordpress\/?p=18"},"modified":"2010-11-15T22:47:35","modified_gmt":"2010-11-15T21:47:35","slug":"envoyer-un-mail-avec-rails","status":"publish","type":"post","link":"https:\/\/sites.lesia.obspm.fr\/florence-henry\/2010\/11\/15\/envoyer-un-mail-avec-rails\/","title":{"rendered":"Envoyer un mail avec Rails"},"content":{"rendered":"<p>Cr\u00e9er un mod\u00e8le de mail\u00a0:<\/p>\n<pre> class Notifier &lt; ActionMailer::Base\n\n  def prevenir_administration(emploi)\n    recipients \"florence.henry@obspm.fr\"\n    bcc        \"\"\n    from       \"florence.henry@obspm.fr\"\n    headers    \"return-path\" =&gt; \"florence.henry@obspm.fr\"\n    headers\t\"reply-to\" =&gt; \"florence.henry@obspm.fr\"\n    subject    \"Offre d'emploi \u00e0 valider\"\n    body      \u00a0:emploi =&gt; emploi\n  end\n\n end\n<\/pre>\n<p>Pour chaque type d&#8217;email, on d\u00e9finit une m\u00e9thode. Dans le champ <code>body<\/code>,  on passe un objet quelconque. Il faut ensuite d\u00e9finir une vue ayant le m\u00eame nom que la m\u00e9thode. Cette  vue sert \u00e0 composer le corps du mail.<\/p>\n<p>Enfin, on envoie le mail en utilisant la m\u00e9thode de classe <code>deliver_methode<\/code>.<\/p>\n<p><a title=\"http:\/\/api.rubyonrails.org\/classes\/ActionMailer\/Base.html\" rel=\"nofollow\" href=\"http:\/\/api.rubyonrails.org\/classes\/ActionMailer\/Base.html\">Lire la doc<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cr\u00e9er un mod\u00e8le de mail\u00a0: class Notifier &lt; ActionMailer::Base def prevenir_administration(emploi) recipients \u00ab\u00a0florence.henry@obspm.fr\u00a0\u00bb bcc \u00ab\u00a0\u00a0\u00bb from \u00ab\u00a0florence.henry@obspm.fr\u00a0\u00bb headers \u00ab\u00a0return-path\u00a0\u00bb =&gt; \u00ab\u00a0florence.henry@obspm.fr\u00a0\u00bb headers \u00ab\u00a0reply-to\u00a0\u00bb =&gt; \u00ab\u00a0florence.henry@obspm.fr\u00a0\u00bb subject \u00ab\u00a0Offre d&#8217;emploi \u00e0 valider\u00a0\u00bb body \u00a0:emploi =&gt; emploi end end Pour chaque type d&#8217;email, on d\u00e9finit une m\u00e9thode. Dans le champ body, on passe un objet quelconque. Il faut [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[9],"class_list":["post-18","post","type-post","status-publish","format-standard","hentry","category-blog","tag-rails"],"_links":{"self":[{"href":"https:\/\/sites.lesia.obspm.fr\/florence-henry\/wp-json\/wp\/v2\/posts\/18","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sites.lesia.obspm.fr\/florence-henry\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sites.lesia.obspm.fr\/florence-henry\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sites.lesia.obspm.fr\/florence-henry\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.lesia.obspm.fr\/florence-henry\/wp-json\/wp\/v2\/comments?post=18"}],"version-history":[{"count":0,"href":"https:\/\/sites.lesia.obspm.fr\/florence-henry\/wp-json\/wp\/v2\/posts\/18\/revisions"}],"wp:attachment":[{"href":"https:\/\/sites.lesia.obspm.fr\/florence-henry\/wp-json\/wp\/v2\/media?parent=18"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sites.lesia.obspm.fr\/florence-henry\/wp-json\/wp\/v2\/categories?post=18"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sites.lesia.obspm.fr\/florence-henry\/wp-json\/wp\/v2\/tags?post=18"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}