如何使用不同地区的aws发送电子邮件?

时间:2018-02-26 10:26:53

标签: amazon-web-services amazon-ec2 amazon-ses

我们需要发送来自我们在EC2实例上托管的网站的邀请电子邮件。我们的常规电子邮件服务由Google托管。

问题是我们位于美国东俄亥俄州地区,那里没有SES。那么我们可以仅仅为了使用SES来改变我们的地区吗?它会影响我们的EC2实例吗?找不到任何关于此的文件。

当我尝试发送电子邮件时,错误来了

chmod 777 public -R

消息:'无法访问的主持人:{ UnknownEndpoint: Inaccessible host: `email.us-east-2.amazonaws.com'. This service may not be available in the `us-east-2' region. at Request.ENOTFOUND_ERROR (/home/pc-09/PlayScoreApi's/node_modules/aws-sdk/lib/event_listeners.js:456:46) at Request.callListeners (/home/pc-09/PlayScoreApi's/node_modules/aws-sdk/lib/sequential_executor.js:105:20) at Request.emit (/home/pc-09/PlayScoreApi's/node_modules/aws-sdk/lib/sequential_executor.js:77:10) at Request.emit (/home/pc-09/PlayScoreApi's/node_modules/aws-sdk/lib/request.js:683:14) at ClientRequest.error (/home/pc-09/PlayScoreApi's/node_modules/aws-sdk/lib/event_listeners.js:295:22) at ClientRequest.<anonymous> (/home/pc-09/PlayScoreApi's/node_modules/aws-sdk/lib/http/node.js:89:19) at ClientRequest.emit (events.js:160:13) at TLSSocket.socketErrorListener (_http_client.js:389:9) at TLSSocket.emit (events.js:160:13) at emitErrorNT (internal/streams/destroy.js:64:8) at process._tickCallback (internal/process/next_tick.js:152:19) us-east-2 \'地区。',   代码:'UnknownEndpoint',   地区:'us-east-2',   主机名:'email.us-east-2.amazonaws.com',   可重试的:是的,   originalError:    {错误:getaddrinfo ENOTFOUND email.us-east-2.amazonaws.com email.us-east-2.amazonaws.com:443     在errnoException(dns.js:55:10)     在GetAddrInfoReqWrap.onlookup [as oncomplete](dns.js:97:26)      消息:'getaddrinfo ENOTFOUND email.us-east-2.amazonaws.com email.us-east-2.amazonaws.com:443',      代码:'NetworkingError',      错误:'ENOTFOUND',      系统调用:'getaddrinfo',      主机名:'email.us-east-2.amazonaws.com',      主持人:'email.us-east-2.amazonaws.com',      港口:443,      地区:'us-east-2',      可重试的:是的,      时间:2018-02-26T10:08:25.003Z},   时间:2018-02-26T10:08:25.003Z}'UnknownEndpoint:无法接入的主持人:email.us-east-2.amazonaws.com\'. This service may not be available in the us-east-2 \'区域。\ n在Request.ENOTFOUND_ERROR(/ home / pc-09 / PlayScoreApi \' s / node_modules / aws -sdk / lib / event_listeners.js:456:46)\ n在Request.callListeners(/home/pc-09/PlayScoreApi\'s/node_modules/aws-sdk/lib/sequential_executor.js:105 :20)\ n在Request.emit(/home/pc-09/PlayScoreApi\'s/node_modules/aws-sdk/lib/sequential_executor.js:77:10),在Request.emit(/ home / pc-) 09 / PlayScoreApi \'s / node_modules / aws -sdk / lib / request.js:683:14)\ n在ClientRequest.error(/ home / pc-09 / PlayScoreApi \'s / node_modules / aws-sdk / lib / event_listeners.js:295:22)\ n在ClientRequest上。 (/home/pc-09/PlayScoreApi\'s/node_modules/aws-sdk/lib/http/node.js:89:19)\n在ClientRequest.emit(events.js:160:13)\ n在TLSSocket .socketErrorListener(_http_client.js:389:9)\ n在TLSSocket.emit(events.js:160:13)\ n在emitErrorNT(internal / streams / destroy.js:64:8)\ n at process._tickCallback(内部/过程/ next_tick.js:152:19)'

2 个答案:

答案 0 :(得分:1)

使用来自其他地区的SES端点没问题,它可以正常工作 - 可能会有一些与区域外带宽费用相关的额外费用,因为ec2实例会将流量发送到另一个地区,但除非你是发送大量的电子邮件,我无法想象它会有多大意义。

答案 1 :(得分:0)

谢谢大家回答,我已经通过在没有AWS Config的nodejs中使用简单SMTP(如nodemailer)发送邮件来解决此问题。因此,当我在AWS服务器上加载代码时,它会发送邮件。