my class for sending to email

Coding Critique is the place to post source code for peer review by other members of DevNetwork. Any kind of code can be posted. Code posted does not have to be limited to PHP. All members are invited to contribute constructive criticism with the goal of improving the code. Posted code should include some background information about it and what areas you specifically would like help with.

Popular code excerpts may be moved to "Code Snippets" by the moderators.

Moderator: General Moderators

Post Reply
Odai_GH
Forum Newbie
Posts: 8
Joined: Sun Aug 14, 2011 1:28 pm

my class for sending to email

Post 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 :)
oscardog
Forum Contributor
Posts: 245
Joined: Thu Oct 23, 2008 4:43 pm

Re: my class for sending to email

Post 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).
Odai_GH
Forum Newbie
Posts: 8
Joined: Sun Aug 14, 2011 1:28 pm

Re: my class for sending to email

Post by Odai_GH »

ah
other time :P
thanks for telling me
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: my class for sending to email

Post 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.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: my class for sending to email

Post by Christopher »

Moved to Code Critique.
(#10850)
Post Reply