如何在我的网站中使用Windows Azure接收电子邮件


How can I receive Email by using Windows Azure in my Website

我能知道"在我的网站上使用Windows Azure接收来自客户的电子邮件"吗?

现在我正在创建我的公司网站。在这个网站上,我将创建"联系我们"页面。此页面将接受我的客户的电子邮件。但此邮件无法使用WIndows Azure直接访问我的服务器。

这个页面我将用PHP语言创建。

我可以创建这个函数吗?

如何创建此页面?你知道怎么做吗?

Windows Azure环境本身当前不提供SMTP中继或邮件中继服务。Steve Marx制作了一个很棒的示例应用程序(可在此处下载),用于执行

以下内容:

它使用第三方服务(SendGrid)从内部发送电子邮件Windows Azure。

它使用具有输入终结点的工作角色来侦听SMTP25号港口的交通。

它在CDN端点上使用自定义域名来缓存Blob。

这是处理传入电子邮件的代码:

// make a container, with public access to blobs
var id = Guid.NewGuid().ToString().Replace("-", null);
var container = account.CreateCloudBlobClient().GetContainerReference(id);
container.Create();
container.SetPermissions(new BlobContainerPermissions() { PublicAccess=BlobContainerPublicAccessType.Blob });
// parse the message
var msg = new SharpMessage(new MemoryStream(Encoding.ASCII.GetBytes(message.Data)),
    SharpDecodeOptions.AllowAttachments | SharpDecodeOptions.AllowHtml | SharpDecodeOptions.DecodeTnef);
// create a permalink-style name for the blob
var permalink = Regex.Replace(Regex.Replace(msg.Subject.ToLower(), @"[^a-z0-9]", "-"), "--+", "-").Trim('-');
if (string.IsNullOrEmpty(permalink))
{
    // in case there's no subject
    permalink = "message";
}
var bodyBlob = container.GetBlobReference(permalink);
// set the CDN to cache the object for 2 hours
bodyBlob.Properties.CacheControl = "max-age=7200";
// replaces references to attachments with the URL of where we'll put them
msg.SetUrlBase(Utility.GetCdnUrlForUri(bodyBlob.Uri) + "/[Name]");
// save each attachment in a blob, setting the appropriate content type
foreach (SharpAttachment attachment in msg.Attachments)
{
    var blob = container.GetBlobReference(permalink + "/" + attachment.Name);
    blob.Properties.ContentType = attachment.MimeTopLevelMediaType + "/" + attachment.MimeMediaSubType;
    blob.Properties.CacheControl = "max-age=7200";
    attachment.Stream.Position = 0;
    blob.UploadFromStream(attachment.Stream);
}
// add the footer and save the body to the blob
SaveBody(msg, bodyBlob, message, container, permalink);