Reputation: 817
I was just testing the email I sent through Mandrill and found out I cannot click on any content link. When I use the inspect element of my browser, what I found is:
<a>Test</a>
instead of
<a href = "http://test.com">Test</a>
This is from Mandrill's API Log:
{
"template_name": "Test_Email",
"template_content": [
{
"name": "email-content",
"content": "<a href=\\\"http://test.com/\\\">Test</a>"
}
...
What I found suspicious on the above API log is: it has 3 forward slash before and after the true link. I checked the API logs of my other working templates and they only have single forward slashes before and after the true link. So it should look like this:
"content": "<a href=\"http://test.com/\">Test</a>"
Any idea what happened here?
Here's my PHP code:
$mandrill = new Mandrill("KEY_CODE");
$message = array(
'subject' => $_POST['mass_email_subject'],
'from_email' => '[email protected]',
'to' => array(
array(
'email' => $user->user_email
)
)
);
$template_name = 'Test_Email';
$template_content = array(
array(
'name' => 'email-content',
'content' => $_POST['mass_email_content'] // '<a href = "http://test.com/">Test</a>'
)
);
$mandrill->messages->sendTemplate( $template_name, $template_content, $message );
Upvotes: 2
Views: 1510
Reputation: 817
Answer is to wrap your posted variables with the stripslashes() function of PHP.
stripslashes( $_POST['mass_email_content'] );
Upvotes: 1