{"id":20458718,"url":"https://github.com/resend/resend-rails-example","last_synced_at":"2025-04-13T05:45:30.854Z","repository":{"id":72519331,"uuid":"583678787","full_name":"resend/resend-rails-example","owner":"resend","description":"Example Rails APP showcasing how to use the Resend Rails SDK with Active Mailer","archived":false,"fork":false,"pushed_at":"2025-04-11T14:15:40.000Z","size":101,"stargazers_count":13,"open_issues_count":12,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T05:45:26.735Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/resend.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-30T14:47:03.000Z","updated_at":"2025-04-11T14:14:50.000Z","dependencies_parsed_at":"2024-02-22T02:33:18.076Z","dependency_job_id":"33f67a32-cf9b-450c-83f3-fea22f996eb7","html_url":"https://github.com/resend/resend-rails-example","commit_stats":null,"previous_names":["resendlabs/resend-rails-example","resend/resend-rails-example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resend%2Fresend-rails-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resend%2Fresend-rails-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resend%2Fresend-rails-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resend%2Fresend-rails-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/resend","download_url":"https://codeload.github.com/resend/resend-rails-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670518,"owners_count":21142901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T12:13:36.855Z","updated_at":"2025-04-13T05:45:30.832Z","avatar_url":"https://github.com/resend.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"This is an example rails app on how to configure and use the [Resend Rails SDK](https://github.com/drish/resend-ruby) with Rails Action Mailer\n\n# Setup\n\nAdd the gem to your Gemfile:\n\n```ruby\n# Gemfile\ngem \"resend\"\n```\n\nCreate a `/config/initializers/mailer.rb` file and add the following configuration line.\n\n```\nResend.api_key = ENV['RESEND_API_KEY']\n```\n\nAdd these lines of code into your environment config file.\n\n```rb\n# Setup resend as the email method\nconfig.action_mailer.delivery_method = :resend\n```\n\nCheckout the [Rails example app with SMTP setup](https://github.com/resendlabs/resend-rails-smtp-example) for SMTP support example.\n\nCreate your mailer class\n\n```ruby\n# /app/mailers/user_mailer.rb\nclass UserMailer \u003c ApplicationMailer\n  default from: 'you@domain.io' # this domain must be verified with Resend\n  def welcome_email\n    @user = params[:user]\n    attachments[\"invoice.pdf\"] = File.read(Rails.root.join(\"resources\",\"invoice.pdf\"))\n    @url  = \"http://example.com/login\"\n    mail(\n      to: [\"to@email.com\"],\n      cc: [\"cc@email.com\"],\n      bcc: [\"cc@email.com\"],\n      reply_to: \"to@email.com\",\n      subject: \"Hello from Rails\",\n    )\n  end\nend\n```\n\nCreate your `ERB Template` for `UserMailer`\n\n```ruby\n# /app/views/welcome_email.html.erb\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cmeta content='text/html; charset=UTF-8' http-equiv='Content-Type' /\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003ch1\u003eWelcome to example.com, \u003c%= @user.name %\u003e\u003c/h1\u003e\n    \u003cp\u003e\n      You have successfully signed up to example.com,\n    \u003c/p\u003e\n    \u003cp\u003e\n      To login to the site, just follow this link: \u003c%= @url %\u003e.\n    \u003c/p\u003e\n    \u003cp\u003eThanks for joining and have a great day!\u003c/p\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\nNow you can send your emails, lets send it using Rails console.\n\n```sh\nbundle exec rails c\n```\n\nInitialize your `UserMailer` class, this should return a `UserMailer` instance.\n\n```ruby\nu = User.new name: \"derich\"\nmailer = UserMailer.with(user: u).welcome_email\n# =\u003e #\u003cMail::Message:153700, Multipart: false, Headers: \u003cFrom: you@domain.io\u003e, \u003cTo: email@example.com, email2@example.com\u003e, \u003cSubject: Hello World\u003e, \u003cMime-Version: 1.0\u003e...\n```\n\nYou can now send emails with:\n\n```ruby\nmailer.deliver_now!\n# =\u003e {:id=\u003e\"a193c81e-9ac5-4708-a569-5caf14220539\", :from=\u003e....}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fresend%2Fresend-rails-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fresend%2Fresend-rails-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fresend%2Fresend-rails-example/lists"}