发送邮件 ruby (gmail with net/smtp)
我有这段代码:
@msg = "Subject: Hi There!\nThis works."
smtp = Net::SMTP.new 'smtp.gmail.com', 587
smtp.enable_starttls
smtp.start(YourDomain, YourAccountName, YourPassword, :login)
smtp.send_message(@msg, FromAddress, ToAddress)
end
但我想知道 YourDomain 是什么意思?!我想从 gmail 发送邮件,那么我的 yourdomain 的“gmail.com”是吗? 我很困惑,我已经用 C#、php 和 actionscript 发送了电子邮件,但我从来不需要输入域名,否则我记不起它了!
好吧,这是我的一个愚蠢的问题,它必须是“gmail.com”!它有效,只是一个错字(我的耻辱!)
I have this code:
@msg = "Subject: Hi There!\nThis works."
smtp = Net::SMTP.new 'smtp.gmail.com', 587
smtp.enable_starttls
smtp.start(YourDomain, YourAccountName, YourPassword, :login)
smtp.send_message(@msg, FromAddress, ToAddress)
end
But i wonder what the mean with YourDomain?! I want to send from gmail is that then "gmail.com" for my yourdomain?
I am confused, i have send emails with C#, php and actionscript but i never had to enter a domain or i cannot remember it!
OK it was a stupid question of me, it has to be "gmail.com"! It works, just a typo (shame on my!)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它意味着可以识别您身份并使用 HELO 命令发送到 smtp 服务器(在您的情况下为 gmail)的域。
如果您没有域,则可以使用地址文字(请参阅 规范)。在你的情况下,我想你可以使用 [your_ip]
无论如何,它经常被 smtp 服务器忽略。
It means the domain that identifies you and is sent with the HELO command to the smtp server (gmail in your case).
If you don't have a domain, you can use an address literal (see specification). In your case I guess you could use [your_ip]
Anyway, it is often ignored by the smtp server.
也许这意味着“您想要什么域名?”
Maybe it means "What's domain your want to?"