Jump to content

IanArcher

Members
  • Posts

    115
  • Joined

  • Last visited

Everything posted by IanArcher

  1. Ok i see where your coming from. See i made that conclusion from the email clients i used, though when i tried to reserach it, their isn't much help articles or documentation at all really, that tells you all about email and their doings 'under the hood'. What regular expresion can i use to do so? Including the filename extensions?
  2. These are very simple articles though, with just bold, italicized, underlined text and images. It's not my choice for all the images to be named image###, by default email clients name all images inserted into the emails in that sequence. For example, i just inserted 4 images into an email and sent them to myself and here is the source of the email. Now before i sent it, these images had other filenames. <img width=960 height=612 id="Picture_x0020_1" src="cid:image001.jpg@01CCD11C.6AFFF2F0"> <img width=1126 height=2048 id="Picture_x0020_2" src="cid:image002.jpg@01CCD11C.6AFFF2F0"> <img width=1052 height=2048 id="Picture_x0020_3" src="cid:image003.jpg@01CCD11C.6AFFF2F0"> <img width=903 height=2048 id="Picture_x0020_4" src="cid:image004.jpg@01CCD11C.6AFFF2F0"> <img width=500 height=419 id="Picture_x0020_5" src="cid:image005.jpg@01CCD11C.6AFFF2F0"> You see what i'm getting at?
  3. Ok i'll explain further.Over time this method will be used more and more for posting New news articles, every time a new email with new images are sent the client, like you said, will automatically name them in that sequence, so eventual when it comes time to posting, those images in that same folder from a previous article with be overwritten. And if someone goes back to look at a previous article, the images in that article will be gone and overwritten with the new ones causing them to be confused. Which is why i implemented this series of functions, so many like that. Using this method, i put out a rule. Only a maximum of 12 images will be allowed to be inserted. Which is where //AND SO FORTH FOR 12 OCCURENCES comes from. In my head, i believe PHP reads and processes each script on each line accordingly unless it is a reference to a variable or function before and after that line. Just as it would read and process each <img> in the email body. My idea was using mkdir to create a new directory to hold the images for that specific article based on the subjects name. //These functions searches the open e-mail for the the prefix defining strings. //Need a function to search after the space after the strings because the subject, categories, snippet, tags and message are constant-changing. $subject = preg_match('/Title: (.*)/', $text_part, $matches) ? $matches[1] : ''; $stripped = strtolower(ereg_replace("[^A-Za-z0-9 ]", "", $subject)); //removes special characters from article/folder name $subject = str_replace("Title: ", "" ,$subject); // Creating a directory to hold the images for this article $subject = strtolower(str_replace(" ", "_", $stripped)); // builds a directory name based on the article's name $dirname = $subject; $dir = mkdir($dirname, 0777); // creates the directory Though with mkdir i get a "No such file or directory" error message. Did that clear it up for you?
  4. Ok thanks for clearing that up for me. I don't want it to seem as if i run here for every little problem or issue to be spoon fed, i do tremendous amounts of research and work on my own for this, but this is something i really need help with. If a .png is the first found when the script reaches to this line, then that means the email has a .png image first, and will be named automatically be email laws? as image001.png If found .jpg is found first then that means the first image will be named image001.jpgEven if the first image is a .png (it will be generated as image001.png) and the next image found would be a .jpg, it would be named image002.jpg, because the email doesnt list emails by file extensions, but by the amount of images in the email, which is why a number sequence is appended to the image file in the email. What if the first image is a .png, then i want it to be image001.png. But the next is a .bmp then i want it to be image002.bmp and not image002.png. But what if it is a .gif for the third? i want it to be image001.gif and not image001.png.What if the second image was a .png? Then i want the script to know to let it be image002.png.And so forth in that sequence of possibilities.At max this will support up to 12 images for the entire process off updating to the MySQL table. What is the process of doing this?Also the filename extensions have to be specified in the REGEX so the if functions would know how to come into play. I really need an example of what i believe would mainly be based around if functions, but also some guiding in where to go for a solution in the manual? # Haystack = // Call if functions into play here, (remember .gif, .png, .jpg, .bmp) // for .png images $png1 = 'src="images/image001.png"'; $png2 = 'src="images/image002.png"'; $png3 = 'src="images/image003.png"'; $png4 = 'src="images/image004.png"'; $png5 = 'src="images/image005.png"'; $png6 = 'src="images/image006.png"'; $png7 = 'src="images/image007.png"'; $png8 = 'src="images/image008.png"'; $png9 = 'src="images/image009.png"'; $png10 = 'src="images/image010.png"'; $png11 = 'src="images/image011.png"'; $png12 = 'src="images/image012.png"'; // for .jpg images $jpg1 = 'src="images/image001.jpg"'; $jpg2 = 'src="images/image002.jpg"'; $jpg3 = 'src="images/image003.jpg"'; $jpg4 = 'src="images/image004.jpg"'; $jpg5 = 'src="images/image005.jpg"'; $jpg6 = 'src="images/image006.jpg"'; $jpg7 = 'src="images/image007.jpg"'; $jpg8 = 'src="images/image008.jpg"'; $jpg9 = 'src="images/image009.jpg"'; $jpg10 = 'src="images/image010.jpg"'; $jpg11 = 'src="images/image011.jpg"'; $jpg12 = 'src="images/image012.jpg"'; // for .gif images $gif1 = 'src="images/image001.gif"'; $gif2 = 'src="images/image002.gif"'; $gif3 = 'src="images/image003.gif"'; $gif4 = 'src="images/image004.gif"'; $gif5 = 'src="images/image005.gif"'; $gif6 = 'src="images/image006.gif"'; $gif7 = 'src="images/image007.gif"'; $gif8 = 'src="images/image008.gif"'; $gif9 = 'src="images/image009.gif"'; $gif10 = 'src="images/image010.gif"'; $gif11 = 'src="images/image011.gif"'; $gif12 = 'src="images/image012.gif"'; // for .bmp images $bmp1 = 'src="images/image001.bmp"'; $bmp2 = 'src="images/image002.bmp"'; $bmp3 = 'src="images/image003.bmp"'; $bmp4 = 'src="images/image004.bmp"'; $bmp5 = 'src="images/image005.bmp"'; $bmp6 = 'src="images/image006.bmp"'; $bmp7 = 'src="images/image007.bmp"'; $bmp8 = 'src="images/image008.bmp"'; $bmp9 = 'src="images/image009.bmp"'; $bmp10 = 'src="images/image010.bmp"'; $bmp11 = 'src="images/image011.bmp"'; $bmp12 = 'src="images/image012.bmp"'; # End of Haystack ///////////// First image in email if first_occurence is .png get $png1 needle from $haystack ( $find = '#src="cid:([^"@]*)@([^"]*)"#'; //this needs to be modified to look for .png specifically $replace = $png1 ); else first_occurence is .jpg? then get $jpg1 ( $find = '#src="cid:([^"@]*)@([^"]*)"#'; //this needs to be modified to look for .jpg specically $replace = $jpg1 ); else first_occurence is .gif ? ( $find = '#src="cid:([^"@]*)@([^"]*)"#'; //this needs to be modified to look for .gif specically $replace = $gif1 ); else first_occurence is .bmp ? ( $find = '#src="cid:([^"@]*)@([^"]*)"#'; //this needs to be modified to look for .bmp specically $replace = $bmp1 );//////////////// Second image in email if second_occurence is .png get $png2 needle from haystack ( $find = '#src="cid:([^"@]*)@([^"]*)"#'; //this needs to be modified to look for .png specifically $replace = $png2 ); else second_occurence is .jpg? then get $jpg2 needle from haystack ( $find = '#src="cid:([^"@]*)@([^"]*)"#'; //this needs to be modified to look for .jpg specically $replace = $jpg2 ); else second_occurence is .gif ? then get $gif2 needle from haystack( $find = '#src="cid:([^"@]*)@([^"]*)"#'; //this needs to be modified to look for .gif specically $replace = $gif2 ); else second_occurence is .bmp ? then get $bmp2 needle from haystack( $find = '#src="cid:([^"@]*)@([^"]*)"#'; //this needs to be modified to look for .bmp specically $replace = $bmp2 ); //AND SO FORTH FOR 12 OCCURENCES //Performs the matches $html_part = preg_replace($find, $replace, $html_part);
  5. Thanks for that snippet.I have to ask for learning purposes, what is the difference between the regex you posted, and the one i planned on using? "/src="cid:(.*).png@(.*)/""
  6. Your script works and it gets the the images as attachements and saves it to the folder "images"You were completely right, Outlook and roundcube was showing these images as just that and not attachments to the email. Now what im trying to do is replace every instance of src="cid:image001.png@ with src="images/image001.png"I use string replace but it keeps bringing back the same "cid" string. // Call if functions into play here, (remember .gif, .png, .jpg, .bmp) // for .png images $png1 = "images/image001.png"; $png2 = "images/image002.png"; $png3 = "images/image003.png"; $png4 = "images/image004.png"; $png5 = "images/image005.png"; // for .jpg images $jpg1 = "images/image001.jpg"; $jpg2 = "images/image002.jpg"; $jpg3 = "images/image003.jpg"; $jpg4 = "images/image004.jpg"; $jpg5 = "images/image005.jpg"; // for .gif images $gif1 = "images/image001.gif"; $gif2 = "images/image002.gif"; $gif3 = "images/image003.gif"; $gif4 = "images/image004.gif"; $gif5 = "images/image005.gif"; // for .bmp images $bmp1 = "images/image001.bmp"; $bmp2 = "images/image002.bmp"; $bmp3 = "images/image003.bmp"; $bmp4 = "images/image004.bmp"; $bmp5 = "images/image005.bmp"; str_replace('src="cid:image001.png@', 'src="$png1"', $html_part); str_replace('src="cid:image002.jpg@', 'src="$jpg2"', $html_part); str_replace('src="cid:image003.png@', 'src="$jpg3"', $html_part); There's also that problem where random integers and words are generated after the "@"for example:src="cid:image001.png@01CCC701.5A896430"but that random text isn't static, it's dynamic, so everytime this is run (or i should say whenever the email is sent), a new set oftext is placed there.Any suggestions on this?
  7. Ok i have a copy of your script i'll do with it what i can right now.
  8. Here is the complete script at the moment, mind taking a look (justsomeguy), not asking to be spoonfed or anything: //IMAP Functions begin here (Before NewsUpdate function) //Accessing e-mail inbox $mailbox = '{server.com/imap/novalidate-cert}INBOX'; $mbox = imap_open($mailbox, 'user', 'pass'); // log in to mail server //Sets up FTP connection $ftp_server = "ftp.example.com"; $ftp_user = "user"; $ftp_pass = "pass"; //Login with username and password $conn = ftp_connect($ftp_server); $login = ftp_login($conn, $ftp_user, $ftp_pass);# # Images inserted into the emails cannot be seen on a web browser, because it was inserted into that email# So the image reference in the source code has to be a hyperlink reference to the image and not cid:image001@1CCC701.5A896430# My issue is there may be one or more images inserted in that email to be published to the site, so how would i be able to differentiate and upload them# to a specified FTP server folder and also get the uploaded file as use the hyperlink reference as a string to be replaced with the current as seen below.# In the body source, the image reference is:# <img width=183 height=183 id="Picture_x0020_1" src="cid:image001.png@01CCC701.5A896430"># to become# <img width=183 height=183 id="Picture_x0020_1" src="image001.png"># $no = 4; //number of the e-mail message. Defined as first e-mail in the inbox (not a UID) $open_email_msg = imap_body($mbox, $no); $body = imap_qprint(imap_fetchbody($mbox, $no, "1.2")); /* Attempts to save the body using file_get_contents and file_put_contents $bodyExtract = file_get_contents($body); $bodySave = file_put_contents('bodyhold.html', $bodyExtract); //$tempFile = file_get_contents('bodyhold.html'); */ echo $body; # if (strpos($bodyExtract, '/src="cid:(.*)"/') # { # $tempfile->$body //invalid statements, if properly executed this would put the copied body file exactly where the body used to be, not exactly retrieving the image # } //The following sequence defines the function "NewsUpdate" function NewsUpdate ($open_email_msg, $body) { //Login to MySQL Datebase $hostname = "localhost"; $db_user = "user"; $db_password = "pass"; $database = "database"; $db_table = "table"; $db = mysql_connect($hostname, $db_user, $db_password); mysql_select_db($database,$db); //These functions searches the open e-mail for the the prefix defining strings. //Need a function to search after the space after the strings because the subject, categories, snippet, tags and message are constant-changing. $subject = preg_match('/Title: (.*)/', $open_email_msg, $matches) ? $matches[1] : ''; $subject = str_replace("Title: ", "" ,$subject); $categories = preg_match('/Categories: (.*)/', $open_email_msg, $matches) ? $matches[1] : ''; //Searches the open e-mail for the string "Categories" $categories = str_replace("Categories: ", "" ,$categories); $tags = preg_match('/Tags: (.*)/', $open_email_msg, $matches) ? $matches[1] : ''; //Searches the open e-mail for the string "Tags" $tags = str_replace("Tags: ", "" ,$tags); //Alternative function for defining categories # $categories = str_replace(' ',',',$subject); $snippet = preg_match('/Snippet: (.*)/', $open_email_msg, $matches) ? $matches[1] : ''; //Searches the open e-mail for the string "Snippet" $snippet = str_replace("Snippet: ", "" ,$snippet);########################################################## $content = preg_match('/Message: (.*)/', $body, $matches) ? $matches[1] : ''; //Searches the open-email for the string "Message" $content = str_replace("Message: ", "" ,$content); ######################################################### # $uri = str_replace(" ", "-", $subject); //uri of news article //This defines the article's tags # $tags = str_replace(' ',',',$subject); //DDIE $when = strtotime("now"); //date article was posted # THIS CODE WILL TELL MYSQL TO INSERT THE DATA FROM THE EMAIL INTO YOUR MYSQL TABLE $sql = "INSERT INTO $db_table(`caption`,`snippet`,`content`,`when`,`tags`,`categories`,`DATE`) values ('$subject','$snippet','$content','$when','$tags','$categories','$when')"; if($result = mysql_query($sql ,$db)) { } else { echo "ERROR: ".mysql_error(); } //echo "<h1>News Article added!</h1>"; //uncomment for testing purposes } //end defining the function NewsUpdate //This script that searches the e-mail for the string "News Update", and if it is found it will start the function NewsUpdate //if(strpos($open_email_msg,"News Update")) NewsUpdate ($open_email_msg, $body); //calls the function NewsUpdate # else {# echo "<b>News Update</b> not found in e-mail message!";# } //Deletes the email imap_delete($mbox, $no);# imap_expunge($mbox); imap_close($mbox); //closes the mailbox ftp_close ($conn); //closes the ftp connection ?>
  9. I originally sent a test email message with the format for posting to the table to the email account with a sample image, and when i checked the original message in Microsoft Outlook that i sent, there is an option for downloading all attachments from the email but there wasnt any attachements found in the email, so the image doesn't count as an attachment, because i had considered going down that path of extracting attachments but coming across this finding in Outlook means that would've probably been a dud. What do you think? EDIT:So i found obtained the source of the e-mail i sent through (On hotmail.com, not Outlook) and here is a paste of the what i believe is MIME? text of the imagehttp://pastebin.com/VDzHqVnr
  10. I have overcome alot on my own while the forums here were down. But im stuck another issue.Images inserted into the emails cannot be seen on a web browser, because it was inserted into that emailSo the image reference in the source code has to be a hyperlink reference to the image and not cid:image001@1CCC701.5A896430My issue is there may be one or more images inserted in that email to be published to the site, so how would i be able to differentiate and upload themto a specified FTP server folder and also get the uploaded file as use the hyperlink reference as a string to be replaced with the current as seen below.In the body source, the image reference is:<img width=183 height=183 id="Picture_x0020_1" src="cid:image001.png@01CCC701.5A896430">Below is the code as i imagine it in my head. Could somebody help me find a solution to this? <?php//Specifies e-mail server inbox and connects to it $mailbox = '{server.example.com/imap/novalidate-cert}INBOX'; $mbox = imap_open($mailbox, 'user', 'pass'); // log in to mail server//Sets up FTP connection $ftp_server = "ftp.example.com"; $ftp_user = "user"; $ftp_pass = "pass";//Login with username and password $conn = ftp_connect($ftp_server); $login = ftp_login($conn, $ftp_user, $ftp_pass);// the body of the e-mail body with its original formatting quoted-printable characters to an 8-bit character set$body = imap_qprint(imap_fetchbody($mbox, $no, "1.2"));//CID image names will be dynamic so i must use REGEX $fileto = "/src="cid:(.*).png@(.*)/""; #$fileto = "/src="cid:(.*).bmp(.*)/""; #$fileto = "/src="cid:(.*).png(.*)/""; #$fileto = "/src="cid:(.*).gif(.*)/""; $target_f = "public_html/images/"; if(strpos($body, $fileto) { $remote_f = ftp_nb_put($conn, $target_f, $fileto, FTP_ASCII); } or die "Could not convert image!"; $new_img = str_replace($fileto, $remote_f, $body); ftp_close ($conn); ?>
  11. Would you recommend something like this preg_match_all('/([^:\\s]+): (.+)/', $open_email_msg, $matches, PREG_SET_ORDER); echo '<pre>' . print_r($matches, 1) . '</pre>'; I used this code $subject = explode("Title: ", $open_email_msg); // Replace with whatever the line separator is foreach($subject as $line){ $temp = explode(": ", $line, 2); $msg[$temp[0]] = $temp[1]; } $categories = explode("Categories: ", $open_email_msg); // Replace with whatever the line separator is foreach($categories as $line){ $temp = explode(": ", $line, 2); $msg[$temp[0]] = $temp[1]; } $snippet = explode("Snippet: ", $open_email_msg); // Replace with whatever the line separator is foreach($snippet as $line){ $temp = explode(": ", $line, 2); $msg[$temp[0]] = $temp[1]; } $content = explode("Message: ", $open_email_msg); // Replace with whatever the line separator is foreach($content as $line){ $temp = explode(": ", $line, 2); $msg[$temp[0]] = $temp[1]; } But all it did was give me the word "Array" in multiple columns in the MySQL table.
  12. I am trying to get the scripts to search the $open_email_msg which different e-mails will have different info but the same format as below. I just want whatever they put after Title: or Tags: or Categories: whatever that data is to be captured and not the string "Title:" or "Tags:" or "Categories:" This is just a snippet of the whole code, the rest inserts the info into a MySQL table and then is posted to a News Article on the site.Can somebody help me find a solution to this please?Strict e-mail message format: <?php //These functions searches the open e-mail for the the prefix defining strings. //Need a function to search after the space after the strings because the subject, categories, snippet, tags and message are constant-changing. $subject = strpos($open_email_msg, "Title:"); //Searches the open e-mail for the string "Title" $categories = strpos($open_email_msg, "Categories:"); //Searches the open e-mail for the string "Categories" $snippet = strpos($open_email_msg,"Snippet"); //Searches the open e-mail for the string "Snippet" $content = strpos($open_email_msg, "Message"); //Searches the open-email for the string "Message" $tags = str_replace(' ',',',$subject); //DDIE $uri = str_replace(' ','-',$subject); //DDIE $when = strtotime("now"); //date article was posted ?>
  13. I moved my function above and called it and it worked. function NewsUpdate ($open_email_msg) { //function declaration} //Test code for email message. $open_email_msg = file_get_contents('emailmessage.html'); //A script that searches the e-mail for the string News Update, and if it is found it will start the function NewsUpdate if(strpos($open_email_msg,"News Update")) NewsUpdate ($open_email_msg);else { echo "<h3>'News Update</h3>not found in e-mail message!"; }
  14. I am at a point in applying a test for the overall code before incorporating the email script justsomeguy provided.Haven't really create my own function before, so what i am attempting is to start the scripts below the line "function NewsUpdate" but i want them to be apart of the function. In the if statement, when the script finds the string "News Update" in the 'email message' it will start those scripts if to (the else statement all the way at the bottom) it will fail and say "News Update not found in e-mail message" But i get the error:Parse error: syntax error, unexpected T_FUNCTION What am i doing wrong? //Test code for email message. $open_email_msg = file_get_contents('emailmessage.html'); //A script that searches the e-mail for the string News Update, and if it is found it will start the function NewsUpdate if(strpos($open_email_msg,"News Update")) function NewsUpdate ($open_email_msg) { //Login to MySQL Datebase$hostname = "localhost";$db_user = "user";$db_password = "pass";$database = "tablename";$db_table = "bx_news_entries"; $db = mysql_connect($hostname, $db_user, $db_password);mysql_select_db($database,$db); $subject = 'Test News Article';$tags = str_replace(' ',',',$subject); //DDIE$uri = str_replace(' ','-',$subject); //DDIE$when = strtotime("now"); //date article was posted$categories = 'Events';$content = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.';$snippet = 'Lorem ipsum dolor sit amet.'; //$snippet = explode(".", $content, -1); # THIS CODE WILL TELL MYSQL TO INSERT THE DATA FROM THE EMAIL INTO YOUR MYSQL TABLE$sql = "INSERT INTO $db_table(`caption`,`snippet`,`content`,`when`,`uri`,`tags`,`categories`,`DATE`) values ('$subject','$snippet','$content','$when','$uri','$tags','$categories','$when')";if($result = mysql_query($sql ,$db)) {} else {echo "ERROR: ".mysql_error();}echo "<h1>News Article added!</h1>"; } else {echo "<h3>'News Update</h3>not found in e-mail message!";} ?>
  15. Alright, i'll try to do what i can with this, thanks alot.I will post back here what happens with it tomorrow.
  16. If the email format every time strictly maintain this format: The very first line in the e-mail would always be the subject, and php would define it as $caption and $uriThe very second line in the e-mail would always be the tags and php would define it as $tagsThe very third line in the e-mail would always be the date and php would define it as $date and then use either mktime or strtotime as a conversion to Unix timestamp.The very fourth line in the e-mail would always be the message and php would define it as $message and would use explode() to split up to the very first line and define it as $snippet and $snippet would be inserted into the uri column in bx_news_entries.The very fifth line in the e-mail would always be the category name and PHP would define it as $category and insert it into the category column.$m_mail = imap_open("{server.myhost.com}INBOX", "username", "password");//get all messages$m_search=imap_search ($m_mail, 'ALL ');// Order results starting from newest messagersort($m_search);//loop through and do what's necessaryforeach ($m_search as $onem) { //get imap header info for obj thang $headers = imap_headerinfo($m_mail, $onem); $head = imap_fetchheader($m_mail, $headers->Msgno); $body = imap_body($m_mail, $headers->Msgno, FT_INTERNAL ); $line1 = find('First Line', =>$caption, $m_search); $line1_2 = find('First Line', =>$uri, $m_search); $line2 = find('Second Time', =>$tags, $m_search); $line3 = find('Third Line', =>$date, $m_search); strtotime($date, =>$date); $line4 = find('Fourth Line', =>$message, $m_search); explode($message at first 2 lines, $snippet); $line5 = find('Fifth Line', =>$category, $m_search); //DO WHAT YOU NEED TO DO HERE - insert to the database, etc //Need to also access permissions to the website as an admin to feature features that allow posting to BxNewsEntries. BxNewsEntries is a MySQL table that holds the info for the news postings. $hostname = "localhost"; // usually is localhost, but if not sure, check with your hosting company, if you are with webune leave as localhost $db_user = "username"; // change to your database password $db_password = "password"; // change to your database password $database = "database"; // provide your database name $db_table = "bx_news_entries"; // leave this as is $db = mysql_connect($hostname, $db_user, $db_password); mysql_select_db($database,$db); $sql = "INSERT INTO $db_table(id,author_id,caption,snippet,content,when,uri,tags,categories,comment,vote,date,status,featured,rate,rate_count,view_count,cmts_count) values ('".mysql_real_escape_string(stripslashes($_REQUEST['$caption']))."', '".mysql_real_escape_string(stripslashes($_REQUEST['$snippet']))."', '".mysql_real_escape_string(stripslashes($_REQUEST['$content']))."', '".mysql_real_escape_string(stripslashes($_REQUEST['$uri']))."', '".mysql_real_escape_string(stripslashes($_REQUEST['$tags']))."', '".mysql_real_escape_string(stripslashes($_REQUEST['$categories']))."', '".mysql_real_escape_string(stripslashes($_REQUEST['$date']))."',"; if($result = mysql_query($sql ,$db)) { } else { echo "ERROR: ".mysql_error(); } } else {}//purge messages (if necessary)imap_expunge($m_mail);//close mailboximap_close($m_mail); This is really how i imagine it in my head, i can see it's obviously not correct functions but i honestly need some serious help with this, maybe if you were to type an example of an effective code please?
  17. What were those complex rules your were talking about? I might need to explore those options.Though What would be the most straight forward way of doing this effectively using PHP?
  18. By the way, It is an HTML email because in the content column of bx_news_entries table, there are HTML formatting tags before text to split up the paragraphs, such as <p>Hi there, sentence, sentence, sentence</p><p>The new art exhibit beings as follows,</p><p>March 23, 2011</p><p>March 30th, 2011</p> Essentially as i observe it in the table, the <p> tags serve as <br /> tags strangely. Also, In my original post, would the code that i said somebody else wanted to use for the similar initiative, work for mines?
  19. I checked out some of those earlier, but i'll take a better look, Also will you still be able to post your better script that you have home here later today?
  20. Pretty much in the first post. It is not a g-mail account, it is a private e-mail on my server. Though I don't know how to find out the imap host for it in cpanel. This is how it looks: Lets say the e-mail is aligned to like this on particular lines so the script would know which line would go into which column in the table.From: admin@example.comTo: newsfeed@example.comSubject: Test News Article! <--- This would serve as the caption and uri for the news article, and would go into the caption column and uri column. test news article <--- (Line 1:) This line would be for the tags that get inserted into the tags column12/20/2011 <--- (Line 2:) This line would go into the date column but would have to be converted to Unix timestamp (Line 3, based on line breaks,) Would be the message that gets inserted into the content column, and the first line only would automatically be inserted into the snippet column<p>Hello. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> How could i attain this?
  21. How can I make it so when I e-mail for e.g. news@example.com text/information of the e-mail is written into a mysql table? It would extract the contents of a new email and write them into MySQL table. This table manages news articles on the website, so in the MySQL columns:"content" is the body of the message"caption" is the title of the news article"snippet" is the title that will appear in a "Latest News" block"uri""date" is the date the article is posted." $subject = caption = uri $message = content = snippet(first two lines of content) $date = date (in Unix timestamp) The table is named bx_news_entries manages the news articles visibly.I researched and saw a user who posted this on stackoverflow who's code looked like so: <?php$imap = imap_open("{gmail.com}", "username", "password"); if( $imap ) { //Check no.of.msgs $num = imap_num_msg($imap) //if there is a message in your inbox if( $num >0 ) { //read that mail recently arrived echo imap_qprint(imap_body($imap, $num)); } //close the stream imap_close($imap);}?> We are using an exchange server..I am a coop student so I am not really advanced at this. I tried this as a test to see if it works, logging in gmail to read email. It didnt work. <?php // connect to the mailbox$m_mail = imap_open("{mail.https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2}INBOX", "username", "password"); //get all messages$m_search=imap_search ($m_mail, 'ALL '); // Order results starting from newest messagersort($m_search); //loop through and do what's necessaryforeach ($m_search as $onem) { //get imap header info for obj thang $headers = imap_headerinfo($m_mail, $onem); $head = imap_fetchheader($m_mail, $headers->Msgno); $body = imap_body($m_mail, $headers->Msgno, FT_INTERNAL ); echo $body; } //purge messages (if necessary)imap_expunge($m_mail); //close mailboximap_close($m_mail); ?> I have the code imagined in my head, i just need to bring it to fruition.Can somebody assist me with this please?
×
×
  • Create New...