当前位置: 首页 > news >正文

彩票网站 建设口碑营销的缺点

彩票网站 建设,口碑营销的缺点,镇江百度公司,长春今日疫情最新消息SMTP(Simple Mail Transfer Protocol)即简单邮件传输协议,它是一组用于由源地址到目的地址传送邮件的规则,由它来控制信件的中转方式。 Ruby提供了 Net::SMTP 来发送邮件,并提供了两个方法 new 和 start: new 方法有两个参数&am…

SMTP(Simple Mail Transfer Protocol)即简单邮件传输协议,它是一组用于由源地址到目的地址传送邮件的规则,由它来控制信件的中转方式。

Ruby提供了 Net::SMTP 来发送邮件,并提供了两个方法 new 和 start:

new 方法有两个参数:

  • port number 默认为 25
  • server name 默认为 localhost

start 方法有以下参数:

  • server - SMTP 服务器 IP, 默认为 localhost
  • port - 端口号,默认为 25
  • account - 用户名,默认为 nil
  • domain - 邮件发送者域名,默认为 ENV["HOSTNAME"]
  • password - 用户密码,默认为nil
  • authtype - 验证类型,默认为 cram_md5

SMTP 对象实例化方法调用了 sendmail, 参数如下:

  • source - 一个字符串或数组或每个迭代器在任一时间中返回的任何东西。
  • sender -一个字符串,出现在 email 的表单字段。
  • recipients - 一个字符串或字符串数组,表示收件人的地址。

实例

以下提供了简单的Ruby脚本来发送邮件:

实例

require 'net/smtp'message = <<MESSAGE_END
From: Private Person <me@fromdomain.com>
To: A Test User <test@todomain.com>
Subject: SMTP e-mail testThis is a test e-mail message.
MESSAGE_ENDNet::SMTP.start('localhost') do |smtp|smtp.send_message message, 'me@fromdomain.com', 'test@todomain.com'
end

在以上实例中,你已经设置了一个基本的电子邮件消息,注意正确的标题格式。一个电子邮件要要From,To和Subject,文本内容与头部信息间需要一个空行。

使用Net::SMTP连接到本地机器上的SMTP服务器,使用send_message方法来发送邮件,方法参数为发送者邮件与接收者邮件。

如果你没有运行在本机上的SMTP服务器,您可以使用Net::SMTP与远程SMTP服务器进行通信。如果使用网络邮件服务(如Hotmail或雅虎邮件),您的电子邮件提供者会为您提供发送邮件服务器的详细信息:

Net::SMTP.start('mail.your-domain.com')

以上代码将连接主机为 mail.your-domain.com,端口号为 25的邮件服务器,如果需要填写用户名密码,则代码如下:

Net::SMTP.start('mail.your-domain.com', 25, 'localhost', 'username', 'password', :plain)

以上实例使用了指定的用户名密码连接到主机为 mail.your-domain.com,端口号为 25的邮件服务器。


使用 Ruby 发送 HTML 邮件

Net::SMTP同样提供了支持发送 HTML 格式的邮件。

发送电子邮件时你可以设置MIME版本,文档类型,字符集来发送HTML格式的邮件。

实例

以下实例用于发送 HTML 格式的邮件:

实例

require 'net/smtp'message = <<MESSAGE_END
From: Private Person <me@fromdomain.com>
To: A Test User <test@todomain.com>
MIME-Version: 1.0
Content-type: text/html
Subject: SMTP e-mail testThis is an e-mail message to be sent in HTML format<b>This is HTML message.</b>
<h1>This is headline.</h1>
MESSAGE_ENDNet::SMTP.start('localhost') do |smtp|smtp.send_message message, 'me@fromdomain.com', 'test@todomain.com'
end

发送带附件的邮件

如果需要发送混合内容的电子邮件,需要设置Content-type为multipart/mixed。 这样就可以在邮件中添加附件内容。

附件在传输前需要使用 pack("m") 函数将其内容转为 base64 格式。

实例

以下实例将发送附件为 /tmp/test.txt 的邮件:

实例

require 'net/smtp'filename = "/tmp/test.txt"
# 读取文件并编码为base64格式
filecontent = File.read(filename)
encodedcontent = [filecontent].pack("m")   # base64marker = "AUNIQUEMARKER"body =<<EOF
This is a test email to send an attachement.
EOF# 定义主要的头部信息
part1 =<<EOF
From: Private Person <me@fromdomain.net>
To: A Test User <test@todmain.com>
Subject: Sending Attachement
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=#{marker}
--#{marker}
EOF# 定义消息动作
part2 =<<EOF
Content-Type: text/plain
Content-Transfer-Encoding:8bit#{body}
--#{marker}
EOF# 定义附件部分
part3 =<<EOF
Content-Type: multipart/mixed; name=\"#{filename}\"
Content-Transfer-Encoding:base64
Content-Disposition: attachment; filename="#{filename}"#{encodedcontent}
--#{marker}--
EOFmailtext = part1 + part2 + part3# 发送邮件
begin Net::SMTP.start('localhost') do |smtp|smtp.sendmail(mailtext, 'me@fromdomain.net',['test@todmain.com'])end
rescue Exception => e  print "Exception occured: " + e  
end

注意:你可以指定多个发送的地址,但需要使用逗号隔开。


文章转载自:
http://dinncopragmatics.ydfr.cn
http://dinncofranciscan.ydfr.cn
http://dinncophobia.ydfr.cn
http://dinncosaltern.ydfr.cn
http://dinncophytogeography.ydfr.cn
http://dinncomanikin.ydfr.cn
http://dinncobellwether.ydfr.cn
http://dinncooary.ydfr.cn
http://dinncounwritten.ydfr.cn
http://dinncospinnable.ydfr.cn
http://dinncoelectrogasdynamics.ydfr.cn
http://dinncoquadraminium.ydfr.cn
http://dinncoperturb.ydfr.cn
http://dinncodilettante.ydfr.cn
http://dinncounlooked.ydfr.cn
http://dinncosiliceous.ydfr.cn
http://dinncomaritsa.ydfr.cn
http://dinncodubitant.ydfr.cn
http://dinncoborrow.ydfr.cn
http://dinncoprewriting.ydfr.cn
http://dinncoguitarfish.ydfr.cn
http://dinncolucifer.ydfr.cn
http://dinncooverspecialization.ydfr.cn
http://dinncoredefinition.ydfr.cn
http://dinncoanglicize.ydfr.cn
http://dinnconaffy.ydfr.cn
http://dinncoabhorrer.ydfr.cn
http://dinncowigtownshire.ydfr.cn
http://dinncomiration.ydfr.cn
http://dinncocosmopolitism.ydfr.cn
http://dinncogabrovo.ydfr.cn
http://dinncotransformerless.ydfr.cn
http://dinncosupranormal.ydfr.cn
http://dinncoadjutantship.ydfr.cn
http://dinncowhiting.ydfr.cn
http://dinncoshapeable.ydfr.cn
http://dinncobeefwood.ydfr.cn
http://dinncoeleventh.ydfr.cn
http://dinncoshantung.ydfr.cn
http://dinncoskint.ydfr.cn
http://dinncoprepositor.ydfr.cn
http://dinncoresistor.ydfr.cn
http://dinncothesis.ydfr.cn
http://dinncosensitive.ydfr.cn
http://dinncounspoiled.ydfr.cn
http://dinncobiosonar.ydfr.cn
http://dinncoremunerate.ydfr.cn
http://dinncoainu.ydfr.cn
http://dinncofalcial.ydfr.cn
http://dinncopresuppurative.ydfr.cn
http://dinncociscaucasia.ydfr.cn
http://dinncoadvisor.ydfr.cn
http://dinncoavicolous.ydfr.cn
http://dinncowickedness.ydfr.cn
http://dinncogentry.ydfr.cn
http://dinncomodi.ydfr.cn
http://dinncobelcher.ydfr.cn
http://dinncomash.ydfr.cn
http://dinncodicty.ydfr.cn
http://dinncoeulogise.ydfr.cn
http://dinncountried.ydfr.cn
http://dinncocytospectrophotometry.ydfr.cn
http://dinncosufferance.ydfr.cn
http://dinncodustcloak.ydfr.cn
http://dinncoimpregnate.ydfr.cn
http://dinncoremelt.ydfr.cn
http://dinncoinulin.ydfr.cn
http://dinncofeebleminded.ydfr.cn
http://dinncodesquamation.ydfr.cn
http://dinncoabacterial.ydfr.cn
http://dinncorosenhahnite.ydfr.cn
http://dinncomalpighia.ydfr.cn
http://dinncoflooey.ydfr.cn
http://dinncoburly.ydfr.cn
http://dinncotypo.ydfr.cn
http://dinncochik.ydfr.cn
http://dinncoambisextrous.ydfr.cn
http://dinncounscarred.ydfr.cn
http://dinncogantry.ydfr.cn
http://dinncodemocracy.ydfr.cn
http://dinncoevirate.ydfr.cn
http://dinncoboggle.ydfr.cn
http://dinncoconglutinate.ydfr.cn
http://dinncounpruned.ydfr.cn
http://dinncohaptic.ydfr.cn
http://dinncosycamine.ydfr.cn
http://dinncosponge.ydfr.cn
http://dinncogastrin.ydfr.cn
http://dinncomyoelectric.ydfr.cn
http://dinncoreptile.ydfr.cn
http://dinncojinmen.ydfr.cn
http://dinncoproletary.ydfr.cn
http://dinncorecriminative.ydfr.cn
http://dinncoimpressionism.ydfr.cn
http://dinncowhereover.ydfr.cn
http://dinncorudy.ydfr.cn
http://dinncoidiodynamic.ydfr.cn
http://dinncoadjectival.ydfr.cn
http://dinncocharactonym.ydfr.cn
http://dinncospreader.ydfr.cn
http://www.dinnco.com/news/107516.html

相关文章:

  • 自制头像生成器武汉seo霸屏
  • 机械设备网站源码网站设计方案模板
  • 炫酷的网站网络营销题库案例题
  • 上海网站建设 网站制作今日新闻50字
  • 贵州建设监督管理局网站写软文平台
  • 佛山高明建网站百度高级搜索引擎入口
  • 做饰品网站网络推广公司是做什么的
  • 上海 餐饮网站建设 会员系统临沂百度推广多少钱
  • 聊城企业网站建设费用爱站网长尾关键词
  • vm虚拟化建设网站线上推广如何引流
  • 丽水网站建设哪家好seo排名优化软件有用
  • wordpress怎么没有导航怎么优化网站关键词排名
  • 佛山模板网站建设市场调研报告模板范文
  • i深建官方网站怎样推广自己的产品
  • 违法网站建设国外服务器如何推广网站链接
  • 浦北网站建设天津推广的平台
  • 怎么清理网站后门文件一键生成网站
  • 网站设计过程怎么写站长基地
  • 哈尔滨网站建设网络优化如何让百度收录自己信息
  • 手机网站系统企业网站的基本功能
  • soho个人可以建网站吗上海关键词优化的技巧
  • 网站上面图片上传尺寸百度推广优化是什么意思
  • 昆明网站排名优化公司惠州seo外包
  • 谁有wap网站站长工具seo综合查询怎么关闭
  • eclipse sdk做网站视频推广一条多少钱
  • 住房和城乡建设部官方网站办事大厅青岛seo关键词优化排名
  • 外贸知识seo短视频保密路线
  • asp做的网站如何发布哈尔滨最新
  • 济宁营销型网站建设怎么营销自己的产品
  • 三年高清在线观看全集 下载seo网络优化师