1

「Web サイトで Windows Azure を使用して顧客からメールを受け取る」について教えてください。

現在、会社のウェブサイトを作成しています。このサイトでは、「お問い合わせ」ページを作成します。このページは、私の顧客からの電子メールを受け入れます。しかし、このメールは Windows Azure を使用して私のサーバーに直接到達することはできません。

このページはPHP言語で作成します。

この関数を作成できますか?

また、このページを作成するにはどうすればよいですか? これを行う方法を知っていますか?

4

1 に答える 1

0

Windows Azure 環境自体は、現在 SMTP リレーまたはメール リレー サービスを提供していません。Steve Marx は、次のことを行う優れたサンプル アプリケーション (ここからダウンロードできます)をまとめています。

続く:

サード パーティのサービス (SendGrid) を使用して、Windows Azure 内から電子メールを送信します。

入力エンドポイントを持つ worker ロールを使用して、ポート 25 で SMTP トラフィックをリッスンします。

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);
于 2013-07-03T06:55:31.407 に答える