`
smm11230704
  • 浏览: 86820 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

使用Postmark作为稳定、给力的邮件代发服务器!

 
阅读更多

一、Postmark简介

 

Postmark enables web applications of any size to deliver and track transactional email reliably, with minimal setup time and zero maintenance. We're the experts at getting your emails to the inbox, so you don't have to be.

 

作者:适用于各种情景的电子邮件专家。简单的API,简单的操作,给力的HTTP协议请求传输,零维护的电子邮件系统!

 

二、注册Postmark

 

 

访问Postmark官方网站:http://postmarkapp.com  开始犀利吧。

 

因为网站是英文的,而且基本没有中文资料,所以英文一般的同学跟上脚步别掉队哦~

 

首先,在首页点击“sign up” 进入注册页:

 

 

Full Name : //这里填入你的全名。

Email : //你的电子邮件

Password : //密码

Password again : //再次输入密码

Time Zone ://不需要管了。。

 

 

 填好之后,点击下面的“Create Account” 注册账号

 

 

 注册完毕之后提示:

         Congratulations, you have signed up successfully!

(祝贺你,你注册成功了!)

         Unfortunately, you have not setup any servers yet.

(很不幸,你还没有设置任何邮件服务器)

 

那么,接下来,点击“Setup a New Server” 设置一个新的服务器吧!

 

二、创建服务器

 

在 Add a new server 页面

 

点击页面最下方的“Next Step”

 

“Enter a name for your server ”

 为你的服务器起一个名字,再选一个颜色。然后继续点击页面最下方的“Next Step”

 

 

经过一系列的验证之后,通过!


点击“Done! Now add a sender signature” (OK!现在添加一个签名!)

 

PS:签名的意义,每一个代发服务器对应一个唯一签名,如果你希望使用a@qq.com作为名称发送邮件时候,签名是为了证实你拥有这个邮箱的所有权!※

 

 

三、得到签名

 

 

在“Add a new Signture”页面中,填写发件人的详细信息。

 

 

Full Name : //这里填入你的全名。

“From”Email : //你想作为发送邮件用的电子邮件 (“被代理”发件箱)

Reply to email: //随便填自己一个邮箱 没啥用

 

Address information 下面的随便填,都没用了。一堆字母和数字 就过了。。 

 

 点击“Create Signture”按钮

 

OK 搞定 继续点击下面的按钮,这个时候我们要在“From”Email 中接受系统发送给我们的确认邮件,

 

他会给你一个英文邮件,内容中有一个确认的link,直接点击链接,或者复制到浏览器访问。

 

接下来会提示 “Sender Signature activated.”  你的这个“发件人”被激活了。

 

那么你可以使用Postmark来帮助你发邮件了。

 

 

四、Postmark发送方式简介

 

Postmark是一个邮件解决方案,他已经在内部处理好了所有的功能,

 

说他是0维护,也就是在于此。

 

在 Postmark 的API中我们可以看到,他完全就是可以直接通过HTTP协议,将数据传输过去,之后进行邮件发送处理。

 

例如:

 

curl -X POST "http://api.postmarkapp.com/email" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "X-Postmark-Server-Token: 04128723-0e11-4a2c-a129-72bf136c6051" \ -v \ -d "{From: 'i@qq123.com', To: 'smm1988@immomo.com', Subject: 'Postmark test', HtmlBody: '<html><body><strong>Hello</strong> dear Postmark user.</body></html>'}" 

 

比如这样,直接通过HTTP协议,设置好正确的 from邮箱和绑定的 server token 就可以正常的发送邮件了!

 

Postmark  提供了多种语言支持的API:

 

我们可以在官方网站中获取所有的支持http://developer.postmarkapp.com/developer-libs.html

 

我这里是使用java开发的系统需要用,那么就来找到了java的API支持 

 

https://github.com/jaredholdcroft/postmark-java  点击downloads

 

就会下载下来一个JAVA项目包,将其导入到java项目中,其中

 

1.不要管com.postmark.java包下的内容,将其导入即可

2.导入需要的jar包 (gson、apache、http这些包)

3.修改测试类TestClient.java,填写自己的信息:

 

// The MIT License
//
// Copyright (c) 2010 Jared Holdcroft
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package com.immomo.momomail;

import java.util.ArrayList;
import java.util.List;

import com.postmark.java.NameValuePair;
import com.postmark.java.PostmarkClient;
import com.postmark.java.PostmarkException;
import com.postmark.java.PostmarkMessage;

/**
 * 
 * @author andy.lilocon 	【xiao9】
 * 
 * 2011年7月8日
 *
 * 
 *
 */

public class SendPostmark {

	private static final String apiKey = "fasdfsdd-4a2c-a129-72bf136c6051";
	
	private static final String fromMailAddress = "abcd@immomo.com";
	
	
	
	/**
	 * 
	 * @param toAddress  接收邮件地址
	 * @param subject	 邮件标题
	 * @param body		邮件内容
	 * @throws PostmarkException
	 */
	public void sendPostmark(String toAddress, String subject, String body) throws PostmarkException {

		List<NameValuePair> headers = new ArrayList<NameValuePair>();

		headers.add(new NameValuePair("HEADER", "immomo"));

		PostmarkMessage message = new PostmarkMessage(fromMailAddress,
				toAddress, fromMailAddress, null, subject, body, false, null,
				headers);

		PostmarkClient client = new PostmarkClient(apiKey);

		client.sendMessage(message);
		
	}

}

 

 

可以直接使用我的发邮件类中的方法,只需替换apiKey 和 fromMailAddress即可!so easy~

 

五、推荐者的话

  

这款国外的邮件服务非常的给力,而且很稳定,并且甚至做到零维护。

 

但是是要花钱的,不过它会提供1000封免费发送邮件,用于用户的免费体验。

 

在发完之后。会收取1000封/1.5美元 的资费。

 

建议:大型系统和力求用户体验的产品使用。

 

1
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics