Ir para conteúdo
Fórum Script Brasil
  • 0

Função Mail()


carol

Pergunta

Oi gente, como passaram de fim de semana?E passei muito bem :D

Bem,

Warning: mail() has been disabled for security reasons in /mnt/host-users/sensuais/cards/index.php on line 375

Já tive esse problema em um outo código e acho que meu servidor não suporta a função Mail()

Gostaria de uma ajuda para criar um outro arquivo PHP com a função SMTP ou trocar esse que já tem por SMTP sem ter que criar um novo arquivo ou se for criar um arquivo por exemplo smtp.php gostaria de uma ajuda para colocar nesse codigo abaixo a direção para esse arquivo SMTP.

Então segue abaixo o código que tenho e gostaria que me ajudassem para trocar o Mail por SMTP.:

<? 
// cmailout - base class for mail system 

class cmailout { 
var $parts = array(); 
var $to = ""; 
var $from = ""; 
var $headers = ""; 
var $subject = ""; 
var $body = ""; 
var $path = ""; 
var $allpath = array(); 
var $clientcode = ""; 
var $size=512000; 
// russian iso = iso-8859-1 
var $allext = array("txt" => "text/plain", 
"php" => "text/plain", 
"htm" => "text/html", 
"html" => "text/html", 
"gif" => "image/gif", 
"jpg" => "image/jpeg", 
"jpeg" => "image/jpeg", 
"xls" => "application/x-msexcel", 
"exe" => "application/x-msdownload", 
"" => "application/octet-stream", 
"doc" => "application/msword" 
); 
// void cmailout() 
// class constraction 

function cmailout($to="", $from="", $headers="", $subject="", $body="", $allpath=array(), $codeclient="") 
{ if(!empty($to)) 
$this->send($to, $from, $headers, $subject, $body, $allpath, $codeclient); 
else return 0; 
} 

// void send() 
// function quick send mail 

function send($to, $from="", $headers="", $subject="", $body="", $allpath=array(), $codeclient="") 
{ $this->to = $to; 
$this->from = $from; 
$this->headers = $headers; 
$this->subject = $subject; 
$this->body = $body; 
$this->allpath = $allpath; 
$this->codeclient = $codeclient; 
$this->step_send(); 
} 

// void check() 
// return 1 if address valid, return 0 if invalid 

function check() 
{ if(!empty($this->to)) 
return(ereg("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|ru|su|net|com|gov|mil|org|edu|int)\$",$this->to)); 
else return 0; 
} 

// void recodeCyr([string name], static input, static output) 
// return recode string, set value $in and $out example: 
// k - koi8-r 
// w - windows-1251 
// i - iso8859-5 
// a - x-cp866 
// d - x-cp866 
// m - x-mac-cyrillic 

function recodeCyr($string) 
{ if(!empty($this->clientcode)) 
{ return(convert_cyr_string($string, w, k)); 
} else 
{ return($string); 
} 
} 

// void attachment(string [input fullpath, file name and extension]) 
// get listing file 

function attachment($file) 
{ if((!empty($file)) || (filesize($file) <= $this->size)) 
{ return(fread(fopen($file, "rb"), filesize($file))); 
fclose($file); 
$this->size = $this->size - filesize($file); 
} else 
{ return 0; 
} 
} 

// void makeoctet(string [file extension]) 
// function make octet-stream from correct include file 

function makeoctet($ext) 
{ reset($this->allext); 
while(list($k, $v) = each($this->allext)) 
{ if($k==$ext) 
return $v; 
} 
} 


// void addattach() 
// Add an attachment to the mail object 

function AddAttach($message,$name="",$ctype="application/octet-stream") 
{ if(!empty($message)) 
$this->parts[] = array ( "ctype" => $ctype, 
"message" => $message, 
"encode" => $encode, 
"name" => $name 
); 
} 

// void build_message(array [parti]) 
// Build message parts of an multipart mail 

function build_message($part) 
{ $message = $part["message"]; 
if ($part["ctype"] != "text/html") 
{ $message = chunk_split(base64_encode($message)); 
$encoding = "base64"; 
return "Content-Type: ".$part["ctype"].($part["name"]?"; name=\"".$part["name"]."\"" : "")."\nContent-Transfer-Encoding: $encoding\nContent-ID: <".$part["name"].">\n\n$message\n"; 
} else 
{ return "Content-Type: text/html;\nContent-Transfer-Encoding: quoted-printable\n\n$message\n"; 
} 
} 

// void build_multipart() 
// Build a multipart mail 

function build_multipart() 
{ $boundary = "b".md5(uniqid(time())); 
$multipart = "Content-Type: multipart/related; boundary=\"$boundary\"; type=\"multipart/alternative\"\n\nThis is a multi-part message in MIME format.\n\n--$boundary"; 
/* 
$multipart.= "\nContent-Type: text/html;\n name=\"".$this->parts[$i][name]."\"\ncharset=".$this->codeclient."\nContent-Transfer-Encoding: quoted-printable\n\n".$this->parts[$i][message]."\n--$boundary"; 
*/ 
$multipart.= "\nContent-Type: text/plain;\ncharset="; 
if(!empty($this->clientcode)) 
{ $multipart.= "\"koi8-r\"\n"; 
} else 
{ $multipart.= "\"".$this->clientcode."\"\n"; 
} 
$multipart.= "Content-Transfer-Encoding: quoted-printable\n\n"; 
if(!empty($this->body)) 
$multipart.= $this->recodecyr($this->body); 
$multipart.= "\n\n--$boundary"; 
for($i = sizeof($this->parts)-1; $i >= 0; $i--) 
{ $multipart.= "\n".$this->build_message($this->parts[$i])."--$boundary"; 
} 
return $multipart.= "--\n"; 
} 

// void step_send() 
// Send the mail 

function st1ep_send() 
{ $mime = ""; 
if (!empty($this->from)) 
$mime.= "From: ".$this->from."\n"; 
if (!empty($this->headers)) 
$mime.= $this->headers."\n"; 
if(!empty($this->path)) 
$this->allpath = explode(",", $this->path); 
if(!empty($this->allpath)) 
{ for($i=0; $i<count($this->allpath); $i++) 
{ $this->addattach($this->attachment($this->allpath[$i]), basename($this->allpath[$i]),$this->makeoctet(substr($this->allpath[$i],-3))); 
} 
} 
$mime.= "MIME-Version: 1.0\n".$this->build_multipart(); 
if($this->check()) 
mail($this->to, $this->recodecyr($this->subject), "", $mime); 
} 

}; // end of class 
?>

Desde já obrigada!

beijokas..

Link para o comentário
Compartilhar em outros sites

3 respostass a esta questão

Posts Recomendados

  • 0

Provavelmente, pela msg de erro, o teu server desabilitou a funcao. Agora, que funcao SMTP?

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...