php smtp mail function - php

can i have this function send email through smtp?
function send()
{
if(mail($this->to, $this->subject, $this->body, $this->headers)) return TRUE;
else return FALSE;
}
this is part of following code:
class sendMail
{
var $to;
var $cc;
var $bcc;
var $subject;
var $from;
var $headers;
var $html;
function sendMail()
{
$this->to = "test#mail.com";
#$this->to = "test#test.com";
$this->cc = NULL;
$this->bcc = NULL;
$this->subject = NULL;
$this->from = NULL;
$this->headers = NULL;
$this->html = FALSE;
}
function getParams($params)
{
$i = 0;
foreach ($params as $key => $value) {
switch($key) {
case 'Submit':
NULL;
break;
default:
if ($key == 'email')
{
$this->from = $value;
$this->subject ="Contactgegevens from " . $value . " at www.webandeve.nl ";
}
$this->body[$i]["key"] = str_replace("_", " ", ucWords(strToLower($key)));
$this->body[$i++]["value"] = $value;
}
}
}
function setHeaders()
{
$this->headers = "From: $this->from\r\n";
if($this->html === TRUE) {
$this->headers.= "MIME-Version: 1.0\r\n";
$this->headers.= "Content-type: text/html; charset=iso-8859-1\r\n";
}
}
function parseBody()
{
$count = count($this->body);
for($i = 0; $i < $count; $i++) {
if($this->html) $content.= "<b>";
$content .= $this->body[$i]["key"].': ';
if($this->html) $content.= "</b>";
if($this->html) $content .= nl2br($this->body[$i]["value"])."\n";
else $content .= $this->body[$i]["value"];
if($this->html) $content.= "<br>\n";
else $content.= "\n".str_repeat("-", 80)."\n";
}
if($this->html) {
$content = "
<style>
BODY {
font-family: verdana;
font-size: 10;
}
</style>
".$content;
}
$this->body = $content;
}
function send()
{
if(mail($this->to, $this->subject, $this->body, $this->headers)) return TRUE;
else return FALSE;
}
function set($key, $value)
{
if($value) $this->$key = $value;
else unset($this->$key);
}
function get_location()
{
return header('Location: thankyou.htm');break;
}
}
I've been looking for a simple solution but cannot find any (for my knowledge of php) but Git and some full replacements of my script.

If you want to use your SMTP mail config with the mail() function you need to set the SMTP config in your php.ini.
See E-Mail configuration for details.
However I would recommend the use of a third party lib like PHPMailer

Related

UPLOAD has a deprecated constructor [duplicate]

This question already has answers here:
Severity: 8192 Message: Methods with the same name as their class will not be constructors in a future version of PHP;
(6 answers)
Closed 9 days ago.
I have a script that sends a SMS alert but it is failing on "class UPLOAD". The PHP error log shows "Methods with the same name as their class will not be constructors in a future version of PHP; UPLOAD has a deprecated constructor". Can anyone see what is going wrong.
class UPLOAD
{
var $URI='';
var $Host='localhost';
var $Port='80';
var $Fields=array();
var $Files=array();
var $Headers=array();
var $Request='';
var $RequestHeaders='';
var $RequestBody='';
var $Response='';
var $ResponseHeaders='';
var $ResponseBody='';
var $log='';
var $errors=array();
var $UseProxy=false;
var $ProxyHost='localhost';
var $ProxyPort=3128;
// constructor
function UPLOAD($URI)
{
$this->log .= 'Creating object with URI: '.htmlspecialchars($URI)."\n";
if (preg_match("/^https:\/\/([^\/:]+)[:]?(\d*)?(.*)/i", $URI, $m))
{
$this->URI = $URI;
$this->Host = $m[1];
$this->Port = ((int)$m[2])==0 ? 80 : (int)$m[2];
$this->log .= 'Object with URI '.htmlspecialchars($URI)." created.\n";
$this->log .= ' host: '.htmlspecialchars($this->Host)."\n";
$this->log .= ' port: '.htmlspecialchars($this->Port)."\n";
}
else
{
$this->log .= 'Object with URI '.htmlspecialchars($URI)." create failed.\n";
$this->errors[] = 'Access URI '.htmlspecialchars('"'.$URI.'"').' is not valid';
}
}
// adding field(s) to form
function SetFields($field, $value='')
{
if (is_array($field))
{
foreach($field as $k=>$v)
{
$this->SetFields($k, $v);
}
}
else
{
$this->Fields[] = array($field, $value);
$this->log .= 'Added field '.htmlspecialchars('"'.$field.'"').' with value '.htmlspecialchars('"'.$value.'"')."\n";
}
}
// adding files to form
function SetFiles($field, $filename='', $content='')
{
if (is_array($field))
{
foreach($field as $k=>$v)
{
$this->SetFiles($k, $v);
}
}
else
{
if (is_array($filename))
{
foreach($filename as $k=>$v)
{
$this->SetFiles($field, $k, $v);
}
}
else
{
$this->Files[] = array($field, $filename, $content);
$this->log .= 'Added field '.htmlspecialchars('"'.$field.'"').' of type file with name '.htmlspecialchars('"'.$filename.'"')."\n";
}
}
}
// send form
function Send()
{
if (!$hosts=gethostbynamel($this->Host))
{
$this->errors[] = 'Send failed. Host '.htmlspecialchars('"'.$this->Host.'"').' not found.';
return false;
}
$fp = #fsockopen($this->Host, $this->Port, $errno, $errstr, 3);
if (!$fp)
{
$this->errors[] = "Connection failed with: ".$errno.' '.htmlspecialchars($errstr);
return false;
}
$this->calculate();
$out = $this->Request;
fwrite($fp, $out, strlen($out));
$result = '';
while (!feof($fp)) {
$result .= fgets($fp, 1024);
}
$this->Response = $result;
$i = strpos($result, "\r\n\r\n");
if ($i>0)
{
$this->ResponseHeader = substr($result, 0, $i);
$this->ResponseBody = substr($result, $i+4);
}
else
{
$this->ResponseHeader = $result;
$this->ResponseBody = '';
}
return true;
}
// calculate form
function calculate()
{
$boundary = '---------------------------PHPUPLOADCLASS';
$body = '';
foreach($this->Fields as $k=>$v)
{
$body .= "--$boundary\r\n";
$body .= 'Content-Disposition: form-data; name="'.$v[0]."\"\r\n";
$body .= "\r\n".$v[1]."\r\n";
}
foreach($this->Files as $k=>$v)
{
$body .= "--$boundary\r\n";
$body .= 'Content-Disposition: form-data; name="'.$v[0].'"; filename="'.$v[1]."\"\r\n";
$body .= "Content-Type: application/octet-stream\r\n";
$body .= "\r\n".$v[2]."\r\n";
}
$body .= "--$boundary--\r\n";
$headers = 'POST '.$this->URI." HTTPS/1.0\r\n";
$headers .= 'Host: '.$this->Host."\r\n";
$headers .= "User-Agent: Mozilla/4.0 (PHP Uploader Class)\r\n";
$headers .= "Accept: */*\r\n";
$headers .= "Pragma: no-cache\r\n";
foreach($this->Headers as $k=>$v)
{
$headers .= $k.': '.$v."\r\n";
}
$headers .= "Content-Type: multipart/form-data; boundary=$boundary\r\n";
$headers .= "Content-Length: ".strlen($body)."\r\n";
$headers .= "Connection: Close\r\n\r\n";
$this->Request = $headers.$body;
$this->RequestHeaders = $headers;
$this->RequestBody = $body;
}
}
[/CODE]
In PHP 7 the old style of constructor having the same name of the class name is deprecated.
So you need to use other name of method which is not same as class
name.
Or you can use A magic method in PHP that usually starts with 2 underscores instead of function UPLOAD.
Like:
public function __construct()
{
//put all your logic to instantiate an object with class properties
}
instead of :
public function UPLOAD()
{
//put all your logic to instantiate an object with class properties
}

