Java代码示例在web上到处都是。但其中是属性文件内容AwsCredentials.properties的一个示例
public AmazonSESMailer(Environment env) throws IOException {
this.env = env;
InputStream resource = AmazonSESMailer.class
.getResourceAsStream("/AwsCredentials.properties");
PropertiesCredentials credentials = new PropertiesCredentials(resource);
this.client = new AmazonSimpleEmailServiceClient(credentials);
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "aws");
props.setProperty("mail.aws.user", credentials.getAWSAccessKeyId());
props.setProperty("mail.aws.password", credentials.getAWSSecretKey());
this.session = Session.getInstance(props);
}
private final static Logger logger = LoggerFactory
.getLogger(AmazonSESMailer.class);
private final static String FROM = "vraptor.simplemail.main.from";
private final static String REPLY_TO = "vraptor.simplemail.main.replyTo";
private final static String SEND_REAL_EMAIL = "vraptor.simplemail.send_real_email";发布于 2015-08-22 08:58:01
getResourceAsStream("/AwsCredentials.properties")文件是由类加载器加载的,因此请将其放在web应用程序的"classes“文件夹中。那么文件的内容应该只有两行:
accessKey = UTZA...secretKey = Alj...
尽情享受
https://stackoverflow.com/questions/32151227
复制相似问题