Jump to content

srujana

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

srujana's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have used this code in my site. It is really good. You can have 2 objects for the same functions.. Here is what I have done in my page: var opt = new OptionTransfer("from","to"); opt.setAutoSort(true); opt.setDelimiter(","); opt.setStaticOptionRegex("static"); opt.saveRemovedLeftOptions("removedLeft"); opt.saveRemovedRightOptions("removedRight"); opt.saveAddedLeftOptions("addedLeft"); opt.saveAddedRightOptions("addedRight"); opt.saveNewLeftOptions("newLeft"); opt.saveNewRightOptions("newRight"); Similarly, you can have another in the same form I guess. var optSecond = new OptionTransfer("first","second"); Hope it helps !
  2. try to echo the $tempval or echo the complete sql and see what it returns.
  3. Hi, I want to check whether few statements are present in the database or not. A regular where condition is sufficient for this. But my concern is that, the user may enter sentences like SMS short codes like 'txt' for text, 'dnt' for dont etc. is there any easy way with PHP or MySQL than manually checking with our common sense?
  4. No, The same was given there but with some extra info php can do. I gave an example for multi columns which I did for my document.
  5. For the example you said it is possible to change to bold, italic and underlined. I got it. But I am passing all of my output(mysql output) to a text file and then by using the multicell function I am getting multi-columns where the mysql output text file is give as an input file for this function. Since all the text is passed ONCE I can either change all of my output to bold or italic or underlined.But all at once.I dont need that.I only need some of the text from the whole text to be formatted. So, I also outputted <b><u> in the text file so that the FPDF will recognise and make appropriate changes in the pdf file. writeHTML function will do it what I said.. but not with multi columns.. I need multicolumns. Hope you got me clearly.
  6. I need it with FPDF. My work is 80% done but only formatting is left. Please check this link http://www.sala.pingst.se/htm/multi.php Tags like <b><u> were also printing there instead of making bold and underlined. I need multi column and also the text in a formatted way. writeHTML() can do it but it wont make multi column. Please help me in this.
  7. Hello, I want to output some text to pdf file using FPDF. Outputting a text is good even with multi columns.But what I need is I need that text to be formatted. Like Some text to be bold and italic etc. I can either make a multi column pdf or a html formatted page to PDF, but I want both of them.I couldnt integrate both the functions and from the forums I found someone refering HTML2PDF, but I also need multi column with it.. Please suggest me with some example.I am in need of it badly Thanks in advance.
  8. is smtp_mail.php will be there in default.. i executed thinking so and got that cannot include..
  9. ya.. i asked them several times... what they said is to try smtp... since i had no other choice.. i am running back of books and net and tried so many scripts... this is my position right now:(
  10. I already worked with that script and failed... coz my hosting service is not providing tht function for some reasons:( do u have any other script??
  11. shortj75, thanks for ur reply.the script above is saying that the email is sent successfully... the same happens with my past scripts but i havent get any mail. this is because that my hosting service wont allow mail function so some reasons. so.. i am looking for an alternative.. have u seen my script above... can u find anything wrong in tht?
  12. Hai all, i want a feedback form in my site and i tried with mail() function.But my hosting service doesnt provide me. And he suggested to do it in any other way like smtp. I tried with many scripts which are online.But couldnt succeed.I took Professional PHP4 book from my library and tried with the code which is there in it. It is not sending email .. and it even shows that there is no error. I used 3 files.I am pasting them here.and the o/p i got. I dont know where i am going wrong.Please help me:( This is my_mail_class.php [code]<?php //my_mail_class.php class My_Mail { var $to=''; var $from=''; var $reply_to=''; var $cc=''; var $bcc=''; var $subject=''; var $body=''; var $validate_email=true; var $rigorous_email_check=false; var $allow_empty_subject=false; var $allow_empty_body=false; var $headers = array(); var $ERROR_MSG; var $ERR_EMPTY_MAIL_TO="Empty TO Field!"; var $ERR_EMPTY_SUBJECT="Empty SUBJECT Field!"; var $ERR_EMPTY_BODY="Empty BODY Field!"; var $ERR_SEND_MAIL_FAILURE="An Error Occured While Attempting To Send EMAIL!"; var $ERR_TO_FIELD_INVALID="TO Field Contains Invalid Email Address!"; var $ERR_CC_FIELD_INVALID="CC Field Contains Invalid Email Address!"; var $ERR_BCC_FIELD_INVALID="BCC Field Contains Invalid Email Address!"; var $STR_NO_ERROR="No error has occured yet"; function CheckFields() { if(empty($this->to)) { $this->ERROR_MSG=$this->ERR_EMPTY_MAIL_TO; return false; } if(!$this->allow_empty_subject && empty($this->subject)) { $this->ERROR_MSG=$this->ERR_EMPTY_SUBJECT; return false; } if(!$this->allow_empty_body && empty($this->body)) { $this->ERROR_MSG=$this->ERR_EMPTY_BODY; return false; } $this->to=ereg_replace(";",",",$this->to); $this->cc=ereg_replace(";",",",$this->cc); $this->bcc=ereg_replace(";",",",$this->bcc); if(!empty($this->from)) $this->headers[]="From: $this->from"; if(!empty($this->reply_to)) $this->headers[]="Reply-To: $this->reply_to"; //check email addresses if specified so. if($this->validate_email) { $to_emails=explode(",",$this->to); if(!empty($this->cc)) $cc_emails=explode(",",$this->cc); if(!empty($this->bcc)) $bcc_emails=explode(",",$this->bcc); //use MX records to further check email addresses. if($this->rigorous_email_check) { if(!$this->rigorousEmailCheck($to_emails)) { $this->ERROR_MSG=$this->ERR_TO_FIELD_INVALID; return false; } else if(is_array($cc_emails) && !$this->rigorousEmailCheck($cc_emails)) { $this->ERROR_MSG=$this->ERR_CC_FIELD_INVALID; return false; } else if(is_array($bcc_emails) && !$this->rigorousEmailCheck($bcc_emails)) { $this->ERROR_MSG=$this->ERR_BCC_FIELD_INVALID; return false; } } else { if(!$this->email_check($to_emails)) { $this->ERROR_MSG=$this->ERR_TO_FIELD_INVALID; return false; } else if(is_array($cc_emails) && !$this->email_check($cc_emails)) { $this->ERROR_MSG=$this->ERR_CC_FIELD_INVALID; return false; } else if(is_array($bcc_emails) && !$this->email_check($bcc_emails)) { $this->ERROR_MSG=$this->ERR_BCC_FIELD_INVALID; return false; } } } return false; } function emailcheck($emails) { foreach($emails as $email) { if(eregi("<(.+)>",$email,$match)) $email=$match[1]; if(!eregi("^[_\-\.0-9a-z]+@([0-9a-z][_0-9a-z\.]+)\.([a-z]{2,4}$)",$email)) return false; } return true; } function rigorousEmailCheck($emails) { if(!$this->emailCheck($emails)) return false; foreach ($emails as $email) { list($user,$domain)=split("@",$email,2); if(checkdnsrr($domain,"ANY")) return true; else { return false; } } } function viewMsg() { if(!$this->checkFields()) return false; $this->headers=array(); $this->buildHeaders(); $this->headers[]="From: $this->from"; $this->headers[]="To: $this->to"; $this->headers[]="Subject: $this->subject"; $msg= implode("\r\n", $this->headers); $msg.="\r\n\r\n"; $msg.=$this->body; return $msg; } function send() { if(!$this->checkFields()) return true; $this->buildHeaders(); if(mail($this->to,stripslashes(trim($this->sunject)),stripslashes($this->body),implode("\r\n",$this->headers))) return true; else { $this->ERROR_MSG=$this->ERR_SEND_MAIL_FAILURE; return false; } } function errorMsg() { if(empty($this->ERROR_MSG)) return $this->STR_NO_ERROR; return $this->ERROR_MSG; } } ?> [/code] The above class is then extended by my_smtp_mail_class.php [code]<?php //my_smtp_mail_class.php include "./my_mail_class.php"; class My_Smtp_Mail extends My_Mail { var $smtp_host=''; var $smtp_port=25; var $socket=0; var $response_code=0; var $response_msg=''; var $ERR_SMTP_HOST_NOT_SET='SMTP host not set!'; var $ERR_SMTP_CONNECTION_FAILED='Failed to connect to the specified SMTP host!'; var $ERR_SMTP_NOT_CONNECTED='Establish a connection to an SMTP server first!'; var $ERR_COMMAND_UNRECOGNIZED='Unrecognizable command!'; var $ERR_HELO_WITHOUT_ARG='HELO command needs an argument'; var $ERR_MAIL_WITHOUT_ARG='MAIL FROM command needs an argument'; var $ERR_RCPT_WITHOUT_ARG='RCPT TO command needs an argument'; var $ERR_DATA_WITHOUT_ARG='DATA command needs an argument'; var $ERR_UNKNOWN_RESPONSE_FROM_SERVER='Unknown response from the server'; var $ERR_HELO_FAILED='HELOcommand failed'; var $ERR_MAIL_FAILED='MAIL TO command failed'; var $ERR_RCPT_FAILED='RCPT TO command failed'; var $ERR_DATA_FAILED='DATA command failed'; var $ERR_QUIT_FAILED='QUIT command failed'; var $ERR_INIT_SOCKET_ERROR="Couldn't initialize the socket!"; function connect() { if(empty($this->smtp_host)) { $this->ERROR_MSG=$this->ERR_SMTP_HOST_NOT_SET; return false; } $this->socket=fsockopen($this->smtp_host,$this->smtp_port,&$err_no,&$err_str); if(!$this->socket) { if(!$err_no) { $err_str=$this->ERR_INIT_SOCKET_ERROR; } $this->ERROR_MSG=$this->ERR_SMTP_CONNECTION_FAILED."$err_no: $err_str"; return false; } if(!$this->getResponse()) { $this->ERROR_MSG=$this->ERR_UNKNOWN_RESPONSE_FROM_SERVER.":".$this->response_msg; return false; } if($this->response_code!=220) { $this->ERROR_MSG=$this->ERR_SMTP_CONNECTION_FAILED." ".$this->response_code." ".$this->response_msg; return false; } return true; } function getResponse() { if(!$this->socket) { $this->ERROR_MSG=$this->ERR_SMTP_NOT_CONNECTED; return false; } $server_response=fgets($this->socket,1024); if(ereg("^([0-9]{3}) (.*)$",$server_response,$match)) { $this->response_code=$match[1]; $this->response_msg=$match[2]; return true; } $this->response_msg=$server_response; return false; } function talk($cmd,$args='') { if(!$this->socket) { $this->ERROR_MSG=$this->ERR_SMTP_NOT_CONNECTED; return false; } switch($cmd) { case "HELO": if(empty($args)) { $this->ERROR_MSG=$this->ERR_HELO_WITHOUT_ARG; return false; } $smtp_cmd="HELO $arg\r\n"; fwrite($this->socket,$smtp_cmd); if(!$this->getResponse()) { $this->ERROR_MSG=$this->ERR_UNKNOWN_RESPONSE_FROM_SERVER.":".$this->response_msg; return false; } if($this->response_code!=250) { $this->ERROR_MSG=$this->ERR_HELO_FAILED." ".$this->response_code." ".$this->response_msg; return false; } break; case "MAIL": if(empty($args)) { $this->ERROR_MSG=$this->ERR_MAIL_WITHOUT_ARG; return false; } $smtp_cmd="MAIL FROM: $arg\r\n"; fwrite($this->socket,$smtp_cmd); if(!$this->getResponse()) { $this->ERROR_MSG=$this->ERR_UNKNOWN_RESPONSE_FROM_SERVER.":".$this->response_msg; return false; } if($this->response_code!=250) { $this->ERROR_MSG=$this->ERR_MAIL_FAILED." ".$this->response_code." ".$this->response_msg; return false; } break; case "RCPT": if(empty($arg)) { $this->ERROR_MSG=$this->ERR_RCPT_WITHOUT_ARG; return false; } $to_emails=explode(",",$arg); foreach ($to_emails as $email) { $smtp_cmd="RCPT TO: $email\r\n"; fwrite($this->socket,$smtp_cmd); if(!$this->getResponse()) { $this->ERROR_MSG=$this->ERR_UNKNOWN_RESPONSE_FROM_SERVER.":".$this->response_msg; return false; } if($this->response_code!=250) { $this->ERROR_MSG=$this->ERR_RCPT_FAILED." ".$this->response_code." ".$this->response_msg; return false; } } break; case "DATA": if(empty($arg)) { $this->ERROR_MSG=$this->ERR_DATA_WITHOUT_ARG; return false; } $smtp_cmd="DATA\r\n"; fwrite($this->socket,$smtp_cmd); if(!$this->getResponse()) { $this->ERROR_MSG=$this->ERR_UNKNOWN_RESPONSE_FROM_SERVER.":".$this->response_msg; return false; } if($this->response_code!=354) { $this->ERROR_MSG=$this->ERR_DATA_FAILED." ".$this->response_code." ".$this->response_msg; return false; } $smtp_cmd="$arg\r\n"."."."\r\n"; fwrite($this->socket,$smtp_cmd); if(!$this->getResponse()) { $this->ERROR_MSG=$this->ERR_UNKNOWN_RESPONSE_FROM_SERVER.":".$this->response_msg; return false; } if($this->response_code!=250) { $this->ERROR_MSG=$this->ERR_DATA_FAILED." ".$this->response_code." ".$this->response_msg; return false; } break; case "QUIT": $smtp_cmd="QUIT\r\n"; fwrite($this->socket,$smtp_cmd); if(!$this->getResponse()) { $this->ERROR_MSG=$this->ERR_UNKNOWN_RESPONSE_FROM_SERVER.":".$this->response_msg; return false; } if($this->response_code!=251) { $this->ERROR_MSG=$this->ERR_QUIT_FAILED." ".$this->response_code." ".$this->response_msg; return false; } break; default: $this->ERROR_MSG=$this->ERR_COMMAND_UNRECOGNIZED; return false; break; } return true; } function send() { if(!$this->checkFields()) return false; $this->buildHeaders(); if(!$this->connect()) return false; if(!$this->talk("HELO",$GLOBALS["SERVER_NAME"])) return false; if(!$this->talk("MAIL",$this->from)) return false; if(!$this->talk("RCPT",$this->to)) return false; if(!empty($this->to)) $this->headers[]="To: $this->to"; if(!empty($this->subject)) $this->headers[]="Subject: $this->subject"; if(!$this->talk("DATA",implode("\r\n",$this->headers)."\r\n\r\n".$this->body)) return false; if(!$this->talk("QUIT")) return false; fclose($this->socket); return true; } } ?> [/code] Now,the below script is for testing.... [code]<?php //my_smtp_mail_class_test.php include("./my_smtp_mail_class.php"); $mail=new My_Smtp_Mail(); $mail->smtp_host=''; //i tried with localhost and also with the smtp server name my hostingsite provided to me.. but nothing worked $mail->to="myid@mydomain.com"; $mail->from="anotherid@gmail.com"; $mail->cc=''; $mail->bcc=''; $mail->subject="Testing..1..2..3..4"; $mail->body="Just testing..."; $mail->rigorous_email_check=1; if($mail->send()) { echo ("Successfully sent an email titled $mail->subject!"); } else die("Error while attempting to send an email titled $mail->subject:".$mail->errorMsg()); echo("<br>"); echo(str_replace("\r\n","<br>",$mail->viewMsg())); ?> [/code] The output i got is: [b]Error while attempting to send an email titled Testing..1..2..3..4:No error has occured yet[/b]
×
×
  • 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.