multple file attachment in mail with php [duplicate]

This question already has answers here:
Error with PHP mail(): Multiple or malformed newlines found in additional_header
(10 answers)
Closed 4 years ago.
I have below code for mail attachment, but it is not working, dont know why it is happening..
function mail_attachment($filename, $path, $mailto, $from_mail, $subject, $message){
$uid = md5(uniqid(time()));
$mime_boundary = "==Multipart_Boundary_x{$uid}x";
$header = "From: <".$from_mail.">\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"".$mime_boundary."\"\r\n\r\n";
$header .= "This is a multi-part message in MIME format.\r\n";
$header .= "--".$mime_boundary."\r\n";
$header .= "Content-type:text/html; charset=iso-8859-1\r\n";
$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$header .= nl2br($message)."\r\n\r\n";
$header .= "--".$mime_boundary."\r\n";
foreach($filename as $k=>$v){
$file = $path.$v;
$file_size = filesize($file);
$handle = fopen($file, "r");
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
$header .= "Content-Type: application/octet-stream; name=\"".$v."\"\r\n"; // use different content types here
$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: attachment; filename=\"".$v."\"\r\n\r\n";
$header .= $content."\r\n\r\n";
$header .= "--".$mime_boundary."--"."\r\n";
}
if (mail($mailto, $subject, "", $header)) {
//echo "mail send ... OK"; // or use booleans here
return true;
} else {
//echo "mail send ... ERROR!";
return false;
}
}
$path='upload/';
$send_email = mail_attachment($files, $path, $to, "roxmorphy26#gmail", $subject, $message);
//mail($to,$subject,$message,$headers);
if($send_email){ echo 'done';} else {echo 'not';}
but it gives error like -- Warning: mail(): Multiple or malformed newlines found in additional_header
please help.
<?php
define("LIBR", "\n"); // use a "\r\n" if you have problems
define("PRIORITY", 3); // 3 = normal, 2 = high, 4 = low
define("TRANS_ENC", "7bit");
define("ENCODING", "iso-8859-1");
class attach_mailer {
var $from_name;
var $from_mail;
var $mail_to;
var $mail_cc;
var $mail_bcc;
var $webmaster_email = "webmaster#yourdomain.com";
var $mail_headers;
var $mail_subject;
var $text_body = "";
var $html_body = "";
var $valid_mail_adresses; // boolean is true if all mail(to) adresses are valid
var $uid; // the unique value for the mail boundry
var $alternative_uid; // the unique value for the mail boundry
var $related_uid; // the unique value for the mail boundry
var $html_images = array();
var $att_files = array();
var $msg = array();
// functions inside this constructor
// - validation of e-mail adresses
// - setting mail variables
// - setting boolean $valid_mail_adresses
function attach_mailer($name = "", $from, $to, $cc = "", $bcc = "", $subject = "") {
$this->valid_mail_adresses = true;
if (!$this->check_mail_address($to)) {
$this->msg[] = "Error, the \"mailto\" address is empty or not valid.";
$this->valid_mail_adresses = false;
}
if (!$this->check_mail_address($from)) {
$this->msg[] = "Error, the \"from\" address is empty or not valid.";
$this->valid_mail_adresses = false;
}
if ($cc != "") {
if (!$this->check_mail_address($cc)) {
$this->msg[] = "Error, the \"Cc\" address is not valid.";
$this->valid_mail_adresses = false;
}
}
if ($bcc != "") {
if (!$this->check_mail_address($bcc)) {
$this->msg[] = "Error, the \"Bcc\" address is not valid.";
$this->valid_mail_adresses = false;
}
}
if ($this->valid_mail_adresses) {
$this->from_name = $this->strip_line_breaks($name);
$this->from_mail = $this->strip_line_breaks($from);
$this->mail_to = $this->strip_line_breaks($to);
$this->mail_cc = $this->strip_line_breaks($cc);
$this->mail_bcc = $this->strip_line_breaks($bcc);
$this->mail_subject = $this->strip_line_breaks($subject);
} else {
return;
}
}
function get_msg_str() {
$messages = "";
foreach($this->msg as $val) {
$messages .= $val."<br />\n";
}
return $messages;
}
// use this to prent formmail spamming
function strip_line_breaks($val) {
$val = preg_replace("/([\r\n])/", "", $val);
return $val;
}
function check_mail_address($mail_address) {
$pattern = "/^[\w-]+(\.[\w-]+)*#([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4})$/i";
if (preg_match($pattern, $mail_address)) {
if (function_exists("checkdnsrr")) {
$parts = explode("#", $mail_address);
if (checkdnsrr($parts[1], "MX")){
return true;
} else {
return false;
}
} else {
// on windows hosts is only a limited e-mail address validation possible
return true;
}
} else {
return false;
}
}
function get_file_data($filepath) {
if (file_exists($filepath)) {
if (!$str = file_get_contents($filepath)) {
$this->msg[] = "Error while opening attachment \"".basename($filepath)."\"";
} else {
return $str;
}
} else {
$this->msg[] = "Error, the file \"".basename($filepath)."\" does not exist.";
return;
}
}
// use for $dispo "attachment" or "inline" (f.e. example images inside a html mail
function add_attach_file($file, $encoding = "base64", $dispo = "attachment", $type = "application/octet-stream") {
$file_str = $this->get_file_data($file);
if ($file_str == "") {
return;
} else {
if ($encoding == "base64") $file_str = base64_encode($file_str);
$this->att_files[] = array(
"data"=>chunk_split($file_str),
"name"=>basename($file),
"cont_type"=>$type,
"trans_enc"=>$encoding,
"disposition"=>$dispo);
}
}
function add_html_image($img_name) {
$file_str = $this->get_file_data($img_name);
$img_dim = getimagesize($img_name);
if ($file_str == "") {
return;
} else {
$this->html_images[] = array(
"data"=>chunk_split(base64_encode($file_str)),
"name"=>basename($img_name),
"cont_type"=>$img_dim['mime'],
"cid"=>md5(uniqid(time()))."#".$_SERVER['SERVER_NAME']);
}
}
function create_stand_headers() {
if ($this->from_name != "") {
$headers = "From: ".$this->from_name." <".$this->from_mail.">".LIBR;
$headers .= "Reply-To: ".$this->from_name." <".$this->from_mail.">".LIBR;
} else {
$headers = "From: ".$this->from_mail.LIBR;
$headers .= "Reply-To: ".$this->from_mail.LIBR;
}
if ($this->mail_cc != "") $headers .= "Cc: ".$this->mail_cc.LIBR;
if ($this->mail_bcc != "") $headers .= "Bcc: ".$this->mail_bcc.LIBR;
$headers .= sprintf("Message-ID: <%s#%s>%s", md5(uniqid(time())), $_SERVER['SERVER_NAME'], LIBR);
$headers .= "X-Priority: ".PRIORITY.LIBR;
$headers .= "X-Mailer: Attachment Mailer [version 1.2]".LIBR;
$headers .= "MIME-Version: 1.0".LIBR;
return $headers;
}
function create_html_image($img_array) {
$img = "Content-Type: ".$img_array['cont_type'].";".LIBR.chr(9)." name=\"".$img_array['name']."\"".LIBR;
$img .= "Content-Transfer-Encoding: base64".LIBR;
$img .= "Content-ID: <image".$img_array['cid'].">".LIBR;
$img .= "Content-Disposition: inline;".LIBR.chr(9)." filename=\"".$img_array['name']."\"".LIBR.LIBR;
$img .= $img_array['data'];
return $img;
}
function create_attachment($data_array) {
$att = "Content-Type: ".$data_array['cont_type'].";".LIBR.chr(9)." name=\"".$data_array['name']."\"".LIBR;
$att .= "Content-Transfer-Encoding: ".$data_array['trans_enc'].LIBR;
$att .= "Content-Disposition: ".$data_array['disposition'].";".LIBR.chr(9)." filename=\"".$data_array['name']."\"".LIBR.LIBR;
$att .= $data_array['data'];
return $att;
}
function create_html_body() {
$html = "Content-Type: text/html; charset=".ENCODING.LIBR;
$html .= "Content-Transfer-Encoding: ".TRANS_ENC.LIBR.LIBR;
foreach ($this->html_images as $img) {
$this->html_body = str_replace($img['name'], "cid:image".$img['cid'], $this->html_body);
}
$html .= $this->html_body;
return $html.LIBR.LIBR;
}
function build_message() {
$this->headers = $this->create_stand_headers();
$msg = "";
$is_html = ($this->html_body != "") ? true : false;
$is_attachment = (count($this->att_files) > 0) ? true : false;
$is_images = (count($this->html_images) > 0) ? true : false;
if ($is_attachment) {
$this->uid = md5(uniqid(time()));
$this->headers .= "Content-Type: multipart/mixed;".LIBR.chr(9)." boundary=\"".$this->uid."\"".LIBR.LIBR;
$this->headers .= "This is a multi-part message in MIME format.".LIBR;
if (!$is_html) {
$msg .= "--".$this->uid.LIBR;
} else {
$this->headers .= "--".$this->uid.LIBR;
}
}
if ($is_html) {
$this->alternative_uid = md5(uniqid(time()));
$this->headers .= "Content-Type: multipart/alternative;".LIBR.chr(9)." boundary=\"".$this->alternative_uid."\"".LIBR.LIBR;
if (!$is_attachment) {
$this->headers .= "This is a multi-part message in MIME format.".LIBR;
}
$msg .= LIBR."--".$this->alternative_uid.LIBR;
}
$body_head = "Content-Type: text/plain; charset=".ENCODING."; format=flowed".LIBR;
$body_head .= "Content-Transfer-Encoding: ".TRANS_ENC.LIBR.LIBR;
if (!$is_attachment && !$is_html) {
$this->headers .= $body_head;
} else {
$msg .= $body_head;
}
$msg .= trim($this->text_body).LIBR.LIBR;
if ($is_html) {
$msg .= "--".$this->alternative_uid.LIBR;
if ($is_images) {
$this->related_uid = md5(uniqid(time()));
$msg .= "Content-Type: multipart/related;".LIBR.chr(9)." boundary=\"".$this->related_uid."\"".LIBR.LIBR.LIBR;
$msg .= "--".$this->related_uid.LIBR;
$msg .= $this->create_html_body();
foreach ($this->html_images as $img) {
$msg .= "--".$this->related_uid.LIBR;
$msg .= $this->create_html_image($img);
}
$msg .= LIBR."--".$this->related_uid."--";
} else {
$msg .= $this->create_html_body();
}
$msg .= LIBR.LIBR."--".$this->alternative_uid."--".LIBR.LIBR;
}
if ($is_attachment) {
foreach ($this->att_files as $att) {
$msg .= "--".$this->uid.LIBR;
$msg .= $this->create_attachment($att);
}
$msg .= "--".$this->uid."--";
}
return $msg;
}
function process_mail() {
if (!$this->valid_mail_adresses) return;
if (mail($this->mail_to, $this->mail_subject, $this->build_message(), $this->headers, "-f".$this->webmaster_email)) {
$this->msg[] = "Your mail is succesfully submitted.";
return true;
} else {
$this->msg[] = "Error while sending you mail.";
return false;
}
}
}
$test = new attach_mailer($name = "Olaf", $from = "youremail#gmail.com", $to = "toemail#gmail.com", $cc = "", $bcc = "", $subject = "Test text email with attachments");
$test->text_body = "...Some body text\n\n the admin";
$test->add_attach_file("uploads/admin_doc.docx");
//$test->add_attach_file("ip2nation.zip");
$test->process_mail();
echo $test->get_msg_str();

