桌面应用程序 azure_在Windows Azure上安装Sendy(PHP应用程序)以通过Amazon SES发送廉价的新闻邮件

桌面应用程序 azure

桌面应用程序 azure

TL; DR摘要(TL;DR Summary)

  • Sendy.co is a lovely and polished PHP app that uses Amazon's SES (Simple Email Service) to send email on the cheap.

    Sendy.co是一款精美可爱PHP应用程序,它使用亚马逊的SES(简单电子邮件服务)以低价发送电子邮件。

  • It's easy to setup PHP apps on Windows Azure.

    在Windows Azure上设置PHP应用程序很容易。
  • Azure Websites don't support mod_rewrite so you port the rules to a web.config. There's a great Sendy web.config for Windows in this post you are welcome to.

    Azure网站不支持mod_rewrite,因此您可以将规则移植到web.config。 欢迎您阅读这篇文章,其中包含适用于Windows很棒的Sendy web.config

  • Sendy works well on Azure although they don't officially support Windows. I'm sure Sendy works great everywhere.

    尽管Sendy并不正式支持Windows,但它们在Azure上运行良好。 我敢肯定,Sendy在任何地方都能发挥出色。

  • I'm now running my Newsletter on Windows Azure with mails sent my Amazon SES

    我现在正在Windows Azure上运行时事通讯,并向我的Amazon SES发送邮件

  • Technical details below.

    技术细节如下。

寻找便宜的新闻通讯解决方案 (In search of a Cheaper Newsletter Solution)

Why not a Rube Goldbergian solution? Well, it's not THAT bad. Here's the back story.

为什么使用Rube Goldbergian解决方案? 好吧,还不错。 这是背景故事。

I started a little link blog newsletter a few months back, just for fun. You can subscribe at http://hanselman.com/newsletter if you like. It's a low-traffic once-or-twice-a-month little ditty, mostly to share the things I've bumped into on the internet with friends.

几个月前,我开始了一个链接博客新闻通讯,只是为了好玩。 如果愿意,可以在http://hanselman.com/newsletter订阅。 这是一个低流量的每月一两次的小事,主要是与朋友分享我在互联网上碰到的事情。

I started at TinyLetter.com which is brilliant for little low-traffic newsletters. However, this one has picked up steam and now it's hit the maximum number of subscribers that TinyLetter allows.  TinyLetter is a front for MailChimp, so I look at their pricing. Looks like 5k-10k subscribers is $75 a month! Eek. Let me check SendGrid. They have a $79 a month option for up to 100k emails, but that's still $960 a year for a newsletter that sells nothing and serves no useful purpose. Yet.

我从TinyLetter.com开始,对于那些低流量的时事通讯来说非常出色。 但是,这已经激增了,现在达到了TinyLetter允许的最大订户数。 TinyLetter是MailChimp的前沿,所以我看一下它们的价格。 看起来5k-10k订户每月75美元! 真是的让我检查SendGrid。 他们有每月$ 79的选择权,最多可发送10万封电子邮件,但对于仍然没有任何用途且没有用处的新闻通讯来说,每年仍为$ 960。 然而。

I suppose I could charge people or get sponsors, but, meh, that takes work. I just want to send my list out. I could use my blog. Well, I do, but I like the high connectivity that a direct letter offers so I post the letter a few weeks letter so subscribers get the early scoop. Cleary folks dig it or they wouldn't sign up.

我想我可以收费或找赞助商,但是,那需要工作。 我只想发送清单。 我可以使用我的博客。 是的,我知道,但是我喜欢直接寄信提供的高连接性,因此我将信件寄出了几个星期,以便订户能早日获得独家报道。 精明的人会挖它,否则他们不会注册。

A twitter person told me about Sendy.co. It's a PHP app that you host yourself. It fronts Amazon's Simple Email Service (SES) which is dirt cheap for email. The app is REALLY polished and just lovely. It's $59 to buy, but they said on their site "If you encounter problems, we will help you. If it doesn't work out, we'll refund you." That matters to me, so I bought it on the spot.

一个推特人告诉我有关Sendy.co的信息。 这是您自己托管PHP应用程序。 它位于亚马逊的简单电子邮件服务(SES)之前,该服务对于电子邮件来说非常便宜。 该应用程序真的很漂亮,很可爱。 购买价格为59美元,但他们在其网站上说:“如果遇到问题,我们将为您提供帮助。如果无法解决,我们将退还您的款项。” 这对我很重要,所以我当场购买了。

I know nothing about PHP, though, but I know the web, so I'm sure I can figure this out.

虽然我对PHP一无所知,但是我对网络一无所知,所以我敢肯定我能弄清楚这一点。

The Sendy site says this MASSIVE DISCLAIMER:

Sendy网站表示此大规模免责声明

What are the requirements?

有什么要求?

You need PHP & mySQL support on a Unix like server, eg. Linux on Apache. Almost all hosting companies support them. IT ISN'T SUPPORTED ON WINDOWS AND YOU'RE A FOOL TO TRY.

例如,您需要在Unix之类的服务器上支持PHP和mySQL。 Linux on Apache。 几乎所有托管公司都支持它们。 WINDOWS上不支持它,您可以尝试。

Ok, I admit, I added that part at the end myself. But, I don't really feel like spinning up a Linode as I have Azure credits I'm not using each month. I'm sure this will work. Plus, if it doesn't, I'll spin up a PHP app at any of a thousand little hosts for minimum money. If it works, it'll be nice to have everything in once place.

好的,我承认,我自己最后添加了这一部分。 但是,我真的不想像Linode一样工作,因为我每个月都没有使用Azure积分。 我敢肯定这会起作用。 另外,如果没有,我将以最少的钱在数千个小型主机中启动一个PHP应用程序。 如果可行,将所有内容都放在一个地方会很好。

在Windows Azure云上制作Sendy PHP应用程序实例 (Making a Sendy PHP app instance on the Windows Azure Cloud)

I go over to Azure and make a new website with a MySQL database:

我转到Azure并使用MySQL数据库创建一个新网站:

Making a new website with a new MySQL DB

Next, inside of Azure I download the publish profile for my site. I also view the connection strings to the database because I'll need them to connect to the Sendy instance.

接下来,在Azure内部,我下载我网站的发布配置文件。 我还将查看数据库的连接字符串,因为需要它们来连接到Sendy实例。

Connection Strings and publish profile

Then I download Sendy (after paying), unblock the zip and unzip it into a folder. I open the folder in WebMatrix. It installs PHP on my local machine so I can run it locally (even though I won't bother). I am using WebMatrix in this instance as a super easy way to publish to Azure directly.

然后我下载Sendy(付款后),解压缩zip并将其解压缩到一个文件夹中。 我在WebMatrix中打开文件夹。 它在本地计算机上安装了PHP,因此我可以在本地运行它(即使我不会打扰)。 我在这种情况下使用WebMatrix作为直接发布到Azure的超级简单方法。

The Sendy PHP app opens nicely in WebMatrix

I hit the Remote tab, then Settings to Import the publish profile I downloaded. Don't publish yet! I need to add a web.config since we are running this PHP app on Windows.

我单击“远程”选项卡,然后单击“设置”以导入我下载的发布配置文件。 还没发布! 我需要添加一个web.config,因为我们正在Windows上运行此PHP应用程序。

Windows上的Sendy-.htaccess与web.config URL重写 (Sendy on Windows - .htaccess vs. web.config URL rewrite)

I noticed there's an .htaccess file in my Sendy install. That means they've likely got mod_rewrite stuff going on to make the URLs pretty. Here's their file:

我注意到我的Sendy安装中有一个.htaccess文件。 这意味着他们可能会继续使用mod_rewrite来使URL变得漂亮。 这是他们的文件:

ErrorDocument 404 "[404 error] If you're seeing this error after install, check this thread on our forum for the fix: http://sendy.co/forum/discussion/5/404-error-after-install/p1"

Options +FollowSymLinks
Options -Multiviews

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9-]+)$ $1.php [L]

# Link tracker
RewriteRule ^l/([a-zA-Z0-9/]+)$ l.php?i=$1 [L]

# Open tracker
RewriteRule ^t/([a-zA-Z0-9/]+)$ t.php?i=$1 [L]

# Web version
RewriteRule ^w/([a-zA-Z0-9/]+)$ w.php?i=$1 [L]

# unsubscribe
RewriteRule ^unsubscribe/(.*)$ unsubscribe.php?i=$1 [L]

# subscribe
RewriteRule ^subscribe/(.*)$ subscribe.php?i=$1 [L]

Windows Azure Websites with PHP doesn't (yet?) support mod_rewrite so I have to make web.config that does the same thing with UrlRewrite.  Fortunately importing mod_rewrite rules into web.config files has been straightforward for over 5 years in IIS.

带有PHP的Windows Azure网站尚不支持mod_rewrite,因此我必须使web.config与UrlRewrite相同。 幸运的是,在IIS中,将mod_rewrite规则导入web.config文件已有5年了

Since I put Sendy in the root of a site, I don't have any sub-directories or paths. If it was in /sendy or something I might have to be a little more specific in my Regular Expressions below. You have to consider where Sendy is and where your web.config is. In this case, the easiest thing was the root and putting Sendy in its own site then adding this web.config. You'll notice is a pretty straight port.

由于我将Sendy放在网站的根目录中,因此我没有任何子目录或路径。 如果是/ sendy或其他内容,则可能需要在下面的正则表达式中更具体一些。 您必须考虑Sendy在哪里以及web.config在哪里。 在这种情况下,最简单的方法是将根目录放入Sendy并放置在其自己的站点中,然后添加此web.config。 您会注意到这是一个相当直截了当的端口。

<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Sendy all" stopProcessing="true">
<match url="^([a-zA-Z0-9-]+)$" ignoreCase="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}.php" appendQueryString="true" />
</rule>

<rule name="Sendy: link tracker" stopProcessing="true">
<match url="^l/([a-zA-Z0-9/]+)$" ignoreCase="true" />
<action type="Rewrite" url="l.php?i={R:1}" appendQueryString="true" />
</rule>

<rule name="Sendy: open tracker" stopProcessing="true">
<match url="^t/([a-zA-Z0-9/]+)$" ignoreCase="true" />
<action type="Rewrite" url="t.php?i={R:1}" appendQueryString="true" />
</rule>

<rule name="Sendy: web version" stopProcessing="true">
<match url="^w/([a-zA-Z0-9/]+)$" ignoreCase="true" />
<action type="Rewrite" url="w.php?i={R:1}" appendQueryString="true" />
</rule>

<rule name="Sendy: unsubscribe" stopProcessing="true">
<match url="^unsubscribe/(.*)$" ignoreCase="true" />
<action type="Rewrite" url="unsubscribe.php?i={R:1}" appendQueryString="true" />
</rule>

<rule name="Sendy: subscribe" stopProcessing="true">
<match url="^subscribe/([a-zA-Z0-9/]+)$" ignoreCase="true" />
<action type="Rewrite" url="subscribe.php?i={R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

I mentioned to the Azure Websites team that we should either directly support mod_rewrite or automatically turn existing ones into a format like this.

我向Azure网站团队提到,我们应该直接支持mod_rewrite或将现有的自动转换为这种格式。

NOTE: This web.config is different, better, and much improved over the one that is mentioned on the Sendy Forums. It also works nicely and completely. The one on the forums is more than little iffy.

注意:与sendy论坛上提到的web.config相比此web.config有所不同,更好并且得到很大改进。 它也可以很好且完全地工作。 论坛上的内容远不止于此。

This web.config needs to be in the same folder as the Sendy app. I just made this file from WebMatrix directly.

该web.config必须与Sendy应用程序位于同一文件夹中。 我只是直接从WebMatrix制作了此文件。

Windows Azure Sendy配置 (Windows Azure Sendy Configuration)

Next, change the includes/config.php and include the details on your application's location as well as your database connection details.

接下来,更改include / config.php,并包括有关应用程序位置的详细信息以及数据库连接的详细信息。

<?php 
    //==================================================================================//    
    // Configuration
    //==================================================================================//
    
    //path to your Sendy installation (without the trailing slash)
    define('APP_PATH', 'http://pantspantspants.hanselman.com');
    
    //database connection credentials
    $dbHost = 'somefunkyurl.cleardb.com'; //mySQL Hostname
    $dbUser = 'ladaladalada'; //mySQL Username
    $dbPass = 'pardypary'; //mySQL Password
    $dbName = 'sendyDBName'; //mySQL Database Name
    //$dbPort = 3306; //mySQL port (only if you need to change it)
    
    //domain of cookie (99.99% chance you don't need to edit this)
    define('COOKIE_DOMAIN', '');
    
    //==================================================================================//
?>


I chose to scale my site up to Shared mode so I could add a custom CNAME for the domain. I just went over to DNSimple where I host my DNS and added a CNAME for Hanselman.com that pointed to my fancypantsmail.azurewebsites.net site. Then in Azure I hit Manage Domains and added this new subdomain.

我选择将网站扩展到共享模式,以便为该域添加自定义CNAME。 我刚到DNSimple托管我的DNS,并为Hanselman.com添加了一个指向我的fancypantsmail.azurewebsites.net网站的CNAME。 然后在Azure中,我点击“管理域”并添加了这个新的子域。

NOTE: The domain name that you tell the Sendy guys must be the same one that's in your config.php and the same one you run under. I bought it for hanselman.com so it will only run there. Phrased differently, I couldn't get Sendy to run until the CNAME subdomain resolved correctly.

注意:您告诉Sendy家伙的域名必须与config.php中的域名相同,并且与您在其下运行的域名相同。 我是在hanselman.com上购买的,因此只能在该网站上运行。 换句话说,在CNAME子域正确解析之前,我无法运行Sendy。

完成Sendy安装 (Finishing Sendy Installation)

The Getting Started checklist at Sendy is REALLY well written. Follow it carefully.

在SENDY入门清单写得很好。 仔细遵循。

I hit my URL and tell Sendy about my license key. You'll know the app ISN'T installed correctly if you can't see any CSS or images or you get 404s. That means the web.config (my fake mod_rewrite) isn't there.

我打了我的URL并告诉Sendy我的许可证密钥。 如果看不到任何CSS或图像,或者得到404,就可以知道ISN未正确安装该应用。 这意味着不存在web.config(我的伪造的mod_rewrite)。

I skipped Step 4 of their Getting Started as I believe it's already done for me, even though I don't plan on uploading any files. I setup Amazon SES and verified my email addresses. Getting this right, as well as bounce and complaint handling is super important so read carefully.

我跳过了《入门指南》的第4步,因为我相信这对我来说已经完成了,即使我不打算上传任何文件。 我设置了Amazon SES并验证了我的电子邮件地址。 正确地做到这一点以及反弹和投诉处理非常重要,因此请仔细阅读。

You'll want to make sure your Amazon SES emails are verified, and that Sendy has endpoints setup for complaints and bounces.

您将要确保您的Amazon SES电子邮件已经过验证,并且Sendy具有针对投诉和退信的终端设置。

Gotcha: I had to make sure both the SES and SNS were in Amazon East 1.

疑难杂症:我必须确保双方的SES和SNS是在亚马逊地区1。

Once these endpoints are setup, again as the Getting Started checklist at Sendy explains, you're ready to do some tests.

一旦设置了这些端点,再次作为Sendy的“入门”清单解释,您已经准备好进行一些测试。

设置新闻通讯活动 (Setting up a Newsletter Campaign)

The Sendy application is really nice, easy to use and easy to move around in.  I found it as easy as using TinyLetter, while it's clear there's more power underneath I have yet to tap into.

Sendy应用程序非常好,易于使用,并且易于移动。  我发现它与使用TinyLetter一样容易,但很明显,我还需要挖掘更多的强大功能。

image

I was able to move my subscribers over with minimal trouble. I exported them from TinyLetter and imported them into Sendy. I wonder how long until the MySQL database gets big enough that I have to pay for it? Right now I'm still using the free MySQL database I created with my website.

我能够以最小的麻烦转移订户。 我从TinyLetter导出了它们,然后将它们导入了Sendy。 我想知道MySQL数据库变得足够大以至于我必须为此付出多长时间? 现在,我仍在使用通过网站创建的免费MySQL数据库。

制作订阅表格 (Making a Subscribe Form)

There isn't a Subscribe Form out of the box that I can find built-in to the Sendy app (can you?) so I made one at http://hanselman.com/newsletter that just posts to the Sendy API subscribe endpoint. Details here, it's just an HTTP POST! http://sendy.co/api. You can integrate it with whatever you like. I just made a simple form, myself.

我没有开箱即用的订阅表单,可以在Sendy应用程序中找到内置的表单(可以吗?),所以我在http://hanselman.com/newsletter上创建了一个表单,该表单仅发布到Sendy API订阅端点。 这里的细节,这只是一个HTTP POST! http://sendy.co/api 。 您可以将其与任何您喜欢的集成。 我自己做了一个简单的表格。

Sending mails!

Hopefully this will be a reasonable and economical solution for http://hanselman.com/newsletter for the foreseeable future!

希望在可预见的将来,这对于http://hanselman.com/newsletter将是一种合理且经济的解决方案!

* SOME DISCLAIMERS AND DETAILS: The Sendy links are a referral link, but they don't know me over at Sendy. I just like them. Maybe I'll get some soda money if you buy it. Also, note again that installing Sendy on Windows is explicitly not supported until they say it is. Don't bother those nice people with your Windows questions. I am assuming that you are reasonably technical and are willing to fiddle. I installed it on Azure because I've already got 12 sites at Azure. You might have success on a Linux machine at Amazon or at Linode. Good luck!

*一些免责声明和详细信息: Sendy链接是引荐链接,但他们对Sendy并不了解我。 我就是喜欢他们如果你买的话,也许我会得到一些苏打水。 另外,请再次注意,除非他们说是,否则明确不支持在Windows上安装Sendy。 不要为Windows问题困扰那些好人。 我假设您具有一定的技术水平并且愿意摆弄。 我将其安装在Azure上是因为我已经在Azure上拥有12个站点。 您可能在Amazon或LinodeLinux计算机上获得了成功。 祝好运!

翻译自: https://www.hanselman.com/blog/installing-sendy-a-php-app-on-windows-azure-to-send-inexpensive-newsletter-email-via-amazon-ses

桌面应用程序 azure

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值