Jump to content

Search the Community

Showing results for tags 'email'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

  1. Hi I've inherited a form that sends the basic text email for output. I want to style this with html so the output forms into two columns in a table. I can see how others have incorporated html into their php script, but can't work out how to do it for the coded forms I have. See code below. $diyf_today = date("jS F Y"); $diyf_subject = "Staff and Student Room Booking Request"; $diyf_feedback = " Student Number: $studentno \r\n School, College or Unit: $unit \r\n Name: $name \r\n Email: $email \r\n Phone: $phone \r\n Event: $event \r\n Event Description: $eventdesc \r\n Event Date: $eventdate \r\n Event Time: $eventtime \r\n Location: ".implode(', ', ${'location[]'})." \r\n If external location: \r\n - External Name of location: $extname \r\n - External Contact Person: $extperson \r\n - External Contact Email: $extemail \r\n - External IP Address: $extIP \r\n \r\n Number Attending: Coffs $coffs; GC $gc; Lismore $lismore; NMSC $nmsc; THSS $thss; External $ext \r\n Do you require videolink: $videolink \r\n Location of videolink: $videolocation \r\n Do you require recording: $recorded \r\n Do you require additional AV equipment and support: $av \r\n - Type of equipment and support: $equip \r\n Do you require additional support: $support \r\n - Type of additional support: $support1 \r\n Additional Comments: $comment "; $diyf_mailTo = "luke.davis@scu.edu.au"; $diyf_mailSubject = stripslashes($diyf_subject); $diyf_mailBody = stripslashes($diyf_feedback); $diyf_mailBody .= "\r\n\r\nThis Room Booking Request form was sent from the Student website on the $diyf_today \r\nReturn Email: $email"; // Do not allow anything in here but valid emails, MUST pass through email validation, DO NOT put anything else in here!!! $diyf_mailHeader= "From: $email\r\n" . "Reply-To: $email\r\n" . "X-Mailer: PHP/" . phpversion(); $diyf_mailHeaderToUser= "From: $diyf_mailTo\r\n" . "Reply-To: $diyf_mailTo\r\n" . "X-Mailer: PHP/" . phpversion(); $sent = mail($diyf_mailTo,$diyf_mailSubject,$diyf_mailBody,$diyf_mailHeader); $returned = mail($email,$diyf_mailSubject,$diyf_mailBody,$diyf_mailHeaderToUser); if (!$sent || !$returned) { echo '<body><center><br><br><font face=verdana color="Gray"> Sorry, There was a problem submiting your form.<br> Please use your browser\'s back button and re-submit the form.</font></center></body>'; } else { echo ' ';// This gets around the PHP bug for self submitting forms submitting twice on redirect. stupid bugs header("Location: $diyf_success_page"); }
  2. So basically I am attempting to make my code work with AJAX also to get rid of the page refreshing to the user. It does physically submit the data to the file and write it how it is supposed to be. However the notifications are not working at all. I am not the best at bug shooting JS stuff as I don't use it a lot - but would be grateful if someone can point out where I am going wrong. <!DOCTYPE html> <html> <head> <meta charset=utf-8 /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name="HandheldFriendly" content="true" /> <link rel="stylesheet" type="text/css" href="css/default.css" /> <script src="scripts/jquery-1.11.1.min.js"></script> <script> $(document).ready(function() { $('#formContainer').submit(function() { var formData = $(this).serialize(); $.post('index.php', formData, processData); function processData(data) { if (data=='1') { $('.form').html('<p>success</p>'); } else if (data=='2') { $('#form').prepend('<p>already exists</p>'); } else if (data=='3') { $('#form').prepend('<p>fail</p>'); } } return false; }); }); </script> <title>WyTraining</title> </head> <body class="background"> <header> <div class="logo"><a href="index.php"><img src="images/logo.png" alt="wyTraining"></a></div> </header> <div class="form"> <div class="title">coming soon</div> <?php /* email entered = 1 */ /* email exists = 2 */ /* email incorrect = 3 */ if($_SERVER['REQUEST_METHOD'] == 'POST') { $trimmed = array_map('trim', $_POST); if(filter_var($trimmed['email'], FILTER_VALIDATE_EMAIL)) { $file = 'data\emails.txt'; if( strpos(file_get_contents($file),$trimmed['email']) == false) { $email = $trimmed['email']; echo '1'; $current = file_get_contents($file); $current .= "$email,\n"; file_put_contents($file, $current); } else { echo '2'; } } else { echo '3'; } } ?> <center><form action="index.php" method="POST" id="formContainer"> <input type="text" name="email" value="" placeholder="enter email to stay updated" autocomplete="off"/> <input type="submit" name="submit" value=" " class="button"/> </form></center> </div> </body> </html>
  3. I want to do something like this, I had a html query submission form linked to php. I want to send the output generated after php execution to the user through mail id provided in the form, in a manner such that when user click submit button, he well be redirected to thank you page and php keeps on running in the background and as soon as the output is generated, it will be send to the end user through email. As my query takes time to execute, so I don't want the end user to keep waiting till the program gets finish. Here is my code: <?php $seq = $_POST['seq']; if (isset($_POST['seq'])) { $b = fopen("sequence.txt", "w"); fwrite($b, $seq); fclose($b); system("perl /opt/lampp/htdocs/matepred/blast/bin/scriptforblastcompleterun.pl sequence.txt nr > out"); system("perl /opt/lampp/htdocs/matepred/blast/bin/format.pl > output"); system("perl /opt/lampp/htdocs/matepred/blast/bin/testing.pl output"); echo "<div align='center'><font color='blue'><b>RESULT</font></div>"; $i=1; $files = array(); foreach (glob("file_*.out")as $file) { $files[] = $file; $b = fopen("/opt/lampp/htdocs/matepred/blast/bin/$file", "r"); $s=fgets($b); fclose($b); echo "<table border=10. align=center><tr bgcolor=lightgreen><th>SerialNo</th><th>Value</th><th>Decision</th><th></tr>"; echo '<td>'. $i++. '</td>'; echo "<td>$s</td>"; if($s>=0) { echo "<td>Yes</td>"; } else { echo"<td>No</td>"; } echo "</table>"; } } ?> html table part marked in red here is the output which I want to send back to the user. Can anybody help me in linking my php output to the mail. Thanks in advance.
  4. Hi! We have a form that's been used for years, and now we would like to have the added capability of attaching an image. (So a consumer can send us an image that might help with their problem.) Currently, a "confirmation" email is sent to the consumer with all of the info they gave us; a copy of the same information also goes to us. We would like the consumer's image to be saved onto our server, so when we look at the completed form, the "Image:" line has a link to that page. I.e. a consumer attaches an image named "picture.jpg". The copy of the information we get would have a line that reads: "Image: http://www.example.com/test/uploads/picture.jpg". I'm assuming I would use a variable to get the image name to display in order to complete the link. I'm lost about which variable I would use... but that might be because I can't get the image to even save in the folder (I think) it's supposed to. Obviously there's something messed up, but I am lost as to what that is. Any help would be greatly appreciated! The field to attach the image on the form: <label for="upload_file" class="main-label">If you have an image that would help us assist you, please attach it here.</label> <input type="file" name="uploaded_file"> The process file (the attachment part is at the bottom): <?php //Collect contact form data //Check Special Field //Email ASC & Webmaster //Email Sender //Redirect to thank you page require_once($_SERVER['DOCUMENT_ROOT'].'/includes/functions.php'); /******** CONTACT DATA **********/ $name = stripslashes($_POST['name']); $company = stripslashes($_POST['company']); $address = stripslashes($_POST['address']); $city = stripslashes($_POST['city']); $state = stripslashes($_POST['state']); $zipcode = stripslashes($_POST['zipcode']); $country = stripslashes($_POST['country']); $website = $_POST['website']; $phone = stripslashes($_POST['phone']); $fax = stripslashes($_POST['fax']); $email = stripslashes($_POST['contact']); $Referred = stripslashes($_POST['referred']); $CustomerType = stripslashes($_POST['CustomerType']); $Comments = stripslashes($_POST['comments']); $ConsumerHelp = stripslashes($_POST['ConsumerHelp']); $UPC = stripslashes($_POST['UPC']); $Describe = stripslashes($_POST['Describe']); $uploaded_file = ($_FILES['uploaded_file']); /******** CHECK SPECIAL FIELD **********/ $spamcheck = stripslashes($_POST['email']); //if spamcheck isnt blank exit page, no need for error message to user, as its a spam bot if ($spamcheck!=="") { exit; } /******** EMAIL ASC & WEBMASTER **********/ $message = " ----------------------------------------------------------------------------- Information Inquiry ----------------------------------------------------------------------------- $name has visited the web site and would like some information. The details they entered on the website are: Name: $name Company: $company Address: $address City: $city State: $state Zip Code: $zipcode Country: $country Website: $website Phone: $phone Fax: $fax Email: $email Referred to web site: $Referred CustomerType: $CustomerType Comments: $Comments I need help with: $ConsumerHelp UPC code or Item #: $UPC What I am looking for: $Describe Image: $uploaded_file Kind Regards, "; $email_address = "example@example"; $subject = "Information Inquiry"; $headers = "From: $name <$email>"; $message = str_replace("\r",'',$message); //fixes postfix php bug that double spaces messages /******** EMAIL SENDER **********/ $message2 = " ----------------------------------------------------------------------------- Re: Information Inquiry ----------------------------------------------------------------------------- Thank you $name for visiting the web site. We will be using the details you entered to contact you. Name: $name Company: $company Address: $address City: $city State: $state Zip Code: $zipcode Country: $country Website: $website Phone: $phone Fax: $fax Email: $email Referred to web site: $Referred CustomerType: $CustomerType Comments: $Comments I need help with: $ConsumerHelp UPC code or Item #: $UPC What I am looking for: $Describe Kind Regards, "; $email_address2 = "$email"; $subject2 = "Re: Information Inquiry"; $headers2 = "From: <example@example.com>"; $message2 = str_replace("\r",'',$message2); //fixes postfix php bug that double spaces messages //send message 1 and save result in success var (either true for success, or false for fail $success = mail($email_address, $subject, $message, $headers); //conditionally send message2, no need to check success on this one if (strpos($email,'@aol.com') == false) { mail($email_address2, $subject2, $message2, $headers2); } if (!$success) { // What happens when the form does not validate header("Location: sorry.php"); die (); } else { // Your code here to handle a successful verification header("Location: thanks.php"); $success; } ?> <?php $allowedExts = array("gif", "jpeg", "jpg", "png"); $temp = explode(".", $_FILES["uploaded_file"]["name"]); $extension = end($temp); if ((($_FILES["uploaded_file"]["type"] == "image/gif") || ($_FILES["uploaded_file"]["type"] == "image/jpeg") || ($_FILES["uploaded_file"]["type"] == "image/jpg") || ($_FILES["uploaded_file"]["type"] == "image/pjpeg") || ($_FILES["uploaded_file"]["type"] == "image/x-png") || ($_FILES["uploaded_file"]["type"] == "image/png")) && ($_FILES["uploaded_file"]["size"] < 20000) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["uploaded_file"]["error"] . "<br>"; } else { echo "Upload: " . $_FILES["uploaded_file"]["name"] . "<br>"; echo "Type: " . $_FILES["uploaded_file"]["type"] . "<br>"; echo "Size: " . ($_FILES["uploaded_file"]["size"] / 1024) . " kB<br>"; echo "Temp file: " . $_FILES["uploaded_file"]["tmp_name"] . "<br>"; if (file_exists("upload/" . $_FILES["uploaded_file"]["name"])) { echo $_FILES["uploaded_file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["uploaded_file"]["tmp_name"], "upload/" . $_FILES["uploaded_file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?>
  5. Hi - we're trying to attach a .pdf to an email and mail it to a client - not working -- here's the code - l'll highlight what I think I understand... =) I've inherited this php project and I'm in no way a PHP person though I can usually do minor fixes -- this is beyond me however. The owner of the site said that up until a year ago, this code was working. ps - I've tried incorporating swiftmailer and phpmailer but don't know how to configure those using this password verifying code and an "include" that's not a .pdf question - is this code fixable and if so, how? <?php orange = goes to database, verifies passwords, that the report was paid for, etc - oks access and sets the "to" email address as $i_email $i_get_sid = isset($_GET["sid"]) ? (int)$_GET["sid"] : $i_sid; $i_get_pass = isset($_GET["a"]) ? $_GET["a"] : $_SESSION['r_pass']; $i_get_pass = addslashes($i_get_pass); $i_qry1 = db_qry("SELECT * FROM reports WHERE sid={$i_get_sid} AND ispurchased=1 AND isenabled=1 AND passhash='$i_get_pass'") or die("Error: report-4, SQL request error #1 ".mysql_error()); if($i_qry1) { if($i_rec1=mysql_fetch_array($i_qry1)) { $i_fname = $i_rec1["fname"]; $i_lname = $i_rec1["lname"]; $i_email = $i_rec1["email"]; } db_free_result($i_qry1); } blue - imports the file where the pdf is generated using FPDF, gives it the variable $data and attaches(or embeds? - not sure) to the email if(!empty($i_email)) { ob_start(); include('inc/pages/report-3.inc.php'); $data = ob_get_contents(); ob_end_clean(); $data = wordwrap(base64_encode($data), 72, "\n", true); $i_boundary = '----------'.bin2hex(mhash(MHASH_MD5, time())); $i_headers = "From: oursite.com <info@oursite.com> green - sets the content of the email message X-Mailer: oursite.com PHP Mail (v1.0) Reply-To: oursite.com <info@oursite.com> X-Priority: 3 (Normal) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=\"$i_boundary\""; $i_message = "--$i_boundary Content-Type: text/plain; charset=\"iso-8859-1\" Content-Transfer-Encoding: 7bit Dear ".$i_fname." ".$i_lname.", Here is the report you asked for, attached as an Adobe Acrobat document. If you do not already have one, an Adobe Acrobat reader can be downloaded for free at http://www.adobe.com/. ---- Best regards, Sports Team mailto:info@oursite.com --$i_boundary Content-Type: APPLICATION/PDF; name=\"report.pdf\" Content-transfer-encoding: base64 Content-Disposition: attachment; filename=\"report.pdf\" $data {$i_boundary}-- "; shows a new message in the browser to the user saying the emails been sent @mail($i_email, ' Sports - Your Report', $i_message, $i_headers); @mail('null@sight2k.com', 'Sports - Your Report', "ID - $i_get_sid", $i_headers); } header('Content-type: text/html'); $m_header = '<link href="shared/report.css" rel=stylesheet type="text/css">'; require_once($DOCUMENT_ROOT."inc/top-2.inc.php"); $i_get_sid = isset($_GET["sid"]) ? (int)$_GET["sid"] : $i_sid; $i_get_pass = isset($_GET["a"]) ? $_GET["a"] : $_SESSION['r_pass']; $i_get_pass = addslashes($i_get_pass); echo '<table cellpadding=0 cellspacing=0 border=0 width="100%">'; echo '<tr vAlign=top><td height=7><img src="images/1x1.gif" width=1 height=7></td></tr>'; echo '<tr height=28 style="background: url(images/bookm-bg.gif) repeat-x"><td width="100%"><nobr>'; echo '<img src="images/1x1.gif" width=5 height=1><a href="report.php?sid='.$i_get_sid.'&a='.urlencode($i_get_pass).'"><img src="images/bookm-42.gif" width=67 height=28 border=0></a><a href="report.php?sid='.$i_get_sid.'&a='.urlencode($i_get_pass).'&b=pdf"><img src="images/bookm-s3.gif" width=10 height=28 border=0><img src="images/bookm-52.gif" width=65 height=28 border=0></a> <a href="report.php?sid='.$i_get_sid.'&a='.urlencode($i_get_pass).'&b=/report.pdf"><img src="images/button-downloadpdf.gif" width=80 height=28 border=0></a> <a href="report.php?sid='.$i_get_sid.'&a='.urlencode($i_get_pass).'&b=email"><img src="images/button-emailpdf.gif" width=80 height=28 border=0></a>'; echo '</nobr></td><td><nobr><font style="font-size: 10px;"><a href="javascript:window.close();">Close Window</a> </font></nobr></td></tr></table>'; echo "<p> Thank you."; echo "<p> Your report has been successfully sent."; require_once($DOCUMENT_ROOT."inc/btm-2.inc.php"); // header("location: report.php?sid=$i_get_sid&a=".urlencode($i_get_pass)); ?> >>>>>The output is this instead of an email with attachment: ------------fd755da9fdf74bb9c832b8a95272fd4b Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Dear "client", Here is the report you asked for, attached as an Adobe Acrobat document. If you do not already have one, an Adobe Acrobat reader can be downloaded for free at http://www.adobe.com/. ---- Best regards, Sports Team mailto:info@oursite.com ------------fd755da9fdf74bb9c832b8a95272fd4b Content-Type: APPLICATION/PDF; name="report.pdf" Content-transfer-encoding: base64 Content-Disposition: attachment; filename="report.pdf" JVBERi0xLjMKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL1Jlc291cmNl cyAyIDAgUgovQ29udGVudHMgNCAwIFI+PgplbmRvYmoKNCAwIG9iago8PC9GaWx0ZXIgL0Zs YXRlRGVjb2RlIC9MZW5ndGggMzE1Pj4Kc3RyZWFtCnicdVLLTsMwELznK+YIUnHtXTuxb0BL JbghIu6hpKgoaUqSgvr3rBNCAQlbstfemdnxg3CXaOUyfCTXOeYrA2OU1sg3uMmTN1jn4jL2 .....(goes on forever)
  6. Just want to get clarification on what this does and why you'd want it displayed in email output: .bin2hex(mhash(MHASH_MD5, time())) Thanks
  7. Hi Prior to a few months ago, when a user hit the final submit button on our site (fitness testing) - the athlete's report (actually an email with a link to view their results) would be automatically be emailed to them and we'd also get an email confirming the test was taken. Now, we still get the confirmation email but the athlete doesn't receive an email. I've located this code and am wondering if there's additional code we need to add to get the process working again: # Email the secret link to the athlete: $i_secret_url = $set_baseurl.'report.php?sid='.$i_sid.'&a='.urlencode($i_passhash); $i_headers = "From: ManOfSteeleSports.com <info@manofsteelesports.com>\nX-Mailer: ManOfSteeleSports.com PHP Mail v1.0\nReply-To: ManOfSteeleSports.com <info@manofsteelesports.com>\nX-Priority: 3 (Normal)"; $i_message = 'Dear '.stripslashes($i_rec1["fname"]).' '.stripslashes($i_rec1["lname"]).', Thanks for the advice in advance!
  8. Hi guys How do I get a thank you message on the same page instead of redirecting the message to a different page as on the script here - header('Location: thanks.html'); Also I want the errors to be echoed in front of the field concerned as in name, email, subject, message <?php $myemail = "hila@gmail.com"; $name = check_input($_POST['name'], "Enter your name"); //error or success message echoed here $subject = check_input($_POST['subject'], "Enter a subject");//error or success message echoed here $email = check_input($_POST['email']);//error or success message echoed here $message = check_input($_POST['message'], "Write your message");//error or success message echoed here if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)) { show_error("E-mail address not valid"); } $message = " Name: $name E-mail: $email Subject: $subject Message: $message "; mail($myemail, $subject, $message); //This is where the problem is header('Location: thanks.html'); //Want to have this message on the same page exit(); function check_input($data, $problem=''){ $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0){ show_error($problem); } return $data; } function show_error($myError) { ?> <html><head> <title> email 2014</title> </head> <body> <strong><?php echo $myError; ?></strong><br /><br /> <form class="email" action="" method="post"> <p>Name:</p> <input type="text" name="name" /> <p>E-mail:</p> <input type="text" name="email" /> <p>Subject:</p> <input type="text" name="subject" /> <p>Message:</p> <textarea name="message"></textarea></p> <input class="send" type="submit" value="Send"> </form> <?php exit(); } ?> </body></html>
  9. Would anyone know why my email confirmation would work sometimes and not other times. Yesterday I tried registering a new member to my site 5 times. The info would go through to the database but he never received the confirmation email. Today, I tried it again and it went through!!!
  10. hi is there any way to create an .edu email address with php ? without a .edu website ?
  11. okay i dont know where to put this topic, if it needs to be moved then please do so, I have been creating a mass mailer with this class, <?php class SimpleMail { private $toAddress; private $CCAddress; private $BCCAddress; private $fromAddress; private $subject; private $sendText; private $textBody; private $sendHTML; private $HTMLBody; public function __construct() { $this->toAddress = ''; $this->CCAddress = ''; $this->BCCAddress = ''; $this->fromAddress = ''; $this->subject = ''; $this->sendText = false; $this->textBody = ''; $this->sendHTML = true; $this->HTMLBody = ''; } public function setToAddress($value) { $this->toAddress = $value; } public function setCCAddress($value) { $this->CCAddress = $value; } public function setBCCAddress($value) { $this->BCCAddress = $value; } public function setFromAddress($value) { $this->fromAddress = $value; } public function setSubject($value) { $this->subject = $value; } public function setSendText($value) { $this->sendText = $value; } public function setTextBody($value) { $this->sendText = false; $this->textBody = $value; } public function setSendHTML($value) { $this->sendHTML = $value; } public function setHTMLBody($value) { $this->sendHTML = true; $this->HTMLBody = $value; } public function send($to = null, $subject = null, $message = null, $headers = null) { $success = false; if (!is_null($to) && !is_null($subject) && !is_null($message)) { $success = mail($to, $subject, $message, $headers); return $success; } else { $headers = array(); if (!empty($this->fromAddress)) { $headers[] = 'From: ' . $this->fromAddress; } if (!empty($this->CCAddress)) { $headers[] = 'CC: ' . $this->CCAddress; } if (!empty($this->BCCAddress)) { $headers[] = 'BCC: ' . $this->BCCAddress; } if ($this->sendText && !$this->sendHTML) { $message = $this->textBody; } elseif (!$this->sendText && $this->sendHTML) { $headers[] = 'MIME-Version: 1.0'; $headers[] = 'Content-type: text/html; charset="iso-8859-1"'; $headers[] = 'Content-Transfer-Encoding: 7bit'; // $headers[] .= 'Content-Transfer-Encoding: quoted-printable'; $message = $this->HTMLBody; } elseif ($this->sendText && $this->sendHTML) { $boundary = '==MP_Bound_xyccr948x=='; $headers[] = 'MIME-Version: 1.0'; $headers[] = 'Content-type: multipart/alternative; boundary="' . $boundary . '"'; $message = 'This is a Multipart Message in MIME format.' . "\n"; $message .= '--' . $boundary . "\n"; $message .= 'Content-type: text/plain; charset="iso-8859-1"' . "\n"; $message .= 'Content-Transfer-Encoding: 7bit' . "\n\n"; // $message .= 'Content-Transfer-Encoding: quoted-printable' . "\n\n"; $message .= $this->textBody . "\n"; $message .= '--' . $boundary . "\n"; $message .= 'Content-type: text/html; charset="iso-8859-1"' . "\n"; $message .= 'Content-Transfer-Encoding: 7bit' . "\n\n"; $message .= $this->HTMLBody . "\n"; $message .= '--' . $boundary . '--'; } $success = mail($this->toAddress, $this->subject, $message, join("\r\n", $headers)); return $success; } } } ?> now the problem is when ever gmail recives the image code , <img src="http://yourdomain.com/image.jpg" > it escapes them like this : <img src=\"http://yourdomain.com/image.jpg\" > and the image is not read how could i resolve this ???
  12. Hi, Here is my site :http://bhc.edu.in/COMMCOLLEGE/index.php I have written code for sending email (The form is in footer). But every time when the page is loaded,it shows the message "Your feedback or enquiry is sent successfully". And i am getting empty mail to my email id.Please help,what should i do?
  13. Hey there Wanted to ask a question with my SMTP setting not authenticating I get an error like this : PHP Warning: mail(): SMTP server response: 530 SMTP authentication is required. in file.php on line 190 Even tho i provided all the details for the SMTP to authenticate . <?php include '../header.php'; include '../config2.php'; $thankYouPage = '/success.php'; $allowedFields = array( 'login_email', 'login_password', 'confirm', 'first_name', 'last_name', 'address_one', 'address_two', 'town_city', 'county_option', 'post_code', 'phone_number', 'agree', ); $requiredFields = array( 'login_email'=> '*Email address is required.', 'login_password'=> '*Password is required.', 'confirm'=> '*Please confirm your password(required).', 'first_name'=> '*Your First Name is required.', 'last_name'=> '*Your Last Name is required.', 'address_one'=> '*First Line of your address is required.', 'address_two'=> '*Second Line of your address is required.', 'town_city'=> '*Town/City is required.', 'county_option'=> '*County is required.', 'post_code'=> '*Post Code is required.', 'phone_number'=> '*Phone Number is required.', 'agree'=> '*You must agree with our Terms & Conditions .', ); $errors = array(); foreach($requiredFields as $fieldname => $errorMsg) { if(empty($_POST[$fieldname])) { $errors[] = $errorMsg; } } foreach($_POST AS $key => $value) { if(in_array($key, $allowedFields)) { ${$key} = $value; } } if(count($errors) > 0) { $errorString.= '<ul>'; foreach($errors as $error) { $errorString.= "<li>$error</li>"; } $errorString.= '</ul>'; ?> <html> <div id="title"> <div class="inner"> <h1>Account Registration</h1> </div> </div> <div id="content"> <div class="container inner"> </head> <body> <h1>Error Processing Form</h1> <br></br> <h3>Some Information was not Entered,please return to the form and fill it out </h3> <tr></tr> <?php echo $errorString; ?> <p></p> <p><a href="register.php" class="button">Go Back to the Form</a></p> </body> </div> </div> </html> <?php } else { $email = $_POST['login_email']; $pass = SHA1($_POST['login_password']); $confirm = SHA1($_POST['confirm']); $fname = $_POST['first_name']; $lname = $_POST['last_name']; $addressone = $_POST['address_one']; $addresstwo = $_POST['address_two']; $towncity = $_POST['town_city']; $countyoption = $_POST['county_option']; $postcode = $_POST['post_code']; $phone = $_POST['phone_number']; $Activation = md5(uniqid(rand())); $insert = 'INSERT into users( login_email, login_password, confirm, first_name, last_name, address_one, address_two, town_city, county_option, post_code, phone_number, Activation) VALUES("'.$email.'","'.$pass.'","'.$confirm.'","'.$fname.'","'.$lname.'","'.$addressone.'","'.$addresstwo.'","'.$towncity.'","'.$countyoption.'","'.$postcode.'","'.$phone.'","'.$Activation.'")'; $result2 = mysql_query($insert) or die("Failed Inserting your data"); if($result2) { require("class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPAuth = true; $mail->Host = "smtp.mysettings.com"; // SMTP server $mail->Username = "support@myhost"; // SMTP account username $mail->Password = "password"; // SMTP account password $mail->From = "myhost@myhost.com"; $mail->FromName = "Admin"; $mail->AddAddress($email,$fname." ".$lname); $mail->Subject = "First PHPMailer Message"; $mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer."; $mail->WordWrap = 50; if(!$mail->Send()) { echo 'Message was not sent.'; echo 'Mailer error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent.'; } $to = $email; $subject = "Confirmation from Test to $username"; $header = "Test: Account Confirmation from Test"; $message = "Please click the link below to verify and activate your account."; $message .= "http://www.test.com/account/confirm.php?passkey=$activation"; $sentmail = mail($to,$subject,$message,$header); if($sentmail) { echo "Your Confirmation link Has Been Sent To Your Email Address."; } else { echo "Cannot send Confirmation link to your e-mail address"; } } } header( 'Location: /account/success.php' ) ; include '../footer.php'; ?>
  14. For about 2/3 years I have had a purchase order form - which sends the forms returns to the recipient by email. After the form is sent, the user will then see a confirmation page - with links back to the main site. Two things happened 1, The site owner changed hosts and now uses 1&1 UK - who recently seemed to have changed teh server PHP handling - now giving options PHP5.5 - 5.4 and dev. 2. The site owner has had an IT guy take over email "security" who then installed an Windows 2003 sever on the hosting. I am notified thr form has stoppped working - looking at the obvious I assumed that changing PHP settings affected the form. But on test site on my 1&1 server.... the forms sends a retuen by email. My problem is that now, the sendresults script seems to be affected ! There is no redirect to the confirmation page and no error page is returned. The screen goes white, no content. The URL shows the same form page path. I got the original scripts of a Dreamweaver forum long ago... which is now demised. In a search I have found similar probems and no solutions.... I have two questions - ppppplease can anybody offer a workaround to get the desired results or is their a way to cut the form after the email is sent and have a link back to the site.. or another workaround to achieve the same result. Finally and sadly, what I know about PHP would not, while using a felt marker and big letters, fill the back of a stamp. Any offers of help will be greatly appreciated. TIA, Art <?php //--------------------------Set these paramaters-------------------------- // Subject of email sent to you. $subject = 'Results from Contact form'; // Your email address. This is where the form information will be sent. $emailadd = 'xxxxx@xxxxx.com'; // Where to redirect after form is processed. $url = 'http://www.xxxxxxxxxxxx.com'; // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty. $req = '0'; // --------------------------Do not edit below this line-------------------------- $text = "Results from form:\n\n"; $space = ' '; $line = ' '; foreach ($_POST as $key => $value) { if ($req == '1') { if ($value == '') {echo "$key is empty";die;} } $j = strlen($key); if ($j >= 20) {echo "Name of form element $key cannot be longer than 20 characters";die;} $j = 20 - $j; for ($i = 1; $i <= $j; $i++) {$space .= ' ';} $value = str_replace('\n', "$line", $value); $conc = "{$key}:$space{$value}$line"; $text .= $conc; $space = ' '; } mail($emailadd, $subject, $text, 'From: '.$emailadd.''); echo '<META HTTP-EQUIV=Refresh CONTENT="3; URL='.$url.'">'; ?>
  15. How can I set up pretty/styled emails and mailing list? I can use php's mail() and I use it all the time but I can't style the email article or add pics. Every time I add an h1 tag for a test I get <h1> in the email not the style text. Does anyone have links to tell me how to do this? Is it worth the hassle? Would it just be easier just to use someone like constantcontact dot com Thanks
  16. Is it possible to insert form data to a Mysql database and print to email a printable document and not just the standard email listing the fields of a web form? ie " looks like the actual document we ultimately want to print?"
  17. I am creating kinda like a small social site. I want to be able to send messages back and forth like facebook does. The I M is the email and vise versa. Anyone know how to do it? Where do I start?
  18. I've been thinking of techniques used by email providers to detect (unless they aren't directly detected, but it is assumed to be) a virus within an email attachment, per say. Besides, I'm generally interested in virus detection and consulted many research papers with no success whatsoever. Does anyone know a method? Are there any email providers using PHP in the backend anyway? Regards
  19. Hi I have taken a ready php script and i have tryid to add one more field to it so it will also send me the name of the user that send me this email but as i have add it now the script don't work any more and if it did work it didn't send me this new field i have add i also need to do also a check that this field is with text and if it is without text then it need to give a popup as it do with all the rest so if you can help me fix this code it will help me a lot thanks Yours Tamir mail.zip
  20. Hi, I want to create a PHP program that sends email to my mail address if it detects any change in the given url . I ll open the php file in browser and so no need to use cron jobs . Kindly help me how to start . I have completely no idea to what to do . I know only concept : Saves the last html code or webview of the webpage in db. if there is changes in html code or webview it sends e-mail . (I don't want to use page2rss - check interval more than 5 hours). -Thanks
  21. I have an online form which when filled in and submitted converts into a pdf file and saves on database/server. I want to, as part of the process, attach the saved file on database and send as email.Currently am having ' failed to open stream: No such file or directory' while using phpmailer. I am not sure whether to use $_FILES function since I am not uploading a file. Any ideas or solution will help. Thanks in advance.
  22. Anyone please help, i'm very desperate. I am new in php coding, therefore I am having a tough time troubleshooting my website. I have a form on this wedding website to should send the data directly to an email account. It was working perfectly, but all of a sudden as become flakey. Sometimes it will send no problem and other times it will not (not browser specific or device specific). It still appears to work properly once the form is completed. It just never reaches the email. My hosting does allow email to be sent and supports php, I double checked. Thanks in advance to anyone who can help! Again, I am just a begginer with php so it might be something real elementary that i'm doing. ------- This is from my index page: <div id="contact-form" class="clearfix"> <div id="contact" class="section"> <form id="contact-us" action="rsvp-form-send.php" method="post"> <?php if(isset($emailSent) && $emailSent == true) { ?> <p class="info">Thanks for sending us your RSVP! Cant wait to CELEBRATE!</p> <?php } else { ?> <?php if(isset($hasError) || isset($captchaError) ) { ?> <p class="alert">Error submitting the form</p> <?php } ?> <div class="left-container"> <div id="contact-name-container" class="formblock"> <?php if($contactName != '') { ?> <br /><span id="contact-name-error" class="error"><?php echo $contactNameError;?></span> <?php } ?> <label class="screen-reader-text">Name</label> <input type="text" name="contactName" id="contactName" value="<?php if(isset($_POST['contactName'])) echo $_POST['contactName'];?>" class="txt requiredField" placeholder="your name" /> </div> <div id="rsvp-text-container" class="formblock"> <?php if($rsvpError != '') { ?> <br /><span class="error"><?php echo $rsvpError;?></span> <?php } ?> <label id="rsvp-text" class="screen-reader-text">RSVP total</label> <input type="text" name="rsvpTotal" id="rsvpTotal" value="<?php if(isset($_POST['rsvpTotal'])) echo $_POST['rsvpTotal'];?>" class="txt requiredField" placeholder="#" /> </div> <div id="additional-guest" class="formblock"> <label class="screen-reader-text">Additional guest name(s) <small>(leave blank if your rolling solo!)</small></label> <div class="clearfix"></div> <input type="text" name="guestName1" id="guestName1" value="<?php if(isset($_POST['guestName1'])) echo $_POST['guestName1'];?>" placeholder="guest name 1" /> <input type="text" name="guestName2" id="guestName2" value="<?php if(isset($_POST['guestName2'])) echo $_POST['guestName2'];?>" placeholder="guest name 2" /> <input type="text" name="guestName3" id="guestName3" value="<?php if(isset($_POST['guestName3'])) echo $_POST['guestName3'];?>" placeholder="guest name 3" /> <input type="text" name="guestName4" id="guestName4" value="<?php if(isset($_POST['guestName4'])) echo $_POST['guestName4'];?>" placeholder="guest name 4" /> <input type="text" name="guestName5" id="guestName5" value="<?php if(isset($_POST['guestName5'])) echo $_POST['guestName5'];?>" placeholder="guest name 5" /> <input type="text" name="guestName6" id="guestName6" value="<?php if(isset($_POST['guestName6'])) echo $_POST['guestName6'];?>" placeholder="guest name 6" /> </div> <div class="formblock"> <label class="screen-reader-text">Comments, Questions, Special Requests!</label> <textarea name="comments" id="commentsText" class="txtarea" placeholder="enter your thoughts!"><?php if(isset($_POST['comments'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['comments']); } else { echo $_POST['comments']; } } ?></textarea> </div> </div> <div class="right-container"> <div id="email-container" class="formblock"> <?php if($emailError != '') { ?> <br /><span class="error"><?php echo $emailError;?></span> <?php } ?> <label class="screen-reader-text">Email Address</label> <input type="text" name="email" id="email" value="<?php if(isset($_POST['email'])) echo $_POST['email'];?>" class="txt requiredField email" placeholder="email address" /> </div> <p>Total your number of meal choices <br />for yourself and your guest(s)</p> <div class="formblock formblock-no-margin"> <div class="beef-img"></div> <label class="screen-reader-text" id="beef-text">Beef total</label> <input type="text" name="beefTotal" id="beefTotal" value="<?php if(isset($_POST['beefTotal'])) echo $_POST['beefTotal'];?>" class="txt" placeholder="#" /> </div> <div class="formblock formblock-no-margin"> <div class="chicken-img"></div> <label class="screen-reader-text" id="chicken-text">Chicken total</label> <input type="text" name="chickenTotal" id="chickenTotal" value="<?php if(isset($_POST['chickenTotal'])) echo $_POST['chickenTotal'];?>" class="txt" placeholder="#" /> </div> <div class="formblock formblock-no-margin"> <div class="fish-img"></div> <label class="screen-reader-text" id="fish-text">Fish total</label> <input type="text" name="fishTotal" id="fishTotal" value="<?php if(isset($_POST['fishTotal'])) echo $_POST['fishTotal'];?>" class="txt" placeholder="#" /> </div> <div class="formblock"> <label class="screen-reader-text" id="hotel-label">Spending the night in our hotel?</label> <label class="screen-reader-text" id="radio-yes-label">yes</label> <input id='radio-yes' type="radio" value="YES"name="hotel"> <label class="screen-reader-text" id="radio-no-label">no</label> <input id='radio-no' type="radio" value="NO" name="hotel"> </div> <div class="formblock"> <label class="screen-reader-text">Like to dance?</label> <input type="text" name="songRequest" id="songRequest" value="<?php if(isset($_POST['songRequest'])) echo $_POST['songRequest'];?>" class="txt" placeholder="give us a song request" /> </div> <button id="submit-button" name="submit" type="submit" class="subbutton">CLICK TO SEND YOUR RSVP!</button> <input type="hidden" name="submitted" id="submitted" value="true" /> </div> </div> <?php } ?> <div class="clearfix"></div> <!-- End #contact --> </div> </form> </div> -------------------------- This is the scripting on the index page: <!--//--><![CDATA[//><!-- $(document).ready(function() { document.getElementById("contact-us").reset(); $('form#contact-us').submit(function() { $('form#contact-us .error').remove(); var hasError = false; $('.requiredField').each(function() { if($.trim($(this).val()) == '') { var labelText = $(this).prev('label').text(); $(this).parent().append('<span class="error">you forgot your '+labelText+'!</span>'); $(this).addClass('inputError'); /* $("#contactName").onclick().hide("span .error");*/ hasError = true; } else if($(this).hasClass('email')) { var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; if(!emailReg.test($.trim($(this).val()))) { var labelText = $(this).prev('label').text(); $(this).parent().append('<span class="error">oops! you\'ve entered an invalid '+labelText+'.</span>'); $(this).addClass('inputError'); hasError = true; } } }); $('#contactName').click(function(){ if($(this).hasClass('inputError')) { $('#contact-name-container .error').css({ 'display' : 'none' }); } }); $('#rsvpTotal').click(function(){ if($(this).hasClass('inputError')) { $('#rsvp-text-container .error').css({ 'display' : 'none' }); } }); $('#email').click(function(){ if($(this).hasClass('inputError')) { $('#email-container .error').css({ 'display' : 'none' }); } }); if(!hasError) { var formInput = $(this).serialize(); $.post($(this).attr('action'),formInput, function(data){ $('form#contact-us').slideUp("fast", function() { $(this).before('<p class="rsvp-thanks"><strong>Thanks for the RSVP!</strong> <br />Cant wait to CELEBRATE!</p>'); }); }); } return false; }); }); //-->!]]> ------------------------ and this is the backend php file: <?php error_reporting(E_ALL ^ E_NOTICE); // hide all basic notices from PHP //If the form is submitted if(isset($_POST['submitted'])) { // require a name from user if(trim($_POST['contactName']) === '') { $contactNameError = 'Forgot your name!'; $hasError = true; } else { $contactName = trim($_POST['contactName']); } // require a RSVP Number if(trim($_POST['rsvpTotal']) === '') { $rsvpError = 'Forgot your RSVP total number!'; $hasError = true; } else { $rsvpTotal = trim($_POST['rsvpTotal']); } // Not required $hotel = trim($_POST['hotel']); $guestName1 = trim($_POST['guestName1']); $guestName2 = trim($_POST['guestName2']); $guestName3 = trim($_POST['guestName3']); $guestName4 = trim($_POST['guestName4']); $guestName5 = trim($_POST['guestName5']); $guestName6 = trim($_POST['guestName6']); $beefTotal = trim($_POST['beefTotal']); $chickenTotal = trim($_POST['chickenTotal']); $fishTotal = trim($_POST['fishTotal']); $songRequest = trim($_POST['songRequest']); // need valid email if(trim($_POST['email']) === '') { $emailError = 'Forgot to enter in your e-mail address.'; $hasError = true; } else if (!preg_match("/^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$/i", trim($_POST['email']))) { $emailError = 'You entered an invalid email address.'; $hasError = true; } else { $email = trim($_POST['email']); } // we need at least some content if(trim($_POST['comments']) === '') { $commentError = 'You forgot to enter a message!'; $hasError = true; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['comments'])); } else { $comments = trim($_POST['comments']); } } // upon no failure errors let's email now! if(!isset($hasError)) { $emailTo = 'nsiri335@live.com'; $subject = ' Wedding RSVP!'; $sendCopy = trim($_POST['sendCopy']); $body = "Name: $contactName \n\nRSVP #: $rsvpTotal \n\nChicken Total #: $chickenTotal \n\nBeef Total #: $beefTotal \n\nFish Total #: $fishTotal \n\nGuest Name 1: $guestName1 \n\nGuest Name 2: $guestName2 \n\nGuest Name 3: $guestName3 \n\nGuest Name 4: $guestName4 \n\nGuest Name 5: $guestName5 \n\nGuest Name 6: $guestName6 \n\nEmail: $email \n\nSong Request: $songRequest \n\nHotel Room?: $hotel \n\nComments: $comments"; $headers = 'From: ' .' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body, $headers); // set our boolean completion value to TRUE $emailSent = true; } } ?>
  23. Hi, The email from the server is on a blacklist. They blame me because I send emails trough my php script. So now I wonder, how can I send email through web form without being blocked? Please, any advice would be appreciated. Thanks.
  24. hi, first i have to say i don't know much of php, a friend asked me to help him in this.. got this landing page: http://www.kaizen10.com/coach/contact.html in which we modified and added some fields to the form.. but for some reason it is not working... as i am very noob in php, i realy can't get to the answer so thats why i am asking.. this are the codes both for the html forma nd php... html: <form id="contactform" class="form-contact" action="http://www.kaizen10.com/coach/mailer.php" method="post"> <div id="success" ></div> <!-- START - DADOS CADASTRAIS --> <input placeholder="Seu Nome" type="text" class="input-name" id="name" name="name" /> <input placeholder="Seu e-mail" type="text" class="input-email" id="email" name="email" /> <input placeholder="Profissão" type="text" class="input-name" id="profesion" name="profesion" /> <input placeholder="Telefone" type="text" class="input-email" id="telefono" name="telefono" /> <!-- END - DADOS CADASTRAIS --> <div class="tx"><p> As respostas oferecidas nesta ferramenta são de caráter estritamente CONFIDENCIAIS, sendo utilizadas apenas por você, nosso assessor e seu Coach. Você está pronto para o Coaching?</p></div> <!-- START - QUESTION RADIO --> <p class="questionh2"> 01 - Estou pronto para investir meu tempo em mim, e fazer o trabalho necessário para o meu desenvolvimento pessoal e profissional?</p> <div class="check"><input type="radio" name="pregunta1" id="pregunta1" value="sim" /> <p class="radio-label">SIM</p></div> <div class="check"><input type="radio" name="pregunta1" id="pregunta1" value="nao" /> <p class="radio-label">NÃO</p></div> <p class="questionh2"> 02 - Tenho objetivos a atingir que serão meu foco em coaching?</p> <div class="check"><input type="radio" name="pregunta2" id="pregunta2" value="sim" /> <p class="radio-label">SIM</p></div> <div class="check"><input type="radio" name="pregunta2" id="pregunta2" value="nao" /> <p class="radio-label">NÃO</p></div> <p class="questionh2"> 03 - Estou pronto a descartar comportamentos que impedem ou limitam o meu sucesso?</p> <div class="check"><input type="radio" name="pregunta3" id="pregunta3" value="sim" /> <p class="radio-label">SIM</p></div> <div class="check"><input type="radio" name="pregunta3" id="pregunta3" value="nao" /> <p class="radio-label">NÃO</p></div> <p class="questionh2"> 04 - Entendo que o foco do coaching é contribuir para que eu atinja minhas metas, diferentemente da terapia, a qual tem foco em traumas emocionais?</p> <div class="check"><input type="radio" name="pregunta4" id="pregunta4" value="sim" /> <p class="radio-label">SIM</p></div> <div class="check"><input type="radio" name="pregunta4" id="pregunta4" value="nao" /> <p class="radio-label">NÃO</p></div> <p class="questionh2"> 05 - Vou me empenhar em ter ações consistentes para atingir minhas metas, mesmo quando não alcançar resultados imediatos?</p> <div class="check"><input type="radio" name="pregunta5" id="pregunta5" value="sim" /> <p class="radio-label">SIM</p></div> <div class="check"><input type="radio" name="pregunta5" id="pregunta5" value="nao" /> <p class="radio-label">NÃO</p></div> <p class="questionh2"> 06 - Estou pronto para trabalhar em colaboração com o meu coaching para idealizar metas e planos de ação que me possibilitarão expandir minhas habilidades?</p> <div class="check"><input type="radio" name="pregunta6" id="pregunta6" value="sim" /> <p class="radio-label">SIM</p></div> <div class="check"><input type="radio" name="pregunta6" id="pregunta6" value="nao" /> <p class="radio-label">NÃO</p></div> <p class="questionh2"> 07 - Reconheço que sou totalmente RESPONSÁVEL por minha vida e pelas decisões que tomo?</p> <div class="check"><input type="radio" name="pregunta7" id="pregunta7" value="sim" /> <p class="radio-label">SIM</p></div> <div class="check"><input type="radio" name="pregunta7" id="pregunta7" value="nao" /> <p class="radio-label">NÃO</p></div> <p class="question"> Qual plano você encontra mais adecuado a sua realidade atual? </p> <div class="check"><input type="checkbox" name="plano" id="plano" value="silver" /> <p class="radio-label">SILVER</p></div> <div class="check"><input type="checkbox" name="plano" id="plano" value="gold" /> <p class="radio-label">GOLD</p></div> <div class="check"><input type="checkbox" name="plano" id="plano" value="platinum" /> <p class="radio-label">PLATINUM</p></div> <!-- END - QUESTION RADIO --> <div class="tx"><p> Responda as questões abaixo sem pressa. Não há respostas certa ou errada. O objetivo é definir onde você está hoje e o que você quer, do processo de coaching de sua vida em geral. Suas respostas são importantes para que se crie uma base sólida para o relacionamento de supervisão.</p></div> <!-- START - QUESTION TEXTAREA --> <p class="question"> 01 - O que voce espera do processo de Coaching?</p> <textarea placeholder="Resposta" class="message" name="pregunta8" id="pregunta8" rows="5" cols="20"></textarea> <p class="question"> 02 - Qual é a sua expectativa sobre seu Coach?</p> <textarea placeholder="Resposta" class="message" name="pregunta9" id="pregunta9" rows="5" cols="20"></textarea> <p class="question"> 03 - Qual é o objetivo prioritário que deseja trabalhar?</p> <textarea placeholder="Resposta" class="message" name="preguna10" id="pregunta10" rows="5" cols="20"></textarea> <!-- END - QUESTION TEXTAREA --> <input type="submit" class="input-submit" value="Enviar" id="send" /> </form> php: <?php $name = $_POST['name']; $email = $_POST['email']; $telefono = $_POST['telefono']; $profesion = $_POST['profesion']; $pregunta1 = $_POST['pregunta1']; $pregunta2 = $_POST['pregunta2']; $pregunta3 = $_POST['pregunta3']; $pregunta4 = $_POST['pregunta4']; $pregunta5 = $_POST['pregunta5']; $pregunta6 = $_POST['pregunta6']; $pregunta7 = $_POST['pregunta7']; $pregunta8 = $_POST['pregunta8']; $pregunta9 = $_POST['pregunta9']; $pregunta10 = $_POST['pregunta10']; $plano = $_POST['plano']; $to = 'clientes@kaizen10.com.br'; $subject = 'Entrevista desde sitio web'; $message = 'FROM: '.$name.' Email: '.$email.' Respuestas: '.$pregunta1,'<br />'.$pregunta2,'<br />'.$pregunta3,'<br />'.$pregunta4,'<br />'.$pregunta5,'<br />'.$pregunta6,'<br />'.$pregunta7,'<br />'.$plano,'<br />'.$pregunta8,'<br />'.$pregunta9,'<br />'.$pregunta10,; $headers = 'From: clientes@kaizen10.com.br' . "\r\n"; if (filter_var($email, FILTER_VALIDATE_EMAIL)) { mail($to, $subject, $message, $headers); echo "Your email was sent!"; }else{ echo "Invalid Email, please provide an correct email."; } ?> i appreciate a lot if someone can help me in this... thanks
  25. Hi everyone, I can't pin down why an auto responder isn't being sent using an email class that has previously worked fine. I've tested the mail() function and it's fine so I'm presuming it's not the server (though I have contacted the host to check on recent changes). Here's an example of the ajax we're using to process everything... // EXPRESS INTEREST case "expressInterest": // Make sure the user is logged in if(!isCrewLoggedIn()) { $return["message"] = "Your session has expired"; send(); } // Make sure all required fields are present $required = array("event_id", "crew_id"); if(missingFields($required, $missing_fields)) { // Fields are missing $return["message"] = "The following fields are missing: " . arrayToErrorString($missing_fields); send(); } // All fields are present and accounted for. //require_once("classes/producer.class.php"); require_once("classes/event.class.php"); require_once("classes/email.class.php"); //Load the event object for the current event_id $objEvent = new Event($conn); $event = $objEvent->get($_POST["event_id"]); $_POST["eventname"] = $event->eventname; $_POST["eventdate"] = $event->eventdate; $_POST["eventstate"] = $event->eventstate; $_POST["eventlocation"] = $event->eventlocation; // Add the application into the database $event_id = $objEvent->addApplication($_POST); if(!$event_id) { $return["message"] = "An error occured whilst expressing interest."; send(); } // Send the event_id back to the client. $return["event_id"] = $event_id; // Send the autoresponder $email_data = array(); $email_data["firstname"] = $_SESSION["firstname"]; $email_data["surname"] = $_SESSION["surname"]; $email_data["email"] = $_SESSION["email"]; $email_data["event_id"] = $_POST["event_id"]; $email_data["eventname"] = $event->eventname; $email_data["eventdate"] = $event->eventdate; $email_data["eventstate"] = $event->eventstate; $email_data["eventlocation"] = $event->eventlocation; //send to Producer $objEmail = new Email($conn, ABSOLUTE_PATH . "email_templates/expressInterest_crew.xml", $email_data); $objEmail->sendEmail($email_data); //send to HQ too $objEmail = new Email($conn, ABSOLUTE_PATH . "email_templates/expressInterest_sc.xml", $email_data); $objEmail->sendEmail($email_data); // Everything processed OK $return["status"] = "OK"; break; And here's the email class <?php class Email { private $conn; // Database connection private $template; // The template file to use private $email_data; // An associate array containing email data private $doc; // An XML document object private $subject; // The email subject private $from; // Who the email is from private $recipients; // An array containing all recipient email addresses private $message; // The plain text or HTML message to send private $isHTML; // Set to true if this should be send as a HTML email message public function __construct($conn, $template, $email_data) { // Class constructor // Set class variables $this->conn = $conn; $this->template = $template; $this->email_data = $email_data; $this->recipients = array(); $this->isHTML = false; // Default to plain text. } public function sendEmail($data) { // Load and parse the XML email template file if(!$this->loadTemplate()) { return false; } // Compose the EMAIL from header $headers = "FROM: " . $this->from . "\r\nReply-To: " . $this->from; // Send the email to all recipients designated in the XML file. foreach($this->recipients as $recipient) { mail($recipient, $this->subject, $this->message, $headers); } // All done. return true; } private function replaceTemplateVars($xml) { if(!is_array($this->email_data)) { return; } foreach($this->email_data as $key => $value) { $xml = str_ireplace("{" . $key . "}", $value, $xml); } return $xml; } private function loadTemplate() { if(($this->template == "") || (!file_exists($this->template))) { return false; } // Load the xml template $xml = file_get_contents($this->template); // Replace any placeholder variables that with values defined in // the email_data array. $xml = $this->replaceTemplateVars($xml); // Create a new XML document from the XML data. $this->doc = new DOMDocument(); if(!$this->doc->loadXML($xml)) { return false; } // Email Subject $node = $this->doc->getElementsByTagName("subject"); if($node->length != 1) return false; $this->subject = trim($node->item(0)->textContent); // Email From $node = $this->doc->getElementsByTagName("from"); if($node->length != 1) return false; $this->from = trim($node->item(0)->textContent); // Email Message $node = $this->doc->getElementsByTagName("message"); if($node->length != 1) return false; $this->message = trim($node->item(0)->textContent); // Recipients $node = $this->doc->getElementsByTagName("recipient"); if($node->length == 0) return false; for($r = 0; $r < $node->length; $r++) { $this->recipients[] = trim($node->item($r)->textContent); } // All done - the template has been loaded and parsed. return true; } } Everything is working fine except for the autoresponder. I have also tested by placing a basic mail() function directly after the db queries and it send perfectly. I'm not great at php but I've got this far without probs and this has got me stumped. If the complete files are needed, message me and I'll email. Any help would be hugely appreciated. Cheers
  • 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.