Locate HTML and plain text using imap_fetchstructure

I want to locate the html and/or the plain text using the imap_fetchstructure.
I tried several solutions but the emails don't have always the same structure.
I'm actually using:
$message=imap_fetchbody($inbox, $number, "1.2.1");
if ($message== "") {
$message =imap_fetchbody($inbox, $number, "1.1");
}
if ($message== "") {
$message = imap_fetchbody($inbox, $number, "1");
}
$message = imap_qprint($body);
When trying this; the result is sometimes correct and sometimes returning The content of the attachements depending on the mail server.
So I want a solution based on Imap_fetchstructure.
I found an answer for my question:
function getBody($uid, $imap) {
$body = $this->get_part($imap, $uid, "TEXT/HTML");
// if HTML body is empty, try getting text body
if ($body == "") {
$body = $this->get_part($imap, $uid, "TEXT/PLAIN");
}
return $body;
}
function get_part($imap, $uid, $mimetype, $structure = false, $partNumber = false) {
if (!$structure) {
$structure = imap_fetchstructure($imap, $uid, FT_UID);
}
if ($structure) {
if ($mimetype == $this->get_mime_type($structure)) {
if (!$partNumber) {
$partNumber = 1;
}
$text = imap_fetchbody($imap, $uid, $partNumber, FT_UID);
switch ($structure->encoding) {
case 3: return imap_base64($text);
case 4: return imap_qprint($text);
default: return $text;
}
}
// multipart
if ($structure->type == 1) {
foreach ($structure->parts as $index => $subStruct) {
$prefix = "";
if ($partNumber) {
$prefix = $partNumber . ".";
}
$data = $this->get_part($imap, $uid, $mimetype, $subStruct,
$prefix. ($index + 1));
if ($data) {
return $data;
}
}
}
}
return false;
}
function get_mime_type($structure) {
$primaryMimetype = array("TEXT", "MULTIPART", "MESSAGE", "APPLICATION",
"AUDIO", "IMAGE", "VIDEO", "OTHER");
if ($structure->subtype) {
return $primaryMimetype[(int)$structure->type] . "/" . $structure->subtype;
}
return "TEXT/PLAIN";
}
You can use like this to separate from html and plaintext:
$inbox = imap_open($hostName,$userName,$pwd) or die('Cannot connect (Allow gmail IMAP): ' . imap_last_error());
$emails = imap_search($inbox,'UNSEEN');
if($emails){
rsort($emails);
foreach($emails as $email_number){
$structure = imap_fetchstructure($inbox, $email_number);
if(isset($structure->parts) && is_array($structure->parts) && isset($structure->parts[1])) {// IF HTML
$part = $structure->parts[1];
$receivedEmailContent = imap_fetchbody($inbox,$email_number,2);
if($part->encoding == 3) {
$receivedEmailContent = imap_base64($receivedEmailContent);
} else if($part->encoding == 1) {
$receivedEmailContent = imap_8bit($receivedEmailContent);
} else {
$receivedEmailContent = imap_qprint($receivedEmailContent);
}
}else{//IF NOT HTML
$receivedEmailContent = imap_fetchbody($inbox,$email_number,1);
if($structure->type == 0){
$receivedEmailContent = imap_base64($receivedEmailContent);
}else{
$receivedEmailContent = imap_qprint($receivedEmailContent);
}
}
$receivedEmailContent = strip_tags($receivedEmailContent);
$header = imap_headerinfo ( $inbox, $email_number);
$receivedEmailTitle = $header->subject;
$receivedEmailSenderName = $header->from[0]->personal;
$receivedEmailSenderEmail = $header->from[0]->mailbox . "#" . $header->from[0]->host;
}
}
imap_close($inbox);

php imap - get body and make plain text

I am using the PHP imap function to get emails from a POP3 mailbox and insert the data into a MySQL database.
Here is the PHP code:
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect: ' . imap_last_error());
$emails = imap_search($inbox,'ALL');
if($emails)
{
$output = '';
rsort($emails);
foreach($emails as $email_number)
{
$header=imap_headerinfo($inbox,$email_number);
$from = $header->from[0]->mailbox . "#" . $header->from[0]->host;
$toaddress=$header->toaddress;
$replyto=$header->reply_to[0]->mailbox."#".$header->reply_to[0]->host;
$datetime=date("Y-m-d H:i:s",$header->udate);
$subject=$header->subject;
//remove the " from the $toaddress
$toaddress = str_replace('"','',$toaddress);
echo '<strong>To:</strong> '.$toaddress.'<br>';
echo '<strong>From:</strong> '.$from.'<br>';
echo '<strong>Subject:</strong> '.$subject.'<br>';
//get message body
$message = (imap_fetchbody($inbox,$email_number,1.1));
if($message == '')
{
$message = (imap_fetchbody($inbox,$email_number,1));
}
}
It works fine, however on some emails in the body I get = in between words, or =20 in between words. And other times the emails will just be blank even though they are not blank when sent.
This only happens when coming from certain emails.
How can I get round this and just make the email completely plain text?
This happens because the emails are normally Quoted-printable encoded. The = is a soft line break and =20 is a white space. I think, you could use quoted_printable_decode() on the message so it shows correctly. About the blank emails, I don't know, I would need more details.
Basically:
//get message body
$message = quoted_printable_decode(imap_fetchbody($inbox,$email_number,1.1));
$data = imap_fetchbody($this->imapStream, $Part->uid, $Part->path, FT_UID | FT_PEEK);
if ($Part->format === 'quoted-printable' && $data) {
$data = quoted_printable_decode($data);
}
This is required for mails with
Content-Transfer-Encoding: quoted-printable
But for mails with
Content-Transfer-Encoding: 8bit
simply imap_fetchbody is enough.
Above code was taken from a cake-php component created for fetching mails from mail boxes throgh IMAP.
I made an entire class some years ago, and I'm still using it when I need to get contents from emails. It will help you fetch all email bodies (sometimes you have html and plain text) in a readable format, and get all attached files, just ready to be saved somewhere or sent to a website user.
It is not really optimized so on a big mailbox you may have troubles; but the purpose of this class was to access emails in a readable format to put them on a widget of a website. I let you play with the sample below to get how it works.
ImapReader.class.php Here is the source code.
<?php
class ImapReader
{
private $host;
private $port;
private $user;
private $pass;
private $box;
private $box_list;
private $errors;
private $connected;
private $list;
private $deleted;
const FROM = 0;
const TO = 1;
const REPLY_TO = 2;
const SUBJECT = 3;
const CONTENT = 4;
const ATTACHMENT = 5;
public function __construct($host = null, $port = '143', $user = null, $pass = null)
{
$this->host = $host;
$this->port = $port;
$this->user = $user;
$this->pass = $pass;
$this->box = null;
$this->box_list = null;
$this->errors = array ();
$this->connected = false;
$this->list = null;
$this->deleted = false;
}
public function __destruct()
{
if ($this->isConnected())
{
$this->disconnect();
}
}
public function changeServer($host = null, $port = '143', $user = null, $pass = null)
{
if ($this->isConnected())
{
$this->disconnect();
}
$this->host = $host;
$this->port = $port;
$this->user = $user;
$this->pass = $pass;
$this->box_list = null;
$this->errors = array ();
$this->list = null;
return $this;
}
public function canConnect()
{
return (($this->connected == false) && (is_string($this->host)) && (!empty($this->host))
&& (is_numeric($this->port)) && ($this->port >= 1) && ($this->port <= 65535)
&& (is_string($this->user)) && (!empty($this->user)) && (is_string($this->pass)) && (!empty($this->pass)));
}
public function connect()
{
if ($this->canConnect())
{
$this->box = #imap_open("{{$this->host}:{$this->port}/imap/ssl/novalidate-cert}INBOX", $this->user,
$this->pass);
if ($this->box !== false)
{
$this->_connected();
}
else
{
$this->errors = array_merge($this->errors, imap_errors());
}
}
return $this;
}
public function boxList()
{
if (is_null($this->box_list))
{
$list = imap_getsubscribed($this->box, "{{$this->host}:{$this->port}}", "*");
$this->box_list = array ();
foreach ($list as $box)
{
$this->box_list[] = $box->name;
}
}
return $this->box_list;
}
public function fetchAllHeaders($mbox)
{
if ($this->isConnected())
{
$test = imap_reopen($this->box, "{$mbox}");
if (!$test)
{
return false;
}
$num_msgs = imap_num_msg($this->box);
$this->list = array ();
for ($id = 1; ($id <= $num_msgs); $id++)
{
$this->list[] = $this->_fetchHeader($mbox, $id);
}
return true;
}
return false;
}
public function fetchSearchHeaders($mbox, $criteria)
{
if ($this->isConnected())
{
$test = imap_reopen($this->box, "{$mbox}");
if (!$test)
{
return false;
}
$msgs = imap_search($this->box, $criteria);
if ($msgs)
{
foreach ($msgs as $id)
{
$this->list[] = $this->_fetchHeader($mbox, $id);
}
}
return true;
}
return false;
}
public function isConnected()
{
return $this->connected;
}
public function disconnect()
{
if ($this->connected)
{
if ($this->deleted)
{
imap_expunge($this->box);
$this->deleted = false;
}
imap_close($this->box);
$this->connected = false;
$this->box = null;
}
return $this;
}
/**
* Took from khigashi dot oang at gmail dot com at php.net
* with replacement of ereg family functions by preg's ones.
*
* #param string $str
* #return string
*/
private function _fix($str)
{
if (preg_match("/=\?.{0,}\?[Bb]\?/", $str))
{
$str = preg_split("/=\?.{0,}\?[Bb]\?/", $str);
while (list($key, $value) = each($str))
{
if (preg_match("/\?=/", $value))
{
$arrTemp = preg_split("/\?=/", $value);
$arrTemp[0] = base64_decode($arrTemp[0]);
$str[$key] = join("", $arrTemp);
}
}
$str = join("", $str);
}
if (preg_match("/=\?.{0,}\?Q\?/", $str))
{
$str = quoted_printable_decode($str);
$str = preg_replace("/=\?.{0,}\?[Qq]\?/", "", $str);
$str = preg_replace("/\?=/", "", $str);
}
return trim($str);
}
private function _connected()
{
$this->connected = true;
return $this;
}
public function getErrors()
{
$errors = $this->errors;
$this->errors = array ();
return $errors;
}
public function count()
{
if (is_null($this->list))
{
return 0;
}
return count($this->list);
}
public function get($nbr = null)
{
if (is_null($nbr))
{
return $this->list;
}
if ((is_array($this->list)) && (isset($this->list[$nbr])))
{
return $this->list[$nbr];
}
return null;
}
public function fetch($nbr = null)
{
return $this->_callById('_fetch', $nbr);
}
private function _fetchHeader($mbox, $id)
{
$header = imap_header($this->box, $id);
if (!is_object($header))
{
return;
}
$mail = new stdClass();
$mail->id = $id;
$mail->mbox = $mbox;
$mail->timestamp = (isset($header->udate)) ? ($header->udate) : ('');
$mail->date = date("d/m/Y H:i:s", (isset($header->udate)) ? ($header->udate) : (''));
$mail->from = $this->_fix(isset($header->fromaddress) ? ($header->fromaddress) : (''));
$mail->to = $this->_fix(isset($header->toaddress) ? ($header->toaddress) : (''));
$mail->reply_to = $this->_fix(isset($header->reply_toaddress) ? ($header->reply_toaddress) : (''));
$mail->subject = $this->_fix(isset($header->subject) ? ($header->subject) : (''));
$mail->content = array ();
$mail->attachments = array ();
$mail->deleted = false;
return $mail;
}
private function _fetch($mail)
{
$test = imap_reopen($this->box, "{$mail->mbox}");
if (!$test)
{
return $mail;
}
$structure = imap_fetchstructure($this->box, $mail->id);
if ((!isset($structure->parts)) || (!is_array($structure->parts)))
{
$body = imap_body($this->box, $mail->id);
$content = new stdClass();
$content->type = 'content';
$content->mime = $this->_fetchType($structure);
$content->charset = $this->_fetchParameter($structure->parameters, 'charset');
$content->data = $this->_decode($body, $structure->type);
$content->size = strlen($content->data);
$mail->content[] = $content;
return $mail;
}
else
{
$parts = $this->_fetchPartsStructureRoot($mail, $structure);
foreach ($parts as $part)
{
$content = new stdClass();
$content->type = null;
$content->data = null;
$content->mime = $this->_fetchType($part->data);
if ((isset($part->data->disposition))
&& ((strcmp('attachment', $part->data->disposition) == 0)
|| (strcmp('inline', $part->data->disposition) == 0)))
{
$content->type = $part->data->disposition;
$content->name = null;
if (isset($part->data->dparameters))
{
$content->name = $this->_fetchParameter($part->data->dparameters, 'filename');
}
if (is_null($content->name))
{
if (isset($part->data->parameters))
{
$content->name = $this->_fetchParameter($part->data->parameters, 'name');
}
}
$mail->attachments[] = $content;
}
else if ($part->data->type == 0)
{
$content->type = 'content';
$content->charset = null;
if (isset($part->data->parameters))
{
$content->charset = $this->_fetchParameter($part->data->parameters, 'charset');
}
$mail->content[] = $content;
}
$body = imap_fetchbody($this->box, $mail->id, $part->no);
if (isset($part->data->encoding))
{
$content->data = $this->_decode($body, $part->data->encoding);
}
else
{
$content->data = $body;
}
$content->size = strlen($content->data);
}
}
return $mail;
}
private function _fetchPartsStructureRoot($mail, $structure)
{
$parts = array ();
if ((isset($structure->parts)) && (is_array($structure->parts)) && (count($structure->parts) > 0))
{
foreach ($structure->parts as $key => $data)
{
$this->_fetchPartsStructure($mail, $data, ($key + 1), $parts);
}
}
return $parts;
}
private function _fetchPartsStructure($mail, $structure, $prefix, &$parts)
{
if ((isset($structure->parts)) && (is_array($structure->parts)) && (count($structure->parts) > 0))
{
foreach ($structure->parts as $key => $data)
{
$this->_fetchPartsStructure($mail, $data, $prefix . "." . ($key + 1), $parts);
}
}
$part = new stdClass;
$part->no = $prefix;
$part->data = $structure;
$parts[] = $part;
}
private function _fetchParameter($parameters, $key)
{
foreach ($parameters as $parameter)
{
if (strcmp($key, $parameter->attribute) == 0)
{
return $parameter->value;
}
}
return null;
}
private function _fetchType($structure)
{
$primary_mime_type = array ("TEXT", "MULTIPART", "MESSAGE", "APPLICATION", "AUDIO", "IMAGE", "VIDEO", "OTHER");
if ((isset($structure->subtype)) && ($structure->subtype) && (isset($structure->type)))
{
return $primary_mime_type[(int) $structure->type] . '/' . $structure->subtype;
}
return "TEXT/PLAIN";
}
private function _decode($message, $coding)
{
switch ($coding)
{
case 2:
$message = imap_binary($message);
break;
case 3:
$message = imap_base64($message);
break;
case 4:
$message = imap_qprint($message);
break;
case 5:
break;
default:
break;
}
return $message;
}
private function _callById($method, $data)
{
$callback = array ($this, $method);
// data is null
if (is_null($data))
{
$result = array ();
foreach ($this->list as $mail)
{
$result[] = $this->_callById($method, $mail);
}
return $result;
}
// data is an array
if (is_array($data))
{
$result = array ();
foreach ($data as $elem)
{
$result[] = $this->_callById($method, $elem);
}
return $result;
}
// data is an object
if ((is_object($data)) && ($data instanceof stdClass) && (isset($data->id)))
{
return call_user_func($callback, $data);
}
// data is numeric
if (($this->isConnected()) && (is_array($this->list)) && (is_numeric($data)))
{
foreach ($this->list as $mail)
{
if ($mail->id == $data)
{
return call_user_func($callback, $mail);
}
}
}
return null;
}
public function delete($nbr)
{
$this->_callById('_delete', $nbr);
return;
}
private function _delete($mail)
{
if ($mail->deleted == false)
{
$test = imap_reopen($this->box, "{$mail->mbox}");
if ($test)
{
$this->deleted = true;
imap_delete($this->box, $mail->id);
$mail->deleted = true;
}
}
}
public function searchBy($pattern, $type)
{
$result = array ();
if (is_array($this->list))
{
foreach ($this->list as $mail)
{
$match = false;
switch ($type)
{
case self::FROM:
$match = $this->_match($mail->from, $pattern);
break;
case self::TO:
$match = $this->_match($mail->to, $pattern);
break;
case self::REPLY_TO:
$match = $this->_match($mail->reply_to, $pattern);
break;
case self::SUBJECT:
$match = $this->_match($mail->subject, $pattern);
break;
case self::CONTENT:
foreach ($mail->content as $content)
{
$match = $this->_match($content->data, $pattern);
if ($match)
{
break;
}
}
break;
case self::ATTACHMENT:
foreach ($mail->attachments as $attachment)
{
$match = $this->_match($attachment->name, $pattern);
if ($match)
{
break;
}
}
break;
}
if ($match)
{
$result[] = $mail;
}
}
}
return $result;
}
private function _nmatch($string, $pattern, $a, $b)
{
if ((!isset($string[$a])) && (!isset($pattern[$b])))
{
return 1;
}
if ((isset($pattern[$b])) && ($pattern[$b] == '*'))
{
if (isset($string[$a]))
{
return ($this->_nmatch($string, $pattern, ($a + 1), $b) + $this->_nmatch($string, $pattern, $a, ($b + 1)));
}
else
{
return ($this->_nmatch($string, $pattern, $a, ($b + 1)));
}
}
if ((isset($string[$a])) && (isset($pattern[$b])) && ($pattern[$b] == '?'))
{
return ($this->_nmatch($string, $pattern, ($a + 1), ($b + 1)));
}
if ((isset($string[$a])) && (isset($pattern[$b])) && ($pattern[$b] == '\\'))
{
if ((isset($pattern[($b + 1)])) && ($string[$a] == $pattern[($b + 1)]))
{
return ($this->_nmatch($string, $pattern, ($a + 1), ($b + 2)));
}
}
if ((isset($string[$a])) && (isset($pattern[$b])) && ($string[$a] == $pattern[$b]))
{
return ($this->_nmatch($string, $pattern, ($a + 1), ($b + 1)));
}
return 0;
}
private function _match($string, $pattern)
{
return $this->_nmatch($string, $pattern, 0, 0);
}
}
ImapReader.demo.php Here is the usage sample
<?php
require_once("ImapReader.class.php");
$box = new ImapReader('example.com', '143', 'somebody#example.com', 'xxxxxxxxxxxx');
$box
->connect()
->fetchAllHeaders()
;
echo $box->count() . " emails in mailbox\n";
for ($i = 0; ($i < $box->count()); $i++)
{
$msg = $box->get($i);
echo "Reception date : {$msg->date}\n";
echo "From : {$msg->from}\n";
echo "To : {$msg->to}\n";
echo "Reply to : {$msg->from}\n";
echo "Subject : {$msg->subject}\n";
$msg = $box->fetch($msg);
echo "Number of readable contents : " . count($msg->content) . "\n";
foreach ($msg->content as $key => $content)
{
echo "\tContent " . ($key + 1) . " :\n";
echo "\t\tContent type : {$content->mime}\n";
echo "\t\tContent charset : {$content->charset}\n";
echo "\t\tContent size : {$content->size}\n";
}
echo "Number of attachments : " . count($msg->attachments) . "\n";
foreach ($msg->attachments as $key => $attachment)
{
echo "\tAttachment " . ($key + 1) . " :\n";
echo "\t\tAttachment type : {$attachment->type}\n";
echo "\t\tContent type : {$attachment->mime}\n";
echo "\t\tFile name : {$attachment->name}\n";
echo "\t\tFile size : {$attachment->size}\n";
}
echo "\n";
}
echo "Searching '*Bob*' ...\n";
$results = $box->searchBy('*Bob*', ImapReader::FROM);
foreach ($results as $result)
{
echo "\tMatched: {$result->from} - {$result->date} - {$result->subject}\n";
}
Enjoy
Regarding the blank emails, check the encoding of the mail.
If it is a binary encoded mail then you will get blank mails when you try to insert them into a mysql text field.
Try shifting every mail to UTF-8 and then insert it
iconv(mb_detect_encoding($mail_content, mb_detect_order(), true), "UTF-8", $mail_content);
function getmsg($mbox,$mid) {
// input $mbox = IMAP stream, $mid = message id
// output all the following:
global $charset,$htmlmsg,$plainmsg,$attachments;
$htmlmsg = $plainmsg = $charset = '';
$attachments = array();
// HEADER
$h = imap_header($mbox,$mid);
// add code here to get date, from, to, cc, subject...
// BODY
$s = imap_fetchstructure($mbox,$mid);
if (!$s->parts) // simple
getpart($mbox,$mid,$s,0); // pass 0 as part-number
else { // multipart: cycle through each part
foreach ($s->parts as $partno0=>$p)
getpart($mbox,$mid,$p,$partno0+1);
}
}
function getpart($mbox,$mid,$p,$partno) {
// $partno = '1', '2', '2.1', '2.1.3', etc for multipart, 0 if simple
global $htmlmsg,$plainmsg,$charset,$attachments;
// DECODE DATA
$data = ($partno)?
imap_fetchbody($mbox,$mid,$partno): // multipart
imap_body($mbox,$mid); // simple
// Any part may be encoded, even plain text messages, so check everything.
if ($p->encoding==4)
$data = quoted_printable_decode($data);
elseif ($p->encoding==3)
$data = base64_decode($data);
// PARAMETERS
// get all parameters, like charset, filenames of attachments, etc.
$params = array();
if ($p->parameters)
foreach ($p->parameters as $x)
$params[strtolower($x->attribute)] = $x->value;
if ($p->dparameters)
foreach ($p->dparameters as $x)
$params[strtolower($x->attribute)] = $x->value;
// ATTACHMENT
// Any part with a filename is an attachment,
// so an attached text file (type 0) is not mistaken as the message.
if ($params['filename'] || $params['name']) {
// filename may be given as 'Filename' or 'Name' or both
$filename = ($params['filename'])? $params['filename'] : $params['name'];
// filename may be encoded, so see imap_mime_header_decode()
$attachments[$filename] = $data; // this is a problem if two files have same name
}
// TEXT
if ($p->type==0 && $data) {
// Messages may be split in different parts because of inline attachments,
// so append parts together with blank row.
if (strtolower($p->subtype)=='plain')
$plainmsg. = trim($data) ."\n\n";
else
$htmlmsg. = $data ."<br><br>";
$charset = $params['charset']; // assume all parts are same charset
}
// EMBEDDED MESSAGE
// Many bounce notifications embed the original message as type 2,
// but AOL uses type 1 (multipart), which is not handled here.
// There are no PHP functions to parse embedded messages,
// so this just appends the raw source to the main message.
elseif ($p->type==2 && $data) {
$plainmsg. = $data."\n\n";
}
// SUBPART RECURSION
if ($p->parts) {
foreach ($p->parts as $partno0=>$p2)
getpart($mbox,$mid,$p2,$partno.'.'.($partno0+1)); // 1.2, 1.2.1, etc.
}
}
Reference (First user contributed note): http://php.net/manual/en/function.imap-fetchstructure.php
I tried all this answers, but neither one worked for me. Then I hit first user contributed note on this PHP page:
http://php.net/manual/en/function.imap-fetchstructure.php
and this works for all my cases. Quite old answer btw.

Contact form doesn't send if there is a space in name

I am reviewing a contact form for a website, but right now it doesn't want to send if in the sender name (like "John Smith") have space, it only sends if it's just a single word ("John"). Where could the problem be, I don't know anything about .php, but I am finding my way around.
EDIT: Ok, here is the code
<?php
function sendemail($toname, $toemail, $fromname, $fromemail, $subject, $message, $type = "plain", $cc = "", $bcc = "") {
require_once "class.phpmailer.php";
$mail = new PHPMailer();
$mail->IsMAIL();
$mail->CharSet = "UTF-8";
$mail->From = $fromemail;
$mail->FromName = $fromname;
$mail->AddAddress($toemail, $toname);
$mail->AddReplyTo($fromemail, $fromname);
if ($cc) {
$cc = explode(", ", $cc);
foreach ($cc as $ccaddress) {
$mail->AddCC($ccaddress);
}
}
if ($bcc) {
$bcc = explode(", ", $bcc);
foreach ($bcc as $bccaddress) {
$mail->AddBCC($bccaddress);
}
}
if ($type == "plain") {
$mail->IsHTML(false);
} else {
$mail->IsHTML(true);
$mail->Subject = $subject;
$mail->Body = $message;
if(!$mail->Send()) {
$mail->ErrorInfo;
$mail->ClearAllRecipients();
$mail->ClearReplyTos();
return false;
} else {
$mail->ClearAllRecipients();
$mail->ClearReplyTos();
return true;
}
}
}
function descript($text, $striptags = true) {
// Convert problematic ascii characters to their true values
$search = array("40","41","58","65","66","67","68","69","70",
"71","72","73","74","75","76","77","78","79","80","81",
"82","83","84","85","86","87","88","89","90","97","98",
"99","100","101","102","103","104","105","106","107",
"108","109","110","111","112","113","114","115","116",
"117","118","119","120","121","122"
);
$replace = array("(",")",":","a","b","c","d","e","f","g","h",
"i","j","k","l","m","n","o","p","q","r","s","t","u",
"v","w","x","y","z","a","b","c","d","e","f","g","h",
"i","j","k","l","m","n","o","p","q","r","s","t","u",
"v","w","x","y","z"
);
$entities = count($search);
for ($i=0; $i < $entities; $i++) {
$text = preg_replace("#(&\#)(0*".$search[$i]."+);*#si", $replace[$i], $text);
}
$text = preg_replace('#(&\#x)([0-9A-F]+);*#si', "", $text);
$text = preg_replace('#(<[^>]+[/\"\'\s])(onmouseover|onmousedown|onmouseup|onmouseout|onmousemove|ondblclick|onfocus|onload|xmlns)[^>]*>#iU', ">", $text);
$text = preg_replace('#([a-z]*)=([\`\'\"]*)script:#iU', '$1=$2nojscript...', $text);
$text = preg_replace('#([a-z]*)=([\`\'\"]*)javascript:#iU', '$1=$2nojavascript...', $text);
$text = preg_replace('#([a-z]*)=([\'\"]*)vbscript:#iU', '$1=$2novbscript...', $text);
$text = preg_replace('#(<[^>]+)style=([\`\'\"]*).*expression\([^>]*>#iU', "$1>", $text);
$text = preg_replace('#(<[^>]+)style=([\`\'\"]*).*behaviour\([^>]*>#iU', "$1>", $text);
if ($striptags) {
do {
$thistext = $text;
$text = preg_replace('#</*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i', "", $text);
} while ($thistext != $text);
}
return $text;
}
$name=0;
$telefon=0;
$sender=0;
$syobshtenie=0;
$ename=0;
$etelefon=0;
$esender=0;
$esyobshtenie=0;
if($_POST['name']){
$name = "Запитване от ".$_POST['name'];
}
else { $name=1; $ename=1; }
if($_POST['sender']){
$sender = $_POST['sender'];
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $sender))
{
$sender="Email";
}
}
else { $sender=1; $esender=1; }
if($_POST['telefon']){
$telefon = $_POST['telefon'];
}
if($_POST['zapitvane']){
$zapitvane = $_POST['zapitvane'];
$syobshtenie = "<p>Запитване от ".$_POST['name']."
<br />Email: ".$sender."
<br />Телефон: ".$telefon."</p>".$zapitvane;
}
else { $syobshtenie=1; $esyobshtenie=1; }
if($name=="Име"){ $ename=1; }
if($telefon=="Телефон"){ $etelefon=1; }
if($sender=="Email"){ $esender=1; }
if($syobshtenie=="Моля, въведете съобщение до нас"){ $esyobshtenie=1; }
if($ename==0 && $esender==0 && $esyobshtenie==0 && $etelefon==0){
sendemail("VillaDes", "info#konsumator.com", "", $sender, $name, $syobshtenie, "", "", "");
echo '
<div class="active-error"" style="margin-top:5px;">Съобщението Ви беше изпратено.<br /><br />Приятен ден!</div>
<script>
document.getElementById("contact").reset();
</script>';
}
else {
echo '
<div class="border-15"></div><div class="active-error"><b>Моля, въведете:</b></div><div class="border-8"></div>';
if($ename==1) { echo '<div class="active-error">Име</div><div class="border-8"></div>'; }
if($esender==1) { echo '<div class="active-error">Е-поща</div><div class="border-8"></div>'; }
if($etelefon==1) { echo '<div class="active-error">Телефон</div><div class="border-8"></div>'; }
if($esyobshtenie==1) { echo '<div class="active-error">Запитване</div>'; }
}
echo '<script type="text/javascript">
$(document).ready(function() {
$("#close-email").click(function () { $("#mailresult").hide("fast"); } );
});
</script>';
?>
In the code you post you call:
sendemail("VillaDes", "info#konsumator.com", "", $sender, $name, $syobshtenie, "", "", "");
Your sendemail function accepts:
sendemail($toname, $toemail, $fromname, $fromemail, $subject, $message
So $fromname will be used as the subject of your e-mail and formname will be empty.
class.phpmailer.php should handle subjects with spaces, so i don't think this will be the problem.
When you use $name as $fromemail spaces will be a problem maybe. (name without spaces can be a local mailbox??).
Beside all this you don't need the class.phpmailer.php to send your email.
Use the default mail function: http://php.net/manual/en/function.mail.php
$headers = 'From: "'.$fromemail.'" <'.$fromname.'>' . "\r\n" .
'Reply-To: "'.$fromname.'" <'.$fromemail.'>' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail('"VillaDes" <info#konsumator.com>',$syobshtenie, "", $headers);

Categories