Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

easyemail

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easyemail

  • 1.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Easyemail

Easyemail是一个为简化邮件发送流程而发布的gem.

Installation

gem install easyemail

Usage

第一步:设置smtp

该gem为三个知名的邮件服务商163.com qq.com gmail.com和我学校(HHU)的邮箱服务做了预先的设置,如果你用来发送邮件的账号来自于以上的邮件服务商,设置smtp的方法如下:

# 以163邮箱为例
# 确保该账号开通了smtp服务
# username 和 password 是你的邮箱账号(账号包括完整后缀)和密码
  mailer = Easyemail.new
  mailer.smtp_settings_for_163  user_name, password
# 同样的方法还有:
#   smtp_settings_for_hhu
#   smtp_settings_for_qq
#   smtp_settings_for_gmail

如果你使用的不是以上任何一种,设置方法如下:

# 确保该账号开通了smtp服务
# username 和 password 是你的邮箱账号(账号包括完整后缀)和密码
  mailer = Easyemail.new
  smtp = {
    "address" => "**",
    "port" => **,
    "authentication" => "**",
    "user_name" => "**",
    "password" => "**",
    "enable_starttls_auto" => **
  }
  mailer.smtp_settings smtp

另外,还可以从yaml配置文件中导入smtp信息,同样的,如果来自以上四个邮件服务商,配置文件可以这样写

provider: ** # (只能从163, qq, gmail, hhu中任选一个)
user_name: **
password: **

否则配置文件需这样写:

address: **
port: **
authentication: **
user_name: **
password: **
enable_starttls_auto: **

调用代码如下:

  mailer = Easyemail.new
  mailer.load_smtp_settings_from_yaml file_path

第二步:设置收件人

允许群发邮件, 设置收件人代码如下:

  mailer.to = "someone@**.com" # 单收件人
  mailer.to = ["someone@**.com", "**"] # 多收件人

第三步:发送邮件

邮件内容支持文本和html格式,两者都以字符串的形式作为参数,调用代码如下:

# subject是邮件主题, content是邮件内容
  mailer.email(subject, content)

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 19 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc