PHP - Imap Open Gmail Error. Too Many E-mails
I'm building a PHP application that's connect to gmail and download the messages. I have an account that contains more than two millions messages and the PHP cannot connect to that account. What can I do?
The error is: Mailbox has more messages (2004032) exist than maximum (1000000) Similar Tutorialshi, very strange issue. when I create test e-mail or I will forward the specific e-mail, the script works correctly - saves attachment into server disk. now, when I configure to check another mailbox, it gives me error: Num Messages 11 Fatal error: Cannot use object of type stdClass as array in /test/emailattach/index.php on line 34 index.php: Code: [Select] <?php $mbox = imap_open("{mail.server.com:143}", "email@email", "XXX") or die('Cannot connect to mail: ' . imap_last_error()); // make connection with mailbox and check # messages if ($hdr = imap_check($mbox)) { echo "Num Messages " . $hdr->Nmsgs ."\n\n<br><br>"; $msgCount = $hdr->Nmsgs; } else { echo "failed"; } $overview=imap_fetch_overview($mbox,"1:$msgCount",0); $size=sizeof($overview); // get message info for($i=$size-1;$i>=0;$i--) { $val=$overview[$i]; $msg=$val->msgno; $from=$val->from; $date=$val->date; $subj=$val->subject; $seen=$val->seen; $from = ereg_replace("\"","",$from); // Check for attachements and store them $struct = imap_fetchstructure($mbox,$msg); $contentParts = count($struct->parts); if ($contentParts >= 2) { for ($ix=2;$ix<=$contentParts;$ix++) { $att[$ix-2] = imap_bodystruct($mbox,$msg,$ix); } for ($k=0;$k<sizeof($att);$k++) { if ($att[$k]->parameters[0]->value == "us-ascii" || $att[$k]->parameters[0]->value == "US-ASCII") { if ($att[$k]->parameters[1]->value != "") { $FileName[$k] = $att[$k]->parameters[1]->value; $FileType[$k] = strrev(substr(strrev($FileName[$k]),0,4)); } } elseif ($att[$k]->parameters[0]->value != "iso-8859-1" && $att[$k]->parameters[0]->value != "ISO-8859-1") { $FileName[$k] = $att[$k]->parameters[0]->value; $FileType[$k] = strrev(substr(strrev($FileName[$k]),0,4)); $fileContent = imap_fetchbody($mbox,$msg,$file+2); $fileContent = imap_base64($fileContent); $localfile = fopen("$FileName[$k]","w"); fputs($localfile,$fileContent); fclose($localfile); } } } } imap_close($mbox); ?> Could there be some encoding issue? with thanks, Margus I had some errors in my script but I solved the most of them except two: Warning: require_once(/home/a3443899/smarty/libs/Smarty.class.php) [function.require-once]: failed to open stream: No such file or directory in /home/a3443899/public_html/include/config.php on line 32 Fatal error: require_once() [function.require]: Failed opening required '/home/a3443899/smarty/libs/Smarty.class.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/a3443899/public_html/include/config.php on line 32 And I checked the map what he couldn't open the map names are just good Here is the config.php script: Code: [Select] <? $config = array(); // Begin Configuration // This Template was Downloaded From GrabTemplates.com $config['basedir'] = 'something'; $config['baseurl'] = 'something'; $DBTYPE = 'mysql'; $DBHOST = 'my host'; $DBUSER = 'my username'; $DBPASSWORD = 'my pass'; $DBNAME = 'my dbname'; // End Configuration ini_set('session.save_path', $config['basedir']. '/temporary/sessions'); session_start; $config['adminurl'] = $config[baseurl].'/administrator'; $config['cssurl'] = $config[baseurl].'/css'; $config['imagedir'] = $config[basedir].'/images'; $config['imageurl'] = $config[baseurl].'/images'; $config['picdir'] = $config[basedir].'/pics'; $config['picurl'] = $config[baseurl].'/pics'; $config['tpicdir'] = $config[basedir].'/pics/thumbs'; $config['tpicurl'] = $config[baseurl].'/pics/thumbs'; $config['membersprofilepicdir'] = $config[imagedir].'/membersprofilepic'; $config['membersprofilepicurl'] = $config[imageurl].'/membersprofilepic'; $config['mbgdir'] = $config[imagedir].'/mbg'; $config['mbgurl'] = $config[imageurl].'/mbg'; require_once($config[basedir].'/smarty/libs/Smarty.class.php'); require_once($config[basedir].'/libraries/mysmarty.class.php'); require_once($config[basedir].'/libraries/SConfig.php'); require_once($config[basedir].'/libraries/SError.php'); require_once($config[basedir].'/libraries/adodb/adodb.inc.php'); require_once($config[basedir].'/libraries/phpmailer/class.phpmailer.php'); require_once($config[basedir].'/libraries/SEmail.php'); function strip_mq_gpc($arg) { if (get_magic_quotes_gpc()) { $arg = str_replace('"',"'",$arg); $arg = stripslashes($arg); return $arg; } else { $arg = str_replace('"',"'",$arg); return $arg; } } $conn = &ADONewConnection($DBTYPE); $conn->PConnect($DBHOST, $DBUSER, $DBPASSWORD, $DBNAME); @mysql_query("SET NAMES 'UTF8'"); $sql = "SELECT * from config"; $rsc = $conn->Execute($sql); if($rsc){while(!$rsc->EOF) { $field = $rsc->fields['setting']; $config[$field] = $rsc->fields['value']; STemplate::assign($field, strip_mq_gpc($config[$field])); @$rsc->MoveNext(); }} if ($_REQUEST['language'] != "") { if ($_REQUEST['language'] == "english") { SESSION_REGISTER("language"); $_SESSION[language] = "english"; } elseif ($_REQUEST['language'] == "spanish") { SESSION_REGISTER("language"); $_SESSION[language] = "spanish"; } elseif ($_REQUEST['language'] == "french") { SESSION_REGISTER("language"); $_SESSION[language] = "french"; } } if ($_SESSION['language'] == "") { SESSION_REGISTER("language"); $_SESSION[language] = "english"; } if ($_SESSION['language'] == "english") { include("lang/english.php"); } elseif ($_SESSION['language'] == "spanish") { include("lang/spanish.php"); } elseif ($_SESSION['language'] == "french") { include("lang/french.php"); } else { include("lang/english.php"); } for ($i=0; $i<count($lang)+1; $i++) { STemplate::assign('lang'.$i, $lang[$i]); } STemplate::assign('baseurl', $config['baseurl']); STemplate::assign('basedir', $config['basedir']); STemplate::assign('adminurl', $config['adminurl']); STemplate::assign('cssurl', $config['cssurl']); STemplate::assign('imagedir', $config['imagedir']); STemplate::assign('imageurl', $config['imageurl']); STemplate::assign('picdir', $config['picdir']); STemplate::assign('picurl', $config['picurl']); STemplate::assign('tpicdir', $config['tpicdir']); STemplate::assign('tpicurl', $config['tpicurl']); STemplate::assign('membersprofilepicdir', $config['membersprofilepicdir']); STemplate::assign('membersprofilepicurl', $config['membersprofilepicurl']); STemplate::assign('mbgdir', $config['mbgdir']); STemplate::assign('mbgurl', $config['mbgurl']); STemplate::setCompileDir($config['basedir']."/temporary"); STemplate::setTplDir($config['basedir']."/themes"); ?> I am trying to install a wordpress plugin called CiviCRM. I am using the GoDaddy wordpress dashboard to do this. I am getting this error (which is just the first error in a list of several that are appearing): Warning: require(/home/NAME/public_html/wordpress.SITE.com/wp-content/plugins/civicrm/civicrm/vendor/composer/../symfony/polyfill-ctype/bootstrap.php): failed to open stream: No such file or directory in /home/NAME/public_html/wordpress.SITE.com/wp-content/plugins/civicrm/civicrm/vendor/composer/autoload_real.php on line 70 I am looking at the code in file "autoload_real.php" and line 70 reads: require $file; nowhere else in this file is $file defined. the directory "/home/NAME/public_html/wordpress.SITE.com/wp-content/plugins/civicrm/civicrm/vendor/composer/" DOES exist, but the rest of the line "../symfony/polyfill-ctype/bootstrap.php" does not. there are also 3 other errors in eclipse that are indicated and all of those errors are "syntax error: unexpected 'Autoload()'. The 3 different lines of code that throw this error a 1) self::$loader = $loader = new \Composer\Autoload\ClassLoader(); 2) call_user_func(\Composer\Autoload\ComposerStaticInitdb2000479593e65ef23454e56d74a73f::getInitializer($loader)); 3) $includeFiles = Composer\Autoload\ComposerStaticInitdb2000479593e65ef23454e56d74a73f::$files; I'm not really sure what the issue is, as I'm not experienced enough. Any help from the experts here? GoDaddy claims the problem is with the plugin file's coding. Edited October 24, 2019 by ajetrumpetHi there, I'm a .net developer and I've inherited a partially complete php project. I'm trying get part of it running on my pc and am running into some issues due to my fairly limited knowledge with php/apache web server. I'm using Windows Vista, I have Apache HTTP server 2.2 running and am using PHP 5.2.17. The aim is to send some data to the web server. I'm using this function below - public static function push_data($data) { $data = base64_encode(gzdeflate(ot::encrypt(serialize($data), otCRYPT_KEY), 9)); $data = http_build_query(array(otDATA_KEY => $data)); $opts = array ( 'http' => array ( 'method' => 'POST', 'header'=> "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Length: " . strlen($data) . "\r\n", 'content' => $data ) ); $ctx = stream_context_create($opts); return file_get_contents(otDATA_URL, 0, $ctx); } And am getting this message back - PHP Warning: file_get_contents(http://localhost/Epointment/ot/backend/data.php): failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host failed to respond. I've echoed $ctx and get Resource ID #15 and echoed otDATA_URL and get http://localhost/Epointment/ot/backend/data.php, which is correct. I've run a test php script actually on the web server and it works, so at least I know the server is running and PHP works on it. I'm not sure if this is an issue with the Apache settings or the PHP script or php.ini settings thanks for any help, Hi I am really frustrated because I got my php code working fine and then I had to make some minor changes to my html form and now the php is not working. I am reciec=ving this message: Warning: move_uploaded_file(upload/carey.bmp) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/content/19/6550319/html/ipad/listing.php on line 35 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpIEUQLo' to 'upload/carey.bmp' in /home/content/19/6550319/html/ipad/listing.php on line 35 Sorry, there was a problem uploading your file.03/10/11 : 20:50:08 I wrote it twice because it keeps coming out twice. I guess it means that it cant upload the image because there is no image but I really dont understand why. I havent changed the image part of the form. Does anyone have any ideas? It is much appreciated. Here is the code Code: [Select] <?php //This is the directory where images will be saved $target = "upload/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $price=$_POST['price']; $pic=($_FILES['photo']['name']); $pic2=($_FILES['phototwo']['name']); $pic3=($_FILES['photothree']['name']); $pic4=($_FILES['photofour']['name']); $description=$_POST['iPadDescription']; $condition=$_POST['condition']; $gig=$_POST['giga']; $yesg=$_POST['yesg']; $fname=$_POST['firstName']; $lname=$_POST['lastName']; $email=$_POST['email']; // Connects to your Database mysql_connect ("taken out for security", "taken out", "taken out") or die(mysql_error()) ; mysql_select_db("taken out") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO ipadlist (price,photo,phototwo,photothree,photofour,iPadDescription,condition,giga,yesg,firstName,lastName,email) VALUES ('$price', '$pic', '$pic2', '$pic3', '$pic4', '$description', '$condition', '$gig', '$yesg', '$fname', '$lname', '$email')") ; //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } echo date("m/d/y : H:i:s", time()) ?> The Script:
<?php if (isset($_POST['submit'])) { $j = 0; //Variable for indexing uploaded image $target_path = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/uploads/"; //Declaring Path for uploaded images for ($i = 0; $i < count($_FILES['file']['name']); $i++) {//loop to get individual element from the array $validextensions = array("jpeg", "jpg", "png"); //Extensions which are allowed $ext = explode('.', basename($_FILES['file']['name'][$i]));//explode file name from dot(.) $file_extension = end($ext); //store extensions in the variable $new_image_name = md5(uniqid()) . "." . $ext[count($ext) - 1]; $target_path = $target_path . $new_image_name;//set the target path with a new name of image $j = $j + 1;//increment the number of uploaded images according to the files in array if (($_FILES["file"]["size"][$i] < 100000) //Approx. 100kb files can be uploaded. && in_array($file_extension, $validextensions)) { if (move_uploaded_file($_FILES['file']['tmp_name'][$i], $target_path)) {//if file moved to uploads folder echo $j. ').<span id="noerror">Image uploaded successfully!.</span><br/><br/>'; for ($i = 0; $i < count($_FILES['file']['name']); $i++) { $tqs = "INSERT INTO images (`original_image_name`, `image_file`, `date_created`) VALUES ('" . $_FILES['file']['name'][$i] . "', '" . $new_image_name . "', now())"; $tqr = mysqli_query($dbc, $tqs); } // To create the thumbnails. function make_thumb($src, $dest, $desired_width) { /* read the source image */ $source_image = imagecreatefromjpeg($src); $width = imagesx($source_image); $height = imagesy($source_image); /* find the "desired height" of this thumbnail, relative to the desired width */ $desired_height = floor($height * ($desired_width / $width)); /* create a new, "virtual" image */ $virtual_image = imagecreatetruecolor($desired_width, $desired_height); /* copy source image at a resized size */ imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height); /* create the physical thumbnail image to its destination */ imagejpeg($virtual_image, $dest); } $src = $target_path; $dest = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/thumbs/"; $desired_width = 100; make_thumb($src, $dest, $desired_width); } else {//if file was not moved. echo $j. ').<span id="error">please try again!.</span><br/><br/>'; } } else {//if file size and file type was incorrect. echo $j. ').<span id="error">***Invalid file Size or Type***</span><br/><br/>'; } } } ?>With this: $dest = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/thumbs/";I get this error message: Warning: imagejpeg(C:/xampp/htdocs/gallerysite/multiple_image_upload/thumbs/): failed to open stream: No such file or directory in C:\xampp\htdocs\gallerysite\multiple_image_upload\upload.php on line 49With this: $dest = "http://localhost/gallerysite/multiple_image_upload/thumbs/";I get this error message: Warning: imagejpeg(http://localhost/gallerysite/multiple_image_upload/thumbs/): failed to open stream: HTTP wrapper does not support writeable connections in C:\xampp\htdocs\gallerysite\multiple_image_upload\upload.php on line 49When I try deleting the "thumbs" folder and then try to upload an image, then I get this error message: Warning: imagejpeg(C:/xampp/htdocs/gallerysite/multiple_image_upload/thumbs/): failed to open stream: Invalid argument in C:\xampp\htdocs\gallerysite\multiple_image_upload\upload.php on line 49The spot of line 49 is this, at the spot where the script creates the thumbnails: /* create the physical thumbnail image to its destination */ imagejpeg($virtual_image, $dest); }Also, with this part right here I am not getting an error message, which means that this part works fine in comparison: $target_path = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/uploads/"; //Declaring Path for uploaded imagesThe script itself works fine. The script also uses javascript for multiple image upload. I am using XAMPP. The folder "thumbs" is set to "read-only", when I try to uncheck the "read-only" option in the properties in Windows then it sets itself back again to "read-only". Then again, the script works fine when it comes to the "uploads" folder. This is mentioned in comparison to the "thumbs" folder. Any suggestions on how to solve this? EDIT: I am using XAMPP. The folder "thumbs" is set to "read-only", when I try to uncheck the "read-only" option in the properties in Windows then it sets itself back again to "read-only". I am wondering if I would have issue that the option sets itself back again with Linux? Edited by glassfish, 11 October 2014 - 05:35 PM. I 'm having some problem while sending mails . i am sending bulk mails using php script, der is no problem in the script. i hope some guys have faced similar issue. while i am sending bulk emails, i figured out that - few mails are going to spam not into their INBOX. can you guys pls give some hint to resolve this issue. .. A form is filled and the information is emailed to my address. The problem is it goes to the spam folder. Is it a problem with the email filter? I suppose I could whitelist the email address the server uses to email the info, but then spam would get through as well. Any ideas? I'm using this code to create and populate a database. It gets a bit involved as it is creating a series of times for every day in the year. The database gets created and populated just fine, however I have 2 quirks I can't figure out. First, I am creating a separate file to store connection creds to the database. The file gets created and holds the correct information, but as I am using the program, somehow the file is getting overwritten with blank spaces, making it impossible to connect to the database. 2nd, the program sends me an e-mail when the database is created. Problem is I'm getting 2 e-mails about 20 minutes apart. 1 with all the correct information and 1 blank. I'm thinking maybe these problems are related??? Like the program is trying to run itself twice or is getting called twice. Once the program runs, it never gets called again in any other part of the program code. Any ideas? Thanks. Code: [Select] <?php $coursename = $_POST["coursename"]; $websiteurl = $_POST["websiteurl"]; $email = $_POST["email"]; $otime = $_POST["opentime"]; $ctime = $_POST["closetime"]; $interval = $_POST["interval"]; $year = $_POST["year"]; $server = $_POST["server"]; $username = $_POST["username"]; $password = $_POST["password"]; $userpassword = $_POST["userpassword"]; //--Creates a file to store Login Information--\\ $data = <<<DATA <?php \$server = "$server"; \$username = "$username"; \$password = "$password"; ?> DATA; file_put_contents("databasedata.php", $data); //--Connect to the Server--\\ mysql_connect("$server", "$username", "$password"); //--Create the Database--\\ mysql_query("CREATE DATABASE IF NOT EXISTS TeeTimes"); mysql_select_db("TeeTimes"); //--Create the Tables--\\ mysql_query("CREATE TABLE IF NOT EXISTS CourseInfo ( Course_ID int NOT NULL AUTO_INCREMENT, PRIMARY KEY(Course_ID), CourseName varchar(40) NOT NULL default '', HomePage varchar(50)NOT NULL default '', Email varchar(50) NOT NULL default '', Password varchar(20) NOT NULL default '' )"); mysql_query("CREATE TABLE IF NOT EXISTS Daysheets$year ( Sheet_ID int NOT NULL AUTO_INCREMENT, PRIMARY KEY(Sheet_ID), Date date NOT NULL, Time time NOT NULL, Player1 varchar(30) NOT NULL default '', Cart1 varchar(3) NOT NULL default '', Player2 varchar(30) NOT NULL default '', Cart2 varchar(3) NOT NULL default '', Player3 varchar(30) NOT NULL default '', Cart3 varchar(3) NOT NULL default '', Player4 varchar(30) NOT NULL default '', Cart4 varchar(3) NOT NULL default '', Player5 varchar(30) NOT NULL default '', Cart5 varchar(3) NOT NULL default '', Men smallint(4) NOT NULL default 0, Women smallint(4) NOT NULL default 0, Guest smallint(4) NOT NULL default 0, Event varchar(3) NOT NULL default '', EventName varchar(30) NOT NULL default '' )"); //***To Populate the Database with Dates and Times***\\ mysql_query(" INSERT INTO CourseInfo (CourseName,HomePage,Email,Password) VALUES('$coursename','$websiteurl','$email','$userpassword')"); $rows = mysql_query("SELECT * FROM Daysheets$year"); if ($rows[Date]=="") { $firstday = "$year:01:01 $otime:00:00"; $firstdate = strtotime($firstday); $firsttime = "$year:01:01 $otime:00:00"; $opentime = strtotime($firsttime); $lasttime = "$year:01:01 $ctime:00:00"; $closetime = strtotime($lasttime); $time = date("g:i",$opentime); $i=1; //***To Account For Leap Years***\\ if ($year == 2012 || $year == 2016 || $year == 2020 || $year == 2024) {$n=366;} else {$n=365;} while ($i <= $n) { $newday = date("Y-m-d",$opentime); mysql_query(" INSERT INTO Daysheets$year (Date,Time) VALUES('$newday','$time')"); while ($opentime < $closetime) { $newtime = strtotime("+$interval minute", $opentime); $nexttime = date("Y-m-d g:i a",$newtime); $nextd = date("Y-m-d",$newtime); $nextt = date("g:i",$newtime); mysql_query(" INSERT INTO Daysheets$year (Date,Time) VALUES('$nextd','$nextt')"); $opentime = strtotime($nexttime); } $opentime = strtotime($firsttime); $newday = strtotime("+$i day", $opentime); $nextday = date("Y-m-d g:i a",$newday); $opentime = strtotime($nextday); $closetime = strtotime($lasttime); $newday = strtotime("+$i day", $closetime); $nextday = date("Y-m-d g:i a",$newday); $closetime = strtotime($nextday); $i++; } } mysql_close(); //--Send Information for Safekeeping--\\ $to = "someone@somewhere.org"; $subject = "Tee Time Maker User Info"; $message = "Course Name:' '$coursename \n Website: ' '$websiteurl \n E-Mail: ' '$email \n Password: ' '$userpassword"; mail($to, $subject, $message, "From: $coursename <$email>"); //--Redirect user to the newly created site--\\ header("Location: /teetimes/adminteetimes.php"); ?> I've been using something like this to send email messages to users on a site: $to = $email; $subject = "Message From Microsoft.com\r\n"; $headers = "From: support@Microsoft.com\r\n"; $headers .= "Return-Path: support@Microsoft.com\r\n"; $headers .= "Reply-To: support@Microsoft.com\r\n"; $message = "<html><body><img src='http://www.Microsoft.com/images/logo.png' /><br /><br />You have a message from Bill:<br /><br />"; $message .= '<img src="' . $image . '" /><br /><br />'; $message .= 'Isn't it pretty?.<br /><br />'; $message .= '<a href="http://www.Microsoft.com">Microsoft.com</a></body></html>'; mail($to,$subject,$message,$headers); This sends, literally, text like this: <html><body><img src='http://www.Microsoft.com/images/logo.png' /><br /><br />You have a message from Bill:<br /><br /><img src="http://www.Microsoft.com/images/billiam.jpg" /><br /><br />Isn't it pretty?.<br /><br /><a href="http://www.Microsoft.com">Microsoft.com</a></body></html> Obviously, I would like the email to hide the HTML, but use it to format the output. Also, I'd obviously like the image to show up, not a link to the image, and I would like the link to show up as a link, not as HTML. How do I do this? Cheers. Hi, I'm developing a php newsletter software but I'm in trouble with bounce mails! I set a return path directing them into a specific email box then I read that email box with php and I process bounce mails to get the kind of problem. Well, I need to get some informations about those bounce emails: The name of the user that should recive that mail, the date when the mail has been sent, the kind of error encountered; It could be so easy if I could read the body of the mail I sent into the back bounce one but every server sends a different kind of bounce...for example mailer-daemon won't let me get the body of the sent message...how can I handle this? Andrea. I have this script that sends an E-mail to my custoemr when an account is created and does a Bcc to me. Every email gets sent once, then about 2 min later another one is sent. So both the customer and myself get 2 emails. I did a test and just after the mail() function i write to a text file. What is odd is that it logs the sent mail 2 times. So somehow it is going through it a second time. The time difference between the first and the second seem to usually be about 2-3 min. For exampel this was only sent one time. My guess is there has to be something wrong with my headers, but i have been over them many times and tried different configurations. To: ben@....com Time 05/12/2011 12:18:30 am To: ben@...com Time 05/12/2011 12:21:09 am Code: [Select] <?php $db_con = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR); mysql_select_db($database, $db_con); if((isset($_POST['password'])) && ($_POST['password'] == 'mandb108' )) { $install_date = date("Y-m-d"); $end = mktime(0, 0, 0, date("m"), date("d"), date("y")+1); $end_date = date("Y-m-d", $end); $folder = $_POST['folder']; $school_db = $_POST['school_db']; $school_name = $_POST['school_name']; // Check to see if school, db or folder exists if (mysql_num_rows(mysql_query("Select * FROM $select_table WHERE `school_name` = '$school_name'"))) { $message = 'School Name Already Exists in Database'; } elseif (mysql_num_rows(mysql_query("Select * FROM $select_table WHERE `school_db` = '$school_db'"))) { $message = 'Database Already Exists'; } elseif (mysql_num_rows(mysql_query("Select * FROM $select_table WHERE `school_folder` = '$folder'"))) { $message = 'School Folder Already Exists'; } else { ////////////////////id, school, db, folder, install, renew, end, contact, email, job, notes $insertSQL = sprintf("INSERT INTO $select_table VALUES (null, %s, %s, %s, %s, '$install_date', null, '$end_date', %s, %s, null, null)", GetSQLValueString($_POST['school_state'], "text"), GetSQLValueString($_POST['school_name'], "text"), GetSQLValueString($_POST['school_db'], "text"), GetSQLValueString($_POST['folder'], "text"), GetSQLValueString($_POST['contact'], "text"), GetSQLValueString($_POST['email'], "text")); mysql_select_db($database, $db_con); if($Result1 = mysql_query($insertSQL, $db_con) or die(mysql_error())) { $message = 'Added to Database - Successful<br>'; } else { $message = 'Added to Database - Failed<br>'; } // Funcatiobn to copy sampel folder to new directory for school full_copy("01_sample","$folder"); // Echo results $message .= 'Install Date - '.$install_date; $message .= '<br>'; $message .= 'Expire Date - '.$end_date.'<br>'; $message .= 'Copy of Folder - Successful<br>'; $message .= '<br><br>School - '; $message .= $_POST['school_name']; $message .= '<br>Database - '; $message .= $_POST['school_db']; $message .= '<br>Folder - '; $message .= $_POST['folder']; $message .= '<br>Contact - '; $message .= $_POST['contact']; $message .= '<br>Email - '; $message .= $_POST['email']; // Write to school_info file $open = fopen ("$folder/school_info.php", "at"); fwrite($open, "<?php\n$".$old); fwrite($open, "school_folder = '$folder';\n$".$old); fwrite($open, "school_db = '$school_db';\n$".$old); fwrite($open, "database = $".$old); fwrite($open, "school_db;\n?>".$old); fclose($open); // Link to create a database on voting site $message .= '<br><a href="http://www.anaheimartscouncil.com:2082/frontend/x3/sql/index.html" target="_blank">Cpanel</a><br>'; // link to setup Database tables on new site $message .= '<br><a href="'.$folder.'/index.php?install=yes&school='.$school_name.'" target="_blank">Database Setup</a><br>'; // link to send email to client $message .= '<br><a href="web_install.php?email=yes&school_db='.$school_db.'">Send E-mail</a><br><br>'; }// end if school name, databae or folder already exists } elseif ((isset($_GET['email'])) && ($_GET['email'] == 'yes')) { $school_db = $_GET['school_db']; $results = mysql_query("select * from tbl_schools_vote WHERE school_db = '$school_db' LIMIT 1"); // removed the while loop to get rid of duplicate emails. //while($row = mysql_fetch_array($results)){ $row = mysql_fetch_array($results); $school_contact = $row['school_contact']; $school_folder = $row['school_folder']; $school_contact_email = $row['school_contact_email']; //} // end while loop $email_message = 'Dear '; $email_message .= $school_contact; $email_message .= ',<br>'; $subject = "Voting 4 Schools - Account Activated"; $email_message .= 'Your Voting 4 Schools account has been setup. Below is all the information that you should need to get started.<br><br> Here is a link to your voting site. <a href="http://www.voting4schools.com/'.$school_folder.'">www.voting4schools.com/'.$school_folder.'</a><br><br>At the bottom of the page you will find an admin link. The user name and password are as follows<br><br>User Name: admin<br>Password: vote<br><br>When you log in please go to the control panel and create a new admin user and delete the default one that we have assigned you. At the top of the page you will find a link that says video tutorial. If you are unsure how to use the software, this is a great place to start. If you have any questions, or need help setting it up, please let us know.<br><br>Thank You,<br>Ben Star<br><br>Software 4 Schools<br>(866)757-7226<br><a href="http://www.software4schools.com">www.software4schools.com</a>'; // website link here //$to = $school_contact_email.', support@software4schools.com'; $to = $school_contact_email; //$email = 'support@software4schools.com'; //$headers = "To: ".$school_contact_email."\r\n"; //$headers .= "From: Software 4 Schools <support@software4schools.com>" . "\r\n"; //$headers .= "Bcc: Software 4 Schools <support@software4schools.com>" . "\r\n"; //$headers .= "MIME-Version: 1.0" . "\r\n"; //$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n"; $headers = 'From: michael@anaheimartscouncil.com' . "\r\n" . 'Reply-To: anaheimartscouncil.com' . "\r\n" . 'Bcc: ben@software4schools.com' . "\r\n" . 'Content-type: text/html; charset=iso-8859-1'; //. "\r\n"; //. 'X-Mailer: PHP/' . phpversion(); if (mail($to, $subject, $email_message, $headers)) { $date = date('m/d/Y h:i:s a', time()); $myFile = "mail.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); $stringData = "To: ". $to."\n"; fwrite($fh, $stringData); $stringData = "Time ". $date."\n\n"; fwrite($fh, $stringData); fclose($fh); $message = 'E-mail was sent once'; }else { $message = 'Problem sending message'; } } elseif ((isset($_POST['password'])) && ($_POST['password'] != 'mandb108' )) { $message = 'Password is incorrect'; $folder = $_POST['folder']; $school_db = $_POST['school_db']; $school = $_POST['school']; $contact = $_POST['contact']; $email = $_POST['email']; } else { // not sure what to do here yet... } // end if password isset from post if (!isset($_POST['school_db'])) { $school_db = 'voting_'; } ?> how to tell gmail to send plan messages only i want to send my friend a pgp-crypted mail - but this fails since the html-based mails allways do some changes to the pgp my friend receives the mails in a broken style they are not readable any more plz advice me - any and all help is much appreciated by the way i use kgpg and the editor to create the crypted message. i do not like the enigmail-addon for tbird. + But if i should try this - : Which credentials are needed to configure the einigmail - the public key that i have generated recently. love to hear from you greetings I have an index.php code. The code doesn't recognize UTF-8. The php identify the right part (one txt has many infos) from a .txt file and send that information to browser. Can I send this information to a specific email address instead of browser? And if Yes, can I say to this code to calculate more than one day but for more? Is this possible? Please help me with that. Thanks! [attachment deleted by admin] hi, im new here i hope to learn and help in the way i can since i'm a newbie with php but here it goes. I have some old databases i need to test, i want to mail these old users from a website i had but i need to know if the database contains invalid e-mails and remove them so i dont mess up my server's good ip reputation. So i found the checkdnsrr function: Code: [Select] function checkEmail($email) { // checks proper syntax if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/" , $email)) { // gets domain name list($username,$domain)=split('@',$email); // checks for if MX records in the DNS if(!checkdnsrr($domain, 'MX')) { return false; } return true; } return false; } so everyone knows this function, i just wanted to run it to multiple e-mail addresses like from a text file. when i say multiple, i mean arround 500.000 or 50k at the time. i just want to output the bad e-mails to a text file. hope someone can help me on this one. thanks in advance Hello I am working on php website. Now here im working on sending orders. So once it is ordered the confirmation e-mail goes to one who ordered(he enters his e-mail id manually) and the head of the department(e-mail ids written in code). But now I have put a checkbox that if the person is head of the department he checks the checkbox and e-mail should be sent to him. So how to verify this by checkbox.Can anyone please help me with this. The person should not get 2 e-mails. I hope I was clear in explaining my doubt. If not please do ask me for more explanation. Thank you. The imap code below displays the date like this: Sat, 18 Feb 2012 19:22:02 +0100 I want the date to be displayed like this instead: 2012-02-18 Any idea how I can achieve this? Thanks in advance Code: [Select] <?php date_default_timezone_set ("Europe/Stockholm"); /* connect to mail */ $hostname = '{xxx.xxxx.com:143/notls}INBOX'; $username = 'xxxxx@xxxxx.com'; $password = 'xxxxxx'; /* try to connect */ $inbox = imap_open($hostname,$username,$password) or die('Anslutning till mail misslyckades: ' . imap_last_error()); /* grab emails */ $emails = imap_search($inbox,'ALL'); /* if emails are returned, cycle through each... */ if($emails) { /* begin output var */ $output = ''; /* put the newest emails on top */ rsort($emails); /* for every email... */ foreach($emails as $email_number) { /* get information specific to this email */ $overview = imap_fetch_overview($inbox,$email_number,0); $message = imap_fetchbody($inbox,$email_number,2); $date = date('d m Y'); $swedate = $overview[0]->date; /* output the email information */ $output.= '<li>'; $output.= '<a href="#"><strong>'.$swedate.'</strong> '; $output.= ''.$overview[0]->subject.'<br> '; $output.= '<small> Från: '.$overview[0]->from.'</small></a>'; $output.= '</li>'; } echo $output; } /* close the connection */ imap_close($inbox); ?> How do u work with .jpg file attachments using the IMAP mail functions... i already know how to read the body text from an e-mail with IMAP but I haven't worked with attachments and don't know where to start... i basically want to get the .jpg attachment and save it to a folder on my server. Hey guys, Been developing a bespoke "helpdesk" system for work and, while it works well on the whole, I am having major problems with base64 encoded email bodies. Admittedly, this might be due to my misunderstanding of imap body parts. It seems in my current setup, the system thinks that all mails are either "type" 0 or 4. As a result, base64 emails don't get decoded and display as an unreadable long string. Here is what my code for the body decoding looks like just now - can provide more on request. $from=$overview[0]->from; $subject=$overview[0]->subject; $subdb=mysql_real_escape_string($subject); $lookingfor=explode("~#",$body); $result=$from; $find=strrpos($ir, $lookingfor[1]); $findreplystream=mysql_query("SELECT * FROM tickets WHERE ticket_md5='$lookingfor[1]'") or die(''.mysql_error().''); $stream=mysql_fetch_array($findreplystream); $now=time(); if($structure->encoding == 0){ $arr1=array("=A3", "=80"); $arr2=array("£", "€"); $newcontent=$explodeunder[0]; define("CHARSET", "ISO-8859-1"); $dbcontenta=str_replace($arr1, $arr2, $newcontent); $r=mb_detect_encoding($dbcontenta); if($r=="UTF-8"){ $dbcontents=mb_convert_encoding($dbcontenta, "ISO-8859-1", "UTF-8"); $dbcontent1=addslashes($dbcontents); $dbcontent2=strip_tags($dbcontent1); } elseif($r=="ASCII"){ $dbcontentb=mb_convert_encoding($dbcontenta, "UTF-8", "ASCII"); $dbcontents=mb_convert_encoding($dbcontentb, "ISO-8859-1", "UTF-8"); $dbcontent1=addslashes($dbcontents); $dbcontentf=strip_tags($dbcontent1); $dbcontent2=quoted_printable_decode($dbcontentf); } } elseif($structure->encoding == 4) { $dbcontent=$explodeunder[0]; $dbcontentf=quoted_printable_decode($dbcontent); $dbcontent2=mb_convert_encoding($dbcontentf, "ISO-8859-1", "UTF-8"); } elseif($structure->encoding == 3) { $dbcontent2=imap_base64($explodeunder[0]); } elseif($structure->encoding == 1){ $dbcontent3=imap_8bit($explodeunder[0]); $dbcontent2=quoted_printable_decode($dbcontent3); } Can anyone advise me with this? I'd be greatful for any assistance at all, as it's causing me nightmares! All the best I'm using imap_open and when I use imap_headerinfo and output the info, I want to be able to have an array of words to match the fromaddress to.... case-insensitive. I tried ton of different ways... array_search array_filter stripos stristr And tried adding strtolower in a few Tried setting the object as a var and comparing it that way... but it either chokes on the object or the array... Or ignores it completely For example setting an array like this: Code: [Select] $blacklist_array = array("wl_partners@cupid.com", "Replica Shop", "CJ Adams", "eharmony", "Dr.Maxman", "Credit Check"); And the fromaddress has this in it: Credit Check <check@iamaspammer.com> I can't get it to work to match the Credit Check only part. I got it to work if I do a foreach through the messages and then a foreach through the array then process a good or bad result, but it takes too long if there are a ton of messages to process... The code is a mess right now with all the trial and errors. Any ideas? I'm kinda brain dead at this point and have been up way to long... Thanks... |