Jump to content

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

 

<?php
class patient_mail
{
 
function mail_send($c)
{
global $db;
$db->fun_db();
global $img_obj;
$img=array();
$time=time();
$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";
 
//var_dump($_FILES);
 
$headers = "From: $fromName";
 
/* GET File Variables */
 
if($_FILES['report']['name'][0]!=''){
 
foreach( $_FILES['report']['name']as $k=>$value)
 
{
 
$time++;
 
$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/";
 
 
 
$img[]=$userimg;
 
$newwidth = "";
 
$newheight = "154";
if($ext!='exe'){
move_uploaded_file($tempname,$folder.$userimg);
}
 
 
if (file($tmpName)) {
 
 /* Reading file ('rb' = read binary)  */
 
 $file = fopen($tmpName,'rb');
 
 $data = fread($file,filesize($tmpName));
 
 fclose($file);
 
 }
 
 
 
 $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" .
 
 "--{$mimeBoundary}--\n";
 
 
 
}
 
$userimg=implode(',',$img);
 
}
 
 
 
  $sql="insert into treatment_mail(comment_name,email,contactno,message,page_id,report1,mail_date)values('".$fromName."','".$fromEmail."','".$subject."','".$message1."','".$c."','".$userimg."','".time()."')"; 
 
mysql_query($sql);
 
 
 
$flgchk = mail ("$to", "$subject", "$message", "$headers");       /* this code is not working*/
 
 
 
if($flgchk){
 
echo $msg="A email has been sent to: $to";
 
}
 
else{
 
 echo $msg= "Error in Email sending"; 
 
}
 
return $msg;
 
}
 
 
}
 
$obj_mail=new patient_mail();
 
?>
Link to comment
https://forums.phpfreaks.com/topic/292136-i-need-help-with-php-oop-form-with-smtp/
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 ;)

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.

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