Hi there, I've followed your instructions to get the welcome email to send using the API and it's still not working. The contacts are saving to my list ok, but they're not recieving the welcome email... Can you please help. Here is my code: try {
// check to see if a contact with the email addess already exists in the account
$response = $cc->getContactByEmail(ACCESS_TOKEN, $_POST['email']);
// create a new contact if one does not exist
if (empty($response->results)) {
$action = "Creating Contact";
$contact = new Contact();
$contact->addEmail($email);
$contact->addList($list);
$contact->first_name = $fname;
$contact->last_name = $lname;
$contact->custom_fields[] = CustomField::create(
array("name"=>"CustomField1","value"=>$target)
);
//Set the opt in source
$contact->optInSource = "ACTION_BY_CONTACT";
$returnContact = $cc->addContact(ACCESS_TOKEN, $contact);
// update the existing contact if address already existed
} else {
$action = "Updating Contact";
$contact = $response->results[0];
$contact->addList($list);
$contact->first_name = $fname;
$contact->last_name = $lname;
$contact->custom_fields[] = CustomField::create(
array("name"=>"CustomField1","value"=>$target)
);
$returnContact = $cc->updateContact(ACCESS_TOKEN, $contact);
}
// catch any exceptions thrown during the process and print the errors to screen
} catch (CtctException $ex) {
echo '<span class="label label-important">Error '.$action.'</span>';
echo '<div class="container alert-error"><pre class="failure-pre">';
print_r($ex->getErrors());
echo '</pre></div>';
mysql_close($id);
die();
}
... View more