Page 1 of 1

PHP Autoresponder Email

Posted: Thu Oct 30, 2014 8:25 pm
by X_JuDaH_X
I have an email that is sending out a thank you for signing up for book. I am trying to hyperlink text for the book but the email is not working. It either sends with code or does not send at all. If I remove the hyperlink the autoresponder works. Yet this defeats the purpose of the email..
Here is my code.
Thanks for all the replies.

Code: Select all

 $header .= "Content-Type: text/html\r\n";

// Subject of confirmation email.
$conf_subject = 'Your Free Book';

// Who should the confirmation email be from?
$conf_sender = 'Your Book <no-reply@something.com>';

$msg = $_POST['Name'] . ",\n\nThank you for interest in our book. To Download  <a href=\"http://something.com\">Click Here</a>";

mail( $_POST['Email'], $conf_subject, $msg, 'From: ' . $conf_sender );


    }

Re: PHP Autoresponder Email

Posted: Thu Oct 30, 2014 11:48 pm
by Christopher
If you want to send an email with HTML in it, then it needs to be MIME encoded. There is an example in the PHP docs, or use a library like SwiftMailer to deals with the painful details of emailing.

PS - If you want a plaintext email, then remove the <a> tag around the URL. Most email readers will create a link automatically.