Page 1 of 1

my class for sending to email

Posted: Sun Aug 14, 2011 4:01 pm
by Odai_GH
Hello All :)
this my 2nd topic here
i've done a new class for sending msgs to email
anyways
this is the class :

Code: Select all

<?php

/**
 * @author ODAI
 * @copyright 2011
 * @contact dodi-505@hotmail.com
 */
class send_email{
/**	Sending info */
  private $from;
  private $to;
  private $subject;
 private $msg;
/**	4 params for sending info */
function __construct($to,$from,$sub,$msg)
{
    $this->from   =$from;
    $this->to     =$to;
    $this->subject=$sub;
    $this->msg    =$msg;
}
/**	function for Headers */
function Headers()
{
    $headers = "From:".$this->from . "\r\n";
    $headers .= "To:".$this->to . "\r\n";
    $headers .= "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
    $headers .=	'X-Mailer: PHP/' . phpversion();
    return $headers;
}
/**	function for sending the msg */
function send(){
    if(mail($this->to,$this->subject,$this->msg,$this->Headers()))
    {
    return "your msg has been sent to : <br />".$this->to ;
    }
}
}
?>
how to use :

Code: Select all

$n=new send_email("x@hotmail.com","x1@hotamil.com","Hello","title");
echo $n->send()
the first parm for the contact , 2nd for ur email , 3rd subject of ur msg , 4th for ur msg
this it
have a nice day :)

Re: my class for sending to email

Posted: Sun Aug 14, 2011 4:07 pm
by oscardog
You might want to post it here as that is the place for code critique, likely to get more responses over there (not to mention it belongs there).

Re: my class for sending to email

Posted: Sun Aug 14, 2011 4:09 pm
by Odai_GH
ah
other time :P
thanks for telling me

Re: my class for sending to email

Posted: Sun Aug 14, 2011 4:27 pm
by social_experiment
Good on starting with OOP stuff, if the class is to be taken more seriously you should look at using more the zend coding standards in terms of your comments for what each method does , etc.

Re: my class for sending to email

Posted: Sun Aug 14, 2011 6:27 pm
by Christopher
Moved to Code Critique.