Jump to content

carrietc

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Everything posted by carrietc

  1. Is it possible to use a php mail script to send an email confirmation after submit and that confirmation is HTML format? I have a working script that sends a confirmation with attachment, but I would like to format it as an HTML email. Ideas?
  2. Nevermind, figured it out. It was the path to the image that was wrong.
  3. Ok i found a new tutorial and at this point I can get the attachment name but its 0k. Also the email_txt is not showing.. hrrrmmmm any help? <?php $con = mysql_connect("localhost","",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("", $con); $sql="INSERT INTO customers (FirstName, LastName, Email, Address, City, State, ZipCode) VALUES ('$_POST[FirstName]','$_POST[LastName]','$_POST[Email]','$_POST[Address]','$_POST[City]','$_POST[state]','$_POST[Zip]')"; $result = mysql_query($sql,$con); if (!$result){ die('<META HTTP-EQUIV="Refresh" CONTENT="0;URL=http://www.gatorscaters.com">'); } header ("location: http://www.gatorscaters.com/coupon.php"); $fileatt = "http://www.gatorscaters.com/images/10Coupon.jpg"; // Path to the file $fileatt_type = "application/octet-stream"; // File Type $fileatt_name = "10Coupon.jpg"; // Filename that will be used for the file as the attachment $email_from = "myemail"; // Who the email is from $email_subject = "Your $10 OFF Coupon for Gators Dockside"; // The Subject of the email $email_txt = "Your coupon is attached! Please print and present on your next visit to Gators Dockside!"; // Message that the email has in it $email_to = $_POST['Email']; // Who the email is too $headers = "From: ".$email_from; $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message . "\n\n"; $data = chunk_split(base64_encode($data)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; $ok = @mail($email_to, $email_subject, $email_message, $headers); if($ok) { echo "<font face=verdana size=2>The file was successfully sent!</font>"; } else { die("Sorry but the email could not be sent. Please go back and try again!"); } mysql_close($con) ?>
  4. Hi guys, I have a form that currently writes to a database and sends the user to a specific page depending if they enter a unique email address. If its unique email they go to the coupon page, if its duplicate they redirect to the home page. Now the client wants the user emailed an attachment in addition to redirecting to the coupon page. I added some code from a tutorial but can't get it to work.. Can anyone look at this and point me in the right direction? Ideally I'd like to have the user emailed an html confirmation to add a little style. But i assume this is more difficult so I'll wait on that one.. <?php $con = mysql_connect("localhost","",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("", $con); $sql="INSERT INTO customers (FirstName, LastName, Email, Address, City, State, ZipCode) VALUES ('$_POST[FirstName]','$_POST[LastName]','$_POST[Email]','$_POST[Address]','$_POST[City]','$_POST[state]','$_POST[Zip]')"; $result = mysql_query($sql,$con); if (!$result){ die('<META HTTP-EQUIV="Refresh" CONTENT="0;URL=http://www.gatorscaters.com">'); } $user = $_POST['Email']; $usersubject = "Your $10 OFF Coupon for Gators Dockside"; $userheaders = "From: myemail\n"; $usermessage = "Your coupon is attached!"; $fileatt = "./10Coupon.jpg"; $fileatttype = "image/jpg"; $fileattname = "coupon.jpg"; $file = fopen($fileatt, 'rb'); $data = fread($file, filesize($fileatt)); fclose($file); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . "boundary=\"{$mime_boundary}\""; $message = "This is a multi-part message in MIME format.\n\n" . "-{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message .= "\n\n"; $data = chunk_split(base64_encode($data)); $message .= "–{$mime_boundary}\n" . "Content-Type: {$fileatttype};\n" . " name=\"{$fileattname}\"\n" . "Content-Disposition: attachment;\n" . " filename=\"{$fileattname}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "-{$mime_boundary}-\n"; if(mail($user,$usersubject,$usermessage,$userheaders)) { header ("location: http://www.gatorscaters.com/coupon.php"); } mysql_close($con) ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.