首先登陸然后進入控制臺
打開左側(cè)菜單找到郵件推送的菜單
這是郵件的主頁面
新建發(fā)信域名 email.xxx.com
點擊配置
配置域名
對應(yīng)的填上就好了 然后到2的驗證 就可以了
代碼實現(xiàn) –
添加maven
<!--發(fā)送郵件--> <dependency> <groupId>com.aliyun</groupId> <artifactId>aliyun-java-sdk-core</artifactId> <version>3.0.0</version> </dependency> <dependency> <groupId>com.aliyun</groupId> <artifactId>aliyun-java-sdk-dm</artifactId> <version>3.1.0</version> </dependency>
代碼實現(xiàn)
/** * @param code */ public static void sendRegisterCode(String code, String email) { // 如果是除杭州region外的其它region(如新加坡、澳洲Region),需要將下面的"cn-hangzhou"替換為"ap-southeast-1"、或"ap-southeast-2"。 IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", "xxxx", "xxx"); IAcsClient client = new DefaultAcsClient(profile); SingleSendMailRequest request = new SingleSendMailRequest(); try { request.setAccountName("xxx@email.xxxx.cn"); request.setFromAlias("xxxxx"); request.setAddressType(1); request.setTagName("register"); request.setReplyToAddress(true); request.setToAddress(email); request.setSubject("xxx 注冊賬號"); request.setHtmlBody("您的驗證碼是:" + code); SingleSendMailResponse httpResponse = client.getAcsResponse(request); System.out.println(httpResponse); } catch (ClientException e) { e.printStackTrace(); } }
文章是本人在工作中學習終結(jié)得到,如果有不對的地方,請小伙伴們私聊或者評論一起探討。
版權(quán)聲明:本文內(nèi)容由互聯(lián)網(wǎng)用戶自發(fā)貢獻,該文觀點僅代表作者本人。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔相關(guān)法律責任。如發(fā)現(xiàn)本站有涉嫌抄襲侵權(quán)/違法違規(guī)的內(nèi)容, 請發(fā)送郵件至2705686032@qq.com 舉報,一經(jīng)查實,本站將立刻刪除。原文轉(zhuǎn)載: 原文出處: