SlideShare a Scribd company logo
Action Mailer  Action Mailer is the Rails component that enables applications to send and receive e-mail. In this chapter we will see how to send an email using Rails. So lets start with creating a emails project using following command. C:ubyamp;gt; rails emails This will create required framework to proceed. Now we will start with configuring Action Mailer. Action Mailer - Configuration Following are the steps you have to follow to complete your configuration before proceeding with actual work: Go into config folder of your emails project and open environment.rb file and add the following line at the bottom of this file. ActionMailer::Base.delivery_method = :smtp
This tells ActionMailer that you want to user SMTP server. You can also set it to be :sendmail if you are using a Unix-based operating system such as Mac OS X or Linux. Add the following lines of code to the bottom of your environment.rb as well. ActionMailer::Base.server_settings = {    :address => "smtp.site.com",    :port => 25,    :domain => “site.com",    :authentication => :login,    :user_name => "username",    :password => "password", } Replace each hash value with proper settings for your Simple Mail Transfer Protocol (SMTP) server. You can take this information from your Internet Service Provider if you already don't know. You don't need to change port number 25 and authentication type if you are using standard SMTP server. You may also change the default email message format. If you prefer to send email in HTML instead of plain text format, add the following line to config/environment.rb as well:
ActionMailer::Base.default_content_type = "text/html" ActionMailer::Base.default_content_type could be set to "text/plain", "text/html", and "text/enriched". The default value is "text/plain". Next step will be to create a mailer Generate a mailer: Use the following command to generate a mailer as follows: C:ubyamp;gt; cd emails C:ubymails> ruby script/generate mailer Emailer This will create a file emailer.rb in appodels directory. Check the content of this file is as follows:
class Emailer < ActionMailer::Base end Let's create one method as follows. class Emailer < ActionMailer::Base    def contact(recipient, subject, message, sent_at = Time.now)       @subject = subject       @recipients = recipient       @from = 'no-reply@yourdomain.com'       @sent_on = sent_at 	  @body["title"] = 'This is title'   	  @body["email"] = 'sender@yourdomain.com'    	  @body["message"] = message end end The contact method has four parameters a recipient, subject, message and a sent_at, which defines when the e-mail is sent. The method also defines six standard parameters that are a part of every ActionMailer method:
[object Object]
 @body is a Ruby hash that contains values with which you can populate the mail template. You created three key-value pairs: title, email, and message
 @recipients is a list of the people to whom the message is being sent.

More Related Content

What's hot

Day3_Part 2_Apache_JMeter_Config_Elements
Day3_Part 2_Apache_JMeter_Config_ElementsDay3_Part 2_Apache_JMeter_Config_Elements
Day3_Part 2_Apache_JMeter_Config_Elements
Sravanthi N
 
1and1Mail Advanced Features - Auto IP Switcher
1and1Mail Advanced Features - Auto IP Switcher1and1Mail Advanced Features - Auto IP Switcher
1and1Mail Advanced Features - Auto IP Switcher
YeteSoft
 
Messaging APIs of RingCentral
Messaging APIs of RingCentralMessaging APIs of RingCentral
Messaging APIs of RingCentral
Anirban Sen Chowdhary
 
Sending mail in mule
Sending mail in muleSending mail in mule
Sending mail in mule
Son Nguyen
 
Inbound Email Troubleshooting Guide
Inbound Email Troubleshooting GuideInbound Email Troubleshooting Guide
Inbound Email Troubleshooting Guide
guestc1eed9
 
1and1Mail Advanced Features - Auto Remove Bounced and Unsubscribed
 1and1Mail Advanced Features - Auto Remove Bounced and Unsubscribed 1and1Mail Advanced Features - Auto Remove Bounced and Unsubscribed
1and1Mail Advanced Features - Auto Remove Bounced and Unsubscribed
YeteSoft
 
1and1Mail Quickstart Guide - View Reports
1and1Mail Quickstart Guide - View Reports1and1Mail Quickstart Guide - View Reports
1and1Mail Quickstart Guide - View Reports
YeteSoft
 
1and1Mail Quickstart Guide - SMTP Account Setup
1and1Mail Quickstart Guide - SMTP Account Setup1and1Mail Quickstart Guide - SMTP Account Setup
1and1Mail Quickstart Guide - SMTP Account Setup
YeteSoft
 
Input and output flow using file to string and logger component
Input and output flow using file to string and logger componentInput and output flow using file to string and logger component
Input and output flow using file to string and logger component
Son Nguyen
 
Bloom links
Bloom linksBloom links
Bloom links
viet nghiem
 
MarvelSoft email hosting guide
MarvelSoft email hosting guideMarvelSoft email hosting guide
MarvelSoft email hosting guide
Ranganath Shivaram
 
Setting emails on android
Setting emails on androidSetting emails on android
Setting emails on androidWasim Ismail
 
JSP diana y yo
JSP diana y yoJSP diana y yo
JSP diana y yo
michael
 
Login With External Accounts In Odoo
Login With External Accounts In OdooLogin With External Accounts In Odoo
Login With External Accounts In Odoo
Anisha Technaureus
 
Winter '19 release development.ppt
Winter '19 release development.pptWinter '19 release development.ppt
Winter '19 release development.ppt
Kailas Shimpi
 

What's hot (16)

Day3_Part 2_Apache_JMeter_Config_Elements
Day3_Part 2_Apache_JMeter_Config_ElementsDay3_Part 2_Apache_JMeter_Config_Elements
Day3_Part 2_Apache_JMeter_Config_Elements
 
1and1Mail Advanced Features - Auto IP Switcher
1and1Mail Advanced Features - Auto IP Switcher1and1Mail Advanced Features - Auto IP Switcher
1and1Mail Advanced Features - Auto IP Switcher
 
Messaging APIs of RingCentral
Messaging APIs of RingCentralMessaging APIs of RingCentral
Messaging APIs of RingCentral
 
Sending mail in mule
Sending mail in muleSending mail in mule
Sending mail in mule
 
Inbound Email Troubleshooting Guide
Inbound Email Troubleshooting GuideInbound Email Troubleshooting Guide
Inbound Email Troubleshooting Guide
 
1and1Mail Advanced Features - Auto Remove Bounced and Unsubscribed
 1and1Mail Advanced Features - Auto Remove Bounced and Unsubscribed 1and1Mail Advanced Features - Auto Remove Bounced and Unsubscribed
1and1Mail Advanced Features - Auto Remove Bounced and Unsubscribed
 
1and1Mail Quickstart Guide - View Reports
1and1Mail Quickstart Guide - View Reports1and1Mail Quickstart Guide - View Reports
1and1Mail Quickstart Guide - View Reports
 
1and1Mail Quickstart Guide - SMTP Account Setup
1and1Mail Quickstart Guide - SMTP Account Setup1and1Mail Quickstart Guide - SMTP Account Setup
1and1Mail Quickstart Guide - SMTP Account Setup
 
Input and output flow using file to string and logger component
Input and output flow using file to string and logger componentInput and output flow using file to string and logger component
Input and output flow using file to string and logger component
 
Ssi
SsiSsi
Ssi
 
Bloom links
Bloom linksBloom links
Bloom links
 
MarvelSoft email hosting guide
MarvelSoft email hosting guideMarvelSoft email hosting guide
MarvelSoft email hosting guide
 
Setting emails on android
Setting emails on androidSetting emails on android
Setting emails on android
 
JSP diana y yo
JSP diana y yoJSP diana y yo
JSP diana y yo
 
Login With External Accounts In Odoo
Login With External Accounts In OdooLogin With External Accounts In Odoo
Login With External Accounts In Odoo
 
Winter '19 release development.ppt
Winter '19 release development.pptWinter '19 release development.ppt
Winter '19 release development.ppt
 

Similar to Action Mailer

Laravel mail example how to send an email using markdown template in laravel 8
Laravel mail example how to send an email using markdown template in laravel 8Laravel mail example how to send an email using markdown template in laravel 8
Laravel mail example how to send an email using markdown template in laravel 8
Katy Slemon
 
Send Email In Asp.Net
Send Email In Asp.NetSend Email In Asp.Net
Send Email In Asp.Net
Inayat Ali Jan
 
Send email
Send emailSend email
Send email
Joselito Catanes
 
Setting up your own email server with hmailserver
Setting up your own email server with hmailserverSetting up your own email server with hmailserver
Setting up your own email server with hmailserver
rifqirr
 
Working with data.pptx
Working with data.pptxWorking with data.pptx
Working with data.pptx
SherinRappai
 
Task scheduling in laravel 8 tutorial
Task scheduling in laravel 8 tutorialTask scheduling in laravel 8 tutorial
Task scheduling in laravel 8 tutorial
Katy Slemon
 
Php forms and validations by naveen kumar veligeti
Php forms and validations by naveen kumar veligetiPhp forms and validations by naveen kumar veligeti
Php forms and validations by naveen kumar veligeti
Naveen Kumar Veligeti
 
AWS SES
AWS SESAWS SES
AWS SES
Vmoksha Admin
 
Article marketing robot_instructions_how_to
Article marketing robot_instructions_how_toArticle marketing robot_instructions_how_to
Article marketing robot_instructions_how_totimegates
 
Php Mysql Feedrss
Php Mysql FeedrssPhp Mysql Feedrss
Php Mysql FeedrssRCS&RDS
 
Install iRedMail on Red Hat Enterprise Linux, CentOS
Install iRedMail on Red Hat Enterprise Linux, CentOSInstall iRedMail on Red Hat Enterprise Linux, CentOS
Install iRedMail on Red Hat Enterprise Linux, CentOS
InfoExcavator
 
Install iRedMail on Red Hat Enterprise Linux, CentOS
Install iRedMail on Red Hat Enterprise Linux, CentOSInstall iRedMail on Red Hat Enterprise Linux, CentOS
Install iRedMail on Red Hat Enterprise Linux, CentOS
Md Meherab Hossen
 
Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP yucefmerhi
 
How to simplify Email oriented workflow with - Visendo SMTP Extender
How to simplify Email oriented workflow with - Visendo SMTP Extender How to simplify Email oriented workflow with - Visendo SMTP Extender
How to simplify Email oriented workflow with - Visendo SMTP Extender
Johannes Cosmin dumitru
 
Validate Email with JavaScript.pdf
Validate Email with JavaScript.pdfValidate Email with JavaScript.pdf
Validate Email with JavaScript.pdf
EmailConcern
 
Email Router Configuration - Gmail and microsoft dynamics crm 2016 online int...
Email Router Configuration - Gmail and microsoft dynamics crm 2016 online int...Email Router Configuration - Gmail and microsoft dynamics crm 2016 online int...
Email Router Configuration - Gmail and microsoft dynamics crm 2016 online int...
Naveen Kumar
 
Merb
MerbMerb

Similar to Action Mailer (20)

Ruby
RubyRuby
Ruby
 
Laravel mail example how to send an email using markdown template in laravel 8
Laravel mail example how to send an email using markdown template in laravel 8Laravel mail example how to send an email using markdown template in laravel 8
Laravel mail example how to send an email using markdown template in laravel 8
 
Lecture19
Lecture19Lecture19
Lecture19
 
Send Email In Asp.Net
Send Email In Asp.NetSend Email In Asp.Net
Send Email In Asp.Net
 
Send email
Send emailSend email
Send email
 
Setting up your own email server with hmailserver
Setting up your own email server with hmailserverSetting up your own email server with hmailserver
Setting up your own email server with hmailserver
 
Working with data.pptx
Working with data.pptxWorking with data.pptx
Working with data.pptx
 
Lecture19
Lecture19Lecture19
Lecture19
 
Task scheduling in laravel 8 tutorial
Task scheduling in laravel 8 tutorialTask scheduling in laravel 8 tutorial
Task scheduling in laravel 8 tutorial
 
Php forms and validations by naveen kumar veligeti
Php forms and validations by naveen kumar veligetiPhp forms and validations by naveen kumar veligeti
Php forms and validations by naveen kumar veligeti
 
AWS SES
AWS SESAWS SES
AWS SES
 
Article marketing robot_instructions_how_to
Article marketing robot_instructions_how_toArticle marketing robot_instructions_how_to
Article marketing robot_instructions_how_to
 
Php Mysql Feedrss
Php Mysql FeedrssPhp Mysql Feedrss
Php Mysql Feedrss
 
Install iRedMail on Red Hat Enterprise Linux, CentOS
Install iRedMail on Red Hat Enterprise Linux, CentOSInstall iRedMail on Red Hat Enterprise Linux, CentOS
Install iRedMail on Red Hat Enterprise Linux, CentOS
 
Install iRedMail on Red Hat Enterprise Linux, CentOS
Install iRedMail on Red Hat Enterprise Linux, CentOSInstall iRedMail on Red Hat Enterprise Linux, CentOS
Install iRedMail on Red Hat Enterprise Linux, CentOS
 
Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP
 
How to simplify Email oriented workflow with - Visendo SMTP Extender
How to simplify Email oriented workflow with - Visendo SMTP Extender How to simplify Email oriented workflow with - Visendo SMTP Extender
How to simplify Email oriented workflow with - Visendo SMTP Extender
 
Validate Email with JavaScript.pdf
Validate Email with JavaScript.pdfValidate Email with JavaScript.pdf
Validate Email with JavaScript.pdf
 
Email Router Configuration - Gmail and microsoft dynamics crm 2016 online int...
Email Router Configuration - Gmail and microsoft dynamics crm 2016 online int...Email Router Configuration - Gmail and microsoft dynamics crm 2016 online int...
Email Router Configuration - Gmail and microsoft dynamics crm 2016 online int...
 
Merb
MerbMerb
Merb
 

More from SHC

Perform brute force
Perform brute forcePerform brute force
Perform brute force
SHC
 
AJAX ASP.Net
AJAX ASP.NetAJAX ASP.Net
AJAX ASP.Net
SHC
 
C++ plus data structures, 3rd edition (2003)
C++ plus data structures, 3rd edition (2003)C++ plus data structures, 3rd edition (2003)
C++ plus data structures, 3rd edition (2003)
SHC
 
Inside Asp.Net Web Matrix
Inside Asp.Net Web MatrixInside Asp.Net Web Matrix
Inside Asp.Net Web MatrixSHC
 
V Pro Bp08505 Phase Iii Edited
V Pro Bp08505 Phase Iii EditedV Pro Bp08505 Phase Iii Edited
V Pro Bp08505 Phase Iii EditedSHC
 
V Pro Bp08505 Phase Iii Edited
V Pro Bp08505 Phase Iii EditedV Pro Bp08505 Phase Iii Edited
V Pro Bp08505 Phase Iii EditedSHC
 
V Pro Bp08505 Phase Ii Edited
V Pro Bp08505 Phase Ii EditedV Pro Bp08505 Phase Ii Edited
V Pro Bp08505 Phase Ii EditedSHC
 
Intel® V Pro™ Technology
Intel® V Pro™ TechnologyIntel® V Pro™ Technology
Intel® V Pro™ Technology
SHC
 
XForms with Linux
XForms with LinuxXForms with Linux
XForms with Linux
SHC
 
XForms
XFormsXForms
XFormsSHC
 
Rails
RailsRails
RailsSHC
 
Call
CallCall
CallSHC
 
Ruby Security
Ruby SecurityRuby Security
Ruby Security
SHC
 
Web Services
Web ServicesWeb Services
Web Services
SHC
 
Pragmatic Agile Web Development With Rails.3rd Edition.2009
Pragmatic   Agile Web Development With Rails.3rd Edition.2009Pragmatic   Agile Web Development With Rails.3rd Edition.2009
Pragmatic Agile Web Development With Rails.3rd Edition.2009
SHC
 
Ruby Basics
Ruby BasicsRuby Basics
Ruby Basics
SHC
 
Ruby Installation
Ruby InstallationRuby Installation
Ruby Installation
SHC
 
Mysql Statments
Mysql StatmentsMysql Statments
Mysql Statments
SHC
 
Mysql Fun
Mysql FunMysql Fun
Mysql Fun
SHC
 
Mysql
MysqlMysql
Mysql
SHC
 

More from SHC (20)

Perform brute force
Perform brute forcePerform brute force
Perform brute force
 
AJAX ASP.Net
AJAX ASP.NetAJAX ASP.Net
AJAX ASP.Net
 
C++ plus data structures, 3rd edition (2003)
C++ plus data structures, 3rd edition (2003)C++ plus data structures, 3rd edition (2003)
C++ plus data structures, 3rd edition (2003)
 
Inside Asp.Net Web Matrix
Inside Asp.Net Web MatrixInside Asp.Net Web Matrix
Inside Asp.Net Web Matrix
 
V Pro Bp08505 Phase Iii Edited
V Pro Bp08505 Phase Iii EditedV Pro Bp08505 Phase Iii Edited
V Pro Bp08505 Phase Iii Edited
 
V Pro Bp08505 Phase Iii Edited
V Pro Bp08505 Phase Iii EditedV Pro Bp08505 Phase Iii Edited
V Pro Bp08505 Phase Iii Edited
 
V Pro Bp08505 Phase Ii Edited
V Pro Bp08505 Phase Ii EditedV Pro Bp08505 Phase Ii Edited
V Pro Bp08505 Phase Ii Edited
 
Intel® V Pro™ Technology
Intel® V Pro™ TechnologyIntel® V Pro™ Technology
Intel® V Pro™ Technology
 
XForms with Linux
XForms with LinuxXForms with Linux
XForms with Linux
 
XForms
XFormsXForms
XForms
 
Rails
RailsRails
Rails
 
Call
CallCall
Call
 
Ruby Security
Ruby SecurityRuby Security
Ruby Security
 
Web Services
Web ServicesWeb Services
Web Services
 
Pragmatic Agile Web Development With Rails.3rd Edition.2009
Pragmatic   Agile Web Development With Rails.3rd Edition.2009Pragmatic   Agile Web Development With Rails.3rd Edition.2009
Pragmatic Agile Web Development With Rails.3rd Edition.2009
 
Ruby Basics
Ruby BasicsRuby Basics
Ruby Basics
 
Ruby Installation
Ruby InstallationRuby Installation
Ruby Installation
 
Mysql Statments
Mysql StatmentsMysql Statments
Mysql Statments
 
Mysql Fun
Mysql FunMysql Fun
Mysql Fun
 
Mysql
MysqlMysql
Mysql
 

Recently uploaded

Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 

Recently uploaded (20)

Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 

Action Mailer

  • 1. Action Mailer Action Mailer is the Rails component that enables applications to send and receive e-mail. In this chapter we will see how to send an email using Rails. So lets start with creating a emails project using following command. C:ubyamp;gt; rails emails This will create required framework to proceed. Now we will start with configuring Action Mailer. Action Mailer - Configuration Following are the steps you have to follow to complete your configuration before proceeding with actual work: Go into config folder of your emails project and open environment.rb file and add the following line at the bottom of this file. ActionMailer::Base.delivery_method = :smtp
  • 2. This tells ActionMailer that you want to user SMTP server. You can also set it to be :sendmail if you are using a Unix-based operating system such as Mac OS X or Linux. Add the following lines of code to the bottom of your environment.rb as well. ActionMailer::Base.server_settings = { :address => "smtp.site.com", :port => 25, :domain => “site.com", :authentication => :login, :user_name => "username", :password => "password", } Replace each hash value with proper settings for your Simple Mail Transfer Protocol (SMTP) server. You can take this information from your Internet Service Provider if you already don't know. You don't need to change port number 25 and authentication type if you are using standard SMTP server. You may also change the default email message format. If you prefer to send email in HTML instead of plain text format, add the following line to config/environment.rb as well:
  • 3. ActionMailer::Base.default_content_type = "text/html" ActionMailer::Base.default_content_type could be set to "text/plain", "text/html", and "text/enriched". The default value is "text/plain". Next step will be to create a mailer Generate a mailer: Use the following command to generate a mailer as follows: C:ubyamp;gt; cd emails C:ubymails> ruby script/generate mailer Emailer This will create a file emailer.rb in appodels directory. Check the content of this file is as follows:
  • 4. class Emailer < ActionMailer::Base end Let's create one method as follows. class Emailer < ActionMailer::Base def contact(recipient, subject, message, sent_at = Time.now) @subject = subject @recipients = recipient @from = 'no-reply@yourdomain.com' @sent_on = sent_at @body["title"] = 'This is title' @body["email"] = 'sender@yourdomain.com' @body["message"] = message end end The contact method has four parameters a recipient, subject, message and a sent_at, which defines when the e-mail is sent. The method also defines six standard parameters that are a part of every ActionMailer method:
  • 5.
  • 6. @body is a Ruby hash that contains values with which you can populate the mail template. You created three key-value pairs: title, email, and message
  • 7. @recipients is a list of the people to whom the message is being sent.
  • 8. @from defines who the e-mail is from.
  • 9.
  • 10. Now let's define our view in appiewsmailsndex.rhtml <h1>Send Email</h1> <%= start_form_tag :action => 'sendmail' %> <p><label for="email_subject">Subject</label>: <%= text_field 'email', 'subject' %></p> <p><label for="email_recipient">Recipient</label>: <%= text_field 'email', 'recipient' %></p> <p><label for="email_message">Message</label><br/> <%= text_area 'email', 'message' %></p> <%= submit_tag "Send" %> <%= end_form_tag %>