Jump to content

I need Help With PHP OOP Form with SMTP


Recommended Posts

Hi Guys,

I just write the code in php but mail function is not working rest everything is working fine.. i tried other script but that also not working.. Than i came to know that my hosting server only use SMTP.. So i need help to do that..


Code Below


class patient_mail
function mail_send($c)
global $db;
global $img_obj;
$to = 'team@concepteurs.co.in';
$fromEmail = $_REQUEST['email'];
$fromName = $_REQUEST['comment_name'];
$subject = $_REQUEST['contactno'];
$message = $_REQUEST['comment'];
$message1 = $_REQUEST['comment'];
//$message.="You have receive An request from $c Page From the user/Patient $fromName";
$headers = "From: $fromName";
/* GET File Variables */
foreach( $_FILES['report']['name']as $k=>$value)
$tmpName = $_FILES['report']['tmp_name'][$k];
$fileType = $_FILES['report']['type'][$k];
/* Start of headers */
$filename = stripslashes($_FILES['report']['name'][$k]);
$ext = explode(".",$value);
$extension = strtolower(end($ext));
$tempname = $_FILES['report']['tmp_name'][$k];
$userimg = "mail_".$time.".".$extension;
$folder = "../images/mail/";
$newwidth = "";
$newheight = "154";
if (file($tmpName)) {
 /* Reading file ('rb' = read binary)  */
 $file = fopen($tmpName,'rb');
 $data = fread($file,filesize($tmpName));
 $randomVal = md5(time());
 $mimeBoundary = "==Multipart_Boundary_x{$randomVal}x";
 /* Header for File Attachment */
 $headers .= "\nMIME-Version: 1.0\n";
 $headers .= "Content-Type: multipart/mixed;\n" ;
 $headers .= " boundary=\"{$mimeBoundary}\"";
 /* Multipart Boundary above message */
 $message = "This is a multi-part message in MIME format.\n\n" .
 "--{$mimeBoundary}\n" .
 "Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
 "Content-Transfer-Encoding: 7bit\n\n" .
 $message . "\n\n";
 /* Encoding file data */
 $data = chunk_split(base64_encode($data));
/* Adding attchment-file to message*/
 $message .= "--{$mimeBoundary}\n" .
 "Content-Type: {$fileType};\n" .
 " name=\"{$value}\"\n" .
 "Content-Transfer-Encoding: base64\n\n" .
 $data . "\n\n" .
  $sql="insert into treatment_mail(comment_name,email,contactno,message,page_id,report1,mail_date)values('".$fromName."','".$fromEmail."','".$subject."','".$message1."','".$c."','".$userimg."','".time()."')"; 
$flgchk = mail ("$to", "$subject", "$message", "$headers");       /* this code is not working*/
echo $msg="A email has been sent to: $to";
 echo $msg= "Error in Email sending"; 
return $msg;
$obj_mail=new patient_mail();
Link to comment
Share on other sites

Hi! There's a 'code' button in the toolbar where you wrote your post. You can edit your post and paste your code in the little box that will appear. Your code will be much more easier to read. Now, it's kinda hard to see, and I'm not talking about that green font there ;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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.