Pass email to mailchimp unsubscribe link - mailchimp

I have an unsubscribe link that looks like this:
example.com/unsubscribe?u=foo&id=bar
This loads the typical mailchimp unsubscribe form. Is it possible to have the email address pre-populated somehow? Perhaps by adding the email in some query string parameter.

I believe you can add the parameter on the end of the URL
&EMAIL=user#domain.co.uk

Related

Pre-filling a hosted MailChimp signup form with an email address shows validation errors

We're trying to pre-fill the email address field of a hosted MailChimp form. Here's the blog post that talks about exactly this matter: https://blog.mailchimp.com/how-to-pre-fill-items-on-your-mailchimp-hosted-form/.
So here's our Newsletter signup form without any validation errors:
https://camping.us2.list-manage.com/subscribe/post?u=761a52bbd46ab21474b3af314&id=5cc638b5e6.
The problem arises when I add an email address to the URL as the value for the first form field, MERGE0, like this (url-encoding the email address, so # becomes %40):
https://camping.us2.list-manage.com/subscribe/post?u=761a52bbd46ab21474b3af314&id=5cc638b5e6&MERGE0=test%40camping.info.
Now, the form correctly copies the email address into the input field with name MERGE0 but it also displays three validation error messages:
Note: the email address field is mandatory.
When I try to pre-fill the user's first or last name fields adding MERGE1=John or MERGE2=Doe to the form's url, all is well - no error happens. It seems to be a problem with mandatory fields.
I'm arguing that this is a problem on MailChimp's side but they refuse to help saying that this is custom code and none of their business.
Can anybody help fix these errors?
It turned out that the problem was caused by a mistake in the URL.
Instead of camping.us2.list-manage.com/subscribe/POST?u=761a52bbd46ab...
it had to be camping.us2.list-manage.com/subscribe?u=761a52bbd46ab...
And the errors were gone!
This really made sense in the end, because posting the form should actually trigger the validation.

Is it possible to use nested merge tags in Mandrill?

Is it possible to use nested merge tags?
What we need is to be able to define the UNSUB tag depending on the values from other merge tags, like on this example:
<a
href="*|UNSUB:*|COMMUNITYURL|*/site/unsuscribe/user_id/*|USERID|*/hash/*|HASH|*/type/all|*">
Unsubscribe
</a>
Is this correct?
Should be done in a different way?
It's not currently possible to nest merge tags. In this case, your best bet would be to add your own List-Unsubscribe headers (using the headers parameter in the API) and pass either your own URL, or a URL constructed with your merge tags but not the UNSUB merge tag.
From the API:
What happens when the [unsubscribe] link is clicked?
If a recipient clicks the generated link, the message status is changed to Unsubscribed and > the recipient's address is added to the Rejection Blacklist in your
Mandrill account. The redirect URL will be appended to include two
querystring parameters that can be used for processing the unsubscribe
in your own system or database:
md_id - the _id, as provided in the API call and webhooks of the
specific message where the unsubscribe link was clicked
md_email - a URL-encoded version of the recipient's email address
So you don't have to worry about generating an unsubscribe url for every user. Just put a generic url and mandrill automatically will append to you the email of that user in the md_email variable.
The documentation suggest that you do this then:
Click here to unsubscribe.
And mandrill will append the correct user email and id:
http://mywebsite.com/unsub?md_email=fulanito#gmail.com&m_id=23321
Since mandrill doesn't support nested merge tags, here is the solution for the case like yours if you dont mind after user click unsub, it did't go to mandrill's black list, since the unsubsription are all handled by your app.
PER YOUR CASE:
Manually compose your unsubscribe link
e.g.
*|COMMUNITYURL|*/site/unsuscribe/user_id/*|USERID|*/hash/*|HASH|*/type/all/
At the end of your link, append the mandrill recipient email var.email=*|EMAIL|* e.g.
*|COMMUNITYURL|*/site/unsuscribe/user_id/*|USERID|*/hash/*|HASH|*/type/all/?email=*|EMAIL|*
Put the link to your mandrill template
Unsubscribe Me
reference: mandrill doc

Send copy of order confirmation email, based on customer data, to different email addresses

Magento: Based on certain customer data I need to send a copy of the confirmation email to other email addresses.
I created an observer to catch the order data
checkout_onepage_controller_success_action
In my observer class I load all data I need with
Mage::getModel('sales/order')->load($observer->getOrderIds());
That works like a charm.
Now some code is selecting the email address where the copy supposed to go to.
But how can I send a copy of the order confirmation email to (always different) email addresses?
$order->sendNewOrderEmail();
Above doesn’t work for me because I need the recipient as a parameter.
Any help will be much appreciated. Thank you.
The simplest way would be to create your own order class:
class My_Mymodule_Model_Sales_Order extends Mage_Sales_Model_Order {
public function sendNewOrderCustomEmail($email) {
// copy from parent's sendNewOrderEmail method with changed this line
// $emailInfo->addTo($this->getCustomerEmail(), $customerName);
}
}
And then in your event, use
Mage::getModel('mymodule/sales_order')
->load($order_id)
->sendNewOrderCustomEmail('myemail#...');
Magento takes emails from order data.
Try:
$order->setCustomerEmail("new#email.com");
$order->sendNewOrderEmail();

Magento variable to display payment method in email subject

I'm trying to display the payment method in the email subject for new order emails in Magento. The reason being is so that our client can easily determine from the subject of emails send from Magento whether the order came via the payment gateway or Paypal Express.
I'm not entirely sure of the best way to achieve this, I would like to think there is already something available I could use for this.
{{var payment_html}}
returns the payment method block for email templates...
{{var paymentMethod}}
returns absolutely nothing in the email subject so unsure whether this is a depreciated variable now.
I suppose there is also the option of creating a custom attribute, calling it in a static block and then displaying this as a custom variable in the email templates but it seems a rather long winded approach just to purely get a text string of "via SagePay" or "via Paypal Express".
Any help would be greatly appreciated.
Thanks in advance.
You actually don't need to perform any customization, this variable is already available in the template though the object chain. This chain is supported by Magento template and allows usage of getters of the object.
In this case you need to retrieve order's payment object, then retrieve its method instance and retrieve method title from method instance. It is very simple construction:
{{var order.getPayment().getMethodInstance().getTitle()}}
This should help you!
Method Mage_Sales_Model_Order::sendNewOrderEmail() is responsible for sending new ordr emails.
$paymentBlock = Mage::helper('payment')->getInfoBlock($this->getPayment())
->setIsSecureMode(true);
$paymentBlock->getMethod()->setStore($storeId);
$paymentBlockHtml = $paymentBlock->toHtml();
...
$mailer->setTemplateParams(array(
'order' => $this,
'billing' => $this->getBillingAddress(),
'payment_html' => $paymentBlockHtml
)
payment_html is rendered html output of the block, so you can not use it.
You can add one more assoc key (using rewite or local/mage trick) with the payment method and add this param to the subject using transactional emails.

Blank Email issue in magento for new order

In my magento website As soon as someone places order , an email is sent to his/her emailid. In the email the subject is correct but there is no body in the message, i mean the message comes blank.
i added new template from Transactional Emails section and associated this template with the Order from configuration->sales emails. but still my subject of the template reaches to mails but not the body. the message body remains empty always.
please help me solve this issue
thanks in advance
Looks like there is some error during rendering the email template. Try to replace your email template body with something simple.
Magento doesn't trigger any error when the template is not returned/processed properly.
The trace is:
Mage/Sales/Model/Order.php - sendNewOrderEmail()
Mage/Core/Model/Email/Template/Mailer.php - send()
Mage/Core/Model/Template.php - send()
Some things to check first - is the email valid for send, see the conditions below:
public function isValidForSend()
{
return !Mage::getStoreConfigFlag('system/smtp/disable')
&& $this->getSenderName()
&& $this->getSenderEmail()
&& $this->getTemplateSubject();
}
Another thing to look for:
If you copy-pasted some of the email content you might have some characters in the email that are not ASCII. This causes a crash when the template is parsed and there is no error logged/displayed.
This can be checked by using the standard Magento email template and if that works and your custom template doesn't.
I found that the cause of the error was the vars:
{{config path='trans_email/ident_support/email'}}
{{config path='general/store_information/phone'}}
If these are deleted/substituted, then the emails are being sent without errors.

Resources