How can I sent relevant email by using Amazon SES? - amazon-ses

I am using Amazon SES server for sending notifications emails to my users. I have verified email and verified domain. So SES_Client is sending emails successfully.
Here is my code:
public function send($subject, $recipients, $body, $senderName){
$response = $this->SESClient->send_email(
$senderName.'-noreply#example.com',
array(
'ToAddresses' => $recipients
),
array(
'Subject' => array(
'Data' => $subject,
'Charset' => 'UTF-8'
),
'Body' => array(
'Text' => array(
'Data' => $body,
'Charset' => 'UTF-8'
),
'Html' => array(
'Data' => $body,
'Charset' => 'UTF-8'
)
)
)
);
return $response->isOK();
}
Problem:
How can I pass parameters values in email text that are belongs to individual recipient in recipients array?
Is there a way at amazon server where I can create queue of my recipients and when SES server will send my email. It will replace all parameters values that belongs to each recipient.

The ToAddresses field should be an array.
Is there a way at amazon server where I can create queue of my recipients and when SES server will send my email. It will replace all parameters values that belongs to each recipient.
No, AWS and the SES service does not currently support this.

Related

Access Custom S3 Metadata After Completing Multipart Upload

I'm wanting to access the custom metadata for an object uploaded via the S3 multipart upload after firing off the completeMultipartUpload method.
I initiate a multipart S3 upload with some added custom metadata like so:
$response = $this->client->createMultipartUpload([
'Bucket' => $this->bucket,
'Key' => $key,
'ContentType' => $type,
'Expires' => 60,
'Metadata' => [
'file-guid' => $fileGuid,
],
]);
When I complete the multipart upload, I'm wanting to access the file-guid metadata and pass it along in my response.
$result = $this->client->completeMultipartUpload([
'Bucket' => $this->bucket,
'Key' => $key,
'UploadId' => $uploadId,
'MultipartUpload' => [
'Parts' => $parts,
],
]);
$fileGuid = $result['?'] // Couldn't find the metadata in the result.
return response()->json(['file-guid' => $fileGuid]);
I've checked the S3 object after it's been uploaded and it shows the custom metadata, but I don't see how to access it. I assumed it would be part of the completeMultipartUpload response, but I'm not seeing it.
Any help would be appreciated. Thanks!
I found a solution, but it involves an additional request. If anyone knows of a way to access the metadata without making another request, that would be better.
$headObject = $this->client->headObject([
'Bucket' => $this->bucket,
'Key' => $key,
]);

Is it possible to send a keyboard without sending text or a message at telegram

I try to send and delete the message but not working
if($new = $bot->sendMessage([
'chat_id' => $call_chat_id,
'text' => ' ',
'parse_mode' => 'HTML',
'reply_markup' => $choose,
])){
$bot->deleteMessage([
'chat_id' => $chat_id,
'message_id' => $new['message_id']
]);
}
am using Telegram-bot-simple
No there is no way to send keyboard without sending a message

Shopify: invite emails not sending to customers

From outside system built in PHP, I wrote this following to call API for create customer account:
'customer' =>
array (
'first_name' => $_POST['datalog']['firstName'],
'last_name' => $_POST['datalog']['lastName'],
'email' => $_POST['datalog']['email'],
'verified_email'=> true,
'password'=> $rand_pass,
'password_confirmation' => $rand_pass,
//'send_email_welcome' => true,
'send_email_invite' => true,
),
Creation of customers are working successfully but they did not receive any invitation email. I have followed the Shopify Documentation : https://help.shopify.com/api/reference/customer
Try using the Customer Invites API: https://help.shopify.com/api/reference/customer#send_invite

Slack API: How to reply for an attachment action?

I've created an integration with Slack as a WebHook APP. The code is to send a message to a slack channel, using the chat.postMessage method, with some attachment actions, then when the user click the action button, I send him a success message. I'm trying to do something like this:
https://api.slack.com/img/api/message_guidelines/Example_6.gif
The problem is when I try to send the success message. Slack is receiving only the text part of the answer. Here is the code:
$message = 'Pre-text message';
$attachments = array(
array(
"title" => 'Title message',
"author_name" => 'My name',
"author_link" => 'https://www.facebook.com/',
"author_icon" => 'https://graph.facebook.com/v2.6/picture',
"image_url" => 'https://i.scdn.co/image',
),
);
$answer = array(
'text' => $message,
'attachments' => json_encode($attachments)
)
How can I do to Slack show the answer with the attachment part as shown in the image above? If I comment the text part on $answer, Slack show an error to user ('Oh no, something went wrong. Please try that again.'). Many thanks for any help.
I found the solution. Posting here to help somebody with the same problem. When you posting a message, should json_encode the attachment part, but when posting the attachment action answer, is not necessary. Here is the solution:
$message = 'Pre-text message';
$attachments = array(
array(
"title" => 'Title message',
"author_name" => 'My name',
"author_link" => 'https://www.facebook.com/',
"author_icon" => 'https://graph.facebook.com/v2.6/picture',
"image_url" => 'https://i.scdn.co/image',
),
);
$answer = array(
'text' => $message,
'attachments' => $attachments
)

Mandrill's UNSUB merge tag not getting parsed

I'm trying to make it so when someone clicks on the unsubscribe link in an email sent via the Mandrill API (using PHP) it works as described in: http://help.mandrill.com/entries/23815367-Can-I-add-an-automatic-unsubscribe-link-to-Mandrill-emails-
The *|UNSUB|* merge tag is not getting parsed. It just comes through in the the body of the email received.
Near the end of the message content ($message_content) I have:
Click here to unsubscribe.
In Gmail, the link is: Click here to unsubscribe.
(NOT a valid HREF, so Gmail just ignores the anchor tag)
In Outlook 2010 the link is: Click here to unsubscribe.
(Not a valid HREF)
Is there some merge_vars parameter I should add to the headers?
http://help.mandrill.com/entries/21678522-How-do-I-use-merge-tags-to-add-dynamic-content- mentions them, but I can't find what the parameter should be for the UNSUB merge tag.
$mandrill = new Mandrill($mandrill_api_key);
$message = array(
'html' => $message_content,
'subject' => $subject,
'from_email' => 'me#mydomain.com',
'from_name' => 'MY NAME',
'to' => $to_list,
'headers' => array('Reply-To' => 'me#mydomain.com'),
'important' => false,
'track_opens' => 1,
'track_clicks' => null,
'auto_text' => null,
'auto_html' => null,
'inline_css' => null,
'url_strip_qs' => null,
'preserve_recipients' => 0,
'view_content_link' => 1,
'tracking_domain' => null,
'signing_domain' => null,
'return_path_domain' => null,
'merge' => true,
'global_merge_vars' => array(
array(
'unsub' => 'unsub'
)
),
);
What step am I missing?
TIA!
The problem was the URL was missing a slash (http:/mydomain...)
This was caused by TinyMCE converting URLs. I added convert_urls: false to the tinymce.init and that solved my problem.
Kudos to Mandrill Support for helping me identify the problem.