向自己发送 HTML 电子邮件以测试它们的快速简便方法是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/460829/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What's a quick, easy way to send HTML emails to myself to test them?
提问by Jonathan
I've been given the task of optimizing HTML emails for different email/webmail clients. I used to test the HTML file by doing a trick in Outlook Express, to make it send the raw HTML, but Microsoft seems to have stopped supplying Outlook Express now (I think "Live Mail" is supposed to replace it).
我的任务是为不同的电子邮件/网络邮件客户端优化 HTML 电子邮件。我曾经通过在 Outlook Express 中做一个技巧来测试 HTML 文件,让它发送原始 HTML,但微软现在似乎已经停止提供 Outlook Express(我认为“Live Mail”应该取代它)。
So my question is, is there a simple, quick way to send HTML emails? Maybe even a freeware program that does the job?
所以我的问题是,是否有一种简单快捷的方式来发送 HTML 电子邮件?也许甚至是一个可以完成这项工作的免费软件程序?
采纳答案by alex
A Test Mail Server Toolcan help with that -if you just need to receive and view any emails sent by your application.
一个测试邮件服务器的工具可以提供帮助的-如果你只需要接收和查看您的应用程序发送的任何电子邮件。
回答by rekamoyka
Puts Mailis the best bet these days. Check out an answer to a similar questionby the creator of Puts Mail.
回答by Harald Schilly
I would use python, here at the bottom is an example how to create a HTML email with a text default: http://docs.python.org/library/email-examples.htmlyou can parameterize this, encapsulate in functions, read content from files, etc. (make sure, that you set localhost in "s = smtplib.SMTP('localhost') " to your smtp server)
我会使用 python,这里的底部是一个示例,如何使用文本默认值创建 HTML 电子邮件:http: //docs.python.org/library/email-examples.html你可以参数化它,封装在函数中,阅读来自文件等的内容(确保您将“s = smtplib.SMTP('localhost')”中的 localhost 设置为您的 smtp 服务器)
回答by Chase Seibert
If you are just looking to test whether an HTML email displays properly in various clients, I would use sendmail.exe(windows only).
如果您只是想测试 HTML 电子邮件是否在各种客户端中正确显示,我会使用sendmail.exe(仅限 Windows)。
You can save a .html file and pipe it into that program on the command-line as the email content. There are command line options for from/to/subject/server, etc.
您可以保存一个 .html 文件并将其作为电子邮件内容通过管道传输到命令行上的该程序中。有 from/to/subject/server 等的命令行选项。
This would allow you to rapidly send and re-send emails by just editing the .html file and running the command-line again. No programming required.
这将允许您通过编辑 .html 文件并再次运行命令行来快速发送和重新发送电子邮件。无需编程。
Edit: there is a similar command-line tool for Linux with the same name.
编辑:Linux 有一个类似的同名命令行工具。
回答by puchu
Ruby variant:
红宝石变体:
require "mail"
options = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "smtp.gmail.com",
:user_name => "[email protected]",
:password => "password",
:enable_starttls_auto => true,
:authentication => :plain,
}
Mail.defaults do
delivery_method :smtp, options
end
mail = Mail.new do
to "[email protected]"
from "Me Me [email protected]"
subject "test email"
html_part do
content_type "text/html; charset=UTF-8"
body File.read("index.html")
end
end
mail.deliver
Do not forget to enable access from https://www.google.com/settings/security/lesssecureapps
不要忘记从https://www.google.com/settings/security/lesssecureapps启用访问
回答by inspite
If you are running .NET and you have a Gmail account this is one easy way
如果您正在运行 .NET 并且拥有 Gmail 帐户,这是一种简单的方法
using System.Net;
using System.Net.Mail;
var fromAddress = new MailAddress("[email protected]", "From Name");
var toAddress = new MailAddress("[email protected]", "To Name");
const string fromPassword = "fromPassword";
const string subject = "Subject";
const string body = "Body";
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message);
}
see Sending email in .NET through Gmailfor more details
有关详细信息,请参阅通过 Gmail 在 .NET 中发送电子邮件
回答by John M
I believe you can send html emails from Mozilla's Thunderbird email client.
我相信您可以从 Mozilla 的 Thunderbird 电子邮件客户端发送 html 电子邮件。
http://www.mozillamessaging.com/en-US/thunderbird/
http://www.mozillamessaging.com/en-US/thunderbird/
This is what I used to send test emails. Or I guess you could use your email provider too.
这就是我用来发送测试电子邮件的方式。或者我想您也可以使用您的电子邮件提供商。
回答by balexandre
I would noteven go with any language...
我什至不会使用任何语言......
I would stop at MailChimpand set up a free account(max of 500 subscribers and 3000 sends per month) ... 3000 sends is enough to test right? :)
我会在MailChimp停留并设置一个免费帐户(最多 500 个订阅者和每月 3000 次发送)...... 3000 次发送足以测试对吗?:)
It has all the tools you need to send emails professionally (and maybe set up an account to your client/friend so they/he can use MailChimp in their Newsletters)
它具有专业发送电子邮件所需的所有工具(并且可能为您的客户/朋友设置一个帐户,以便他们/他可以在他们的时事通讯中使用 MailChimp)
while you're at it, see their resourcespage as well the perfect tool to know what can we use in Newsletters using CampaignMonitorown Guide to CSS support in email clients
当您使用它时,请查看他们的资源页面以及了解我们可以在时事通讯中使用什么的完美工具,使用CampaignMonitor自己的电子邮件客户端 CSS 支持指南
hope it helps
希望能帮助到你
回答by Rob Flaherty
If you're on a Mac you can send HTML email super quickly using Safari and Mail. I blogged about the details at the link below, but basically you just view your HTML file in Safari and select File > Mail Contents of This Page.
如果您使用的是 Mac,则可以使用 Safari 和 Mail 快速发送 HTML 电子邮件。我在下面的链接中写了有关详细信息的博客,但基本上您只需在 Safari 中查看您的 HTML 文件,然后选择“文件”>“此页面的邮件内容”。
http://www.ravelrumba.com/blog/send-html-email-with-safari-mail-for-fast-testing/
http://www.ravelrumba.com/blog/send-html-email-with-safari-mail-for-fast-testing/
回答by abatishchev
Also you can use PowerShell
您也可以使用PowerShell
回答by Ates Goral
A Windows-only free solution where you typically don't have to install anything special is to use ASP or WSH. I opt for JScript instead of VBScript:
通常无需安装任何特殊程序的仅适用于 Windows 的免费解决方案是使用 ASP 或 WSH。我选择 JScript 而不是 VBScript:
function sendHtml(recipients, subject, html) {
var mail = Server.CreateObject("CDO.Message");
mail.From = "Tester <[email protected]>";
mail.Subject = subject;
mail.To = recipients.join(";");
mail.HTMLBody = html;
// Do the following if you want to directly use a specific SMTP server
mail.Configuration.Fields.Item(
"http://schemas.microsoft.com/cdo/configuration/sendusing") = 2;
mail.Configuration.Fields.Item(
"http://schemas.microsoft.com/cdo/configuration/smtpserver")
= "smtp.example.com";
mail.Configuration.Fields.Item(
"http://schemas.microsoft.com/cdo/configuration/smtpserverport")
= 25;
mail.Configuration.Fields.Update();
mail.Send();
}
Note:However, your HTML may end up getting slightly reformatted with this approach.
注意:但是,您的 HTML 最终可能会通过这种方法稍微重新格式化。