Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29959

Amazon SES not sending email to the Gmail id's?

$
0
0

I am using amazon ses sdk in my app for sending the emails from the app. In android app the sdk is sending the emails to all the email addresses but from the iOS app I am not able to send the email to the Gmail email addresses. I am able to send the email to any other email service from the iOS app but it is not working with the gmail id's. I am using the below code to send the email in the raw format because I have to send the images as attachments in the email.

let credentials = AWSStaticCredentialsProvider(accessKey: "XXXXX", secretKey: "XXXXX")
let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentials)
AWSServiceManager.default().defaultServiceConfiguration = configuration

let attachment = UIImageJPEGRepresentation(image, 0)
let attachmentString = attachment!.base64EncodedString(options: .lineLength64Characters)
let MIMEDataType = "image/jpeg"
let attachmentName = "screenshot1"

let attachment2 = UIImageJPEGRepresentation(image2, 0)
let attachmentString2 = attachment2!.base64EncodedString(options: .lineLength64Characters)
let attachmentName2 = "screenshot2"

let message:String = """
Subject: \(String)
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="XXXXboundary text"

This is a multipart message in MIME format.

--XXXXboundary text
Content-Type: text/plain

\(data)

--XXXXboundary text
Content-Type: \(MIMEDataType);
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="\(attachmentName).\(MIMEDataType.components(separatedBy: "/")[1])"

\(attachmentString)

--XXXXboundary text
Content-Type: \(MIMEDataType);
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="\(attachmentName2).\(MIMEDataType.components(separatedBy: "/")[1])"

\(attachmentString2)

--XXXXboundary text--
"""

let data = message.data(using: .utf8)
let rawMessage = AWSSESRawMessage()
rawMessage?.data = data
let rawRequest = AWSSESSendRawEmailRequest()
rawRequest?.destinations = toEmail
rawRequest?.source = "xxxx@xxxx.com"

rawRequest?.rawMessage = rawMessage

AWSSES
  .default()
  .sendRawEmail(rawRequest!)
  .continueOnSuccessWith { (task) -> Any? in
       success(Strings.ResultSharedOnEmail)
   }
   .continueWith { (task) -> Any? in
       if task.error != nil {
          print("Error sending email")
          print(task.error?.localizedDescription ?? "")
          let type : String? = (task.error! as NSError).userInfo["Type"] as? String
          print("Type   : \(type ?? "")")

          let errorMessage : String? = (task.error! as NSError).userInfo["Message"] as? String
          print("Message: \(errorMessage ?? "")")

          var code : String? = (task.error! as NSError).userInfo["Code"] as? String
          code = (code != nil ? code : "Unknown")
          print("Code   : \(code ?? "")")
          failure(errorMessage ?? "")
        }
   return nil
}

Can anyone please help me with this. So that I can come to know that there is some issue with my code or there is any other issue.


Viewing all articles
Browse latest Browse all 29959

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>