Error when adding ['title'] field to an email message subject of contact form

2 posts by 2 authors in: Forums > CMS Builder
Last Post: July 28, 2015   (RSS)

By Mikey - July 21, 2015

I'm trying to add the ['title'] field to an email message subject when some submits a form related to a specific page that the ['title'] field exist on.

However it's throwing the follow error message in bold below.

Error sending email: mail(): Bad parameters to mail() function, mail not sent.

Anyone have any suggestions on how to get this to work? Below is the code I'm using.

if (!$errorsAlerts) {
        $from        = $_REQUEST['sendto'];
$headers    = 'MIME-Version: 1.0' . "\r\n";
        $headers    .= 'Content-type: text/html; charset=utf-8' . "\r\n";
        $headers    .="From: $from \r\n";
        $to          = "zick@example.com";
        $subject     = "{$_REQUEST['firstname']} {$_REQUEST['lastname']} is interested in {$productRecord['title']}, Item Number {$productRecord['item_number']} submitted a message at {$_SERVER['HTTP_HOST']}";
        $message     = <<<__TEXT__

Thanks, Zick

By Dave - July 28, 2015

Hi Zick, 

What does this output: showme($subject);

Also, use "Reply-To: " for the user entered email and set FROM to an email on the server (like your email).  Some servers will block emails if they know the FROM address didn't originate from the server it's sent from.  Like if I enter a gmail address mail servers will know your server isn't authorized to send from random gmail addresses.

Also you might find it easier to use the sendMessage() function in /lib/common.php.  If you look in the code there's some examples on how to use it just above the function header.

Let me know how it goes.

Dave Edis - Senior Developer
interactivetools.com