tessguefen
5/18/2015 - 5:55 PM

Tell a Friend (fancy) for Lotus

Tell a Friend (fancy) for Lotus

<?php
	$fromEmail = $_POST['fromEmail'];
	$toEmail = $_POST['toEmail'];

	if (isset($_POST['message'])) {
		$extraMessage = $_POST['message'];
	} else {
		$extraMessage ='';
	}

	$storeName = $_POST['Store'];
	$storeUrl = $_POST['storeUrl'];
	$prodUrl = $_POST['prodUrl'];
	$prodImage = $_POST['prodImage'];
	$prodName = $_POST['prodName'];
	$lotusSpecial = $_POST['taf-extra'];
	
	$subject = 'View the '.$prodName;
	
	date_default_timezone_set('UTC');
	$now = time();
	
	/* Let's prepare the message for the e-mail. */
	$message = '<p style="font-family:sans-serif; font-size: 13px;">View <a href="'.$prodUrl.'" style="color:#c66e19; text-decoration:none;">'.$prodName.'</a> I saw on <a href="'.$storeUrl.'" style="color:#c66e19; text-decoration:none;">'.$storeName.'</a></p>
				<table border="0" cellpadding="0" style="font-family:sans-serif; font-size: 13px;">
					<tr>
						<td width="250" valign="top"><img src="'.$storeUrl.'mm5/'.$prodImage.'" width="250" /></td>
						<td style="padding-left: 10px;" valign="top">'.$lotusSpecial.'</td>
						</tr>
				</table><a href="'.$prodUrl.'" style="font-family:sans-serif; font-size: 13px; color:#000; text-decoration:none;">View Full Product Details &rarr;</a><br /><br />';

	if ($extraMessage) {
	    $message = $message . $extraMessage;
	}

	/* Is the OS Windows or Mac or Linux? */
	if (strtoupper(substr(PHP_OS, 0, 3) === 'WIN')) {
		$eol = "\r\n";
	}
	elseif (strtoupper(substr(PHP_OS, 0, 3) === 'MAC')) {
		$eol = "\r";
	}
	else {
		$eol = "\n";
	}
	
	/* Set Common Headers */
	$headers = 'From: <'.$fromEmail.'>'.$eol;
	$headers .= 'Reply-To: <'.$fromEmail.'>'.$eol;
	$headers .= 'Return-Path: <'.$fromEmail.'>'.$eol;    // These two to set reply address.
	$headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
	$headers .= "X-Mailer: PHP v".phpversion().$eol;          // These two are used to help avoid spam-filters.
	$headers .= 'MIME-Version: 1.0'.$eol;
	$headers .= 'Content-Type: text/html; charset=UTF-8' .$eol;
	
	/* Send the message using mail() function */
	mail($toEmail, $subject, $message, $headers);
	
	/* Redirect visitor to the thank you page on success...error page on failue. */
	if (mail) {
		echo 'Success';
		exit();
	}
	else {
		echo 'Error';
		exit();
	}
?>

<!-- Just a nice gag in case someone can actually visit this page. -->
<p>If you want to "attack" this form, <a href="../php/clearCookie.php">try this demo</a>.</p>