Hi guys,
Ive been having a bit of an issue with php today and it has me totally stumped.
Hopefully someone on here can point out my mistake.
I have a function for sending an email with attachments. This works bar one small issue.
! is appearing in the email body and is screwing up part of the formatting
Below is the code:
PHP Code:
function xmail($to, $subject, $text, $ref) {
/* */
$filepath = ../../images/uploads/.$ref./;
$vmLink =;
$vwLink =;
if ($handle = opendir($filepath)) {
while (false !== ($file = readdir($handle))) {
if ($file != . && $file != ..) {
$extArr = explode(., $file);
$extStr = $extArr[1];
if($extStr !=mov && $extStr !=wmv){
$files[] = $filepath.$file;
}else{
$fileType = substr($file,15,4);
if($fileType == _vm_){
$link1 = http://www.domain.com/images/uploads/.$ref./.$file;
$vmLink = Movie link download: <a href=$link1>$file</a> Right click Save Target as... <br />;
}
if($fileType == _vw_){
$link2 = http://www.domain.com/images/uploads/.$ref./.$file;
$vwLink = Wire-res link download: <a href=$link2>$file</a> Right click Save Target as... <br />;
}
}
}
}
$text.=<br />.$vmLink.$vwLink;
closedir($handle);
}
/* */
$b = 0;
$fEmail =
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
;
$mail_attached = ;
$boundary = md5(uniqid(time(),1))._xmail;
$add_header = MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=$boundary;
if (count($files)>0) {
for ($a=0;$a<count($files);$a++) {
if ($fp = fopen($files[$a],rb)) {
$file_name = basename($files[$a]);
$content[$b] = fread($fp,filesize($files[$a]));
$mail_attached .= --.$boundary.
.Content-Type: image/jpeg; name=$file_name\r
. Content-Transfer-Encoding: base64
. Content-Disposition: attachment; filename=$file_name\r
.chunk_split(base64_encode($content[$b])).
;
$b++;
fclose($fp);
} else {
echo none;
}
}
$mail_attached .= --.$boundary.
;
$mail_content = --.$boundary.
. Content-Type: text/html; charset=iso-8859-1; format=flowed
. Content-Transfer-Encoding: 8bit
. $text.
.$mail_attached;
$ok = mail($to,$subject,$mail_content,$add_header
.FROM:.$fEmail,-fwebmaster@{$_SERVER[SERVER_NAME]});
return true;
}else {
$sheaders = MIME-Version: 1.0
;
$sheaders .= Content-type: text/html; charset=iso-8859-1
;
$sheaders .= From: $fEmail
;
$ok = mail($to,$subject,$text,$sheaders,-fwebmaster@{$_SERVER[SERVER_NAME]});
return true;
}
}
This is not all my code. More a miss-mash of years of editing.
Any takers?
Attached is a screen grab of the email that comes through with the issue.
Hi guys,
Ive been having a bit of an issue with php today and it has me totally stumped.
Hopefully someone on here can point out my mistake.
I have a function for sending an email with attachments. This works bar one small issue.
! is appearing in the email body and is screwing up part of the formatting
Below is the code:
PHP Code:
function xmail($to, $subject, $text, $ref) {
/* */
$filepath = ../../images/uploads/.$ref./;
$vmLink =;
$vwLink =;
if ($handle = opendir($filepath)) {
while (false !== ($file = readdir($handle))) {
if ($file != . && $file != ..) {
$extArr = explode(., $file);
$extStr = $extArr[1];
if($extStr !=mov && $extStr !=wmv){
$files[] = $filepath.$file;
}else{
$fileType = substr($file,15,4);
if($fileType == _vm_){
$link1 = http://www.domain.com/images/uploads/.$ref./.$file;
$vmLink = Movie link download: <a href=$link1>$file</a> Right click Save Target as... <br />;
}
if($fileType == _vw_){
$link2 = http://www.domain.com/images/uploads/.$ref./.$file;
$vwLink = Wire-res link download: <a href=$link2>$file</a> Right click Save Target as... <br />;
}
}
}
}
$text.=<br />.$vmLink.$vwLink;
closedir($handle);
}
/* */
$b = 0;
$fEmail =
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
;
$mail_attached = ;
$boundary = md5(uniqid(time(),1))._xmail;
$add_header = MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=$boundary;
if (count($files)>0) {
for ($a=0;$a<count($files);$a++) {
if ($fp = fopen($files[$a],rb)) {
$file_name = basename($files[$a]);
$content[$b] = fread($fp,filesize($files[$a]));
$mail_attached .= --.$boundary.
.Content-Type: image/jpeg; name=$file_name\r
. Content-Transfer-Encoding: base64
. Content-Disposition: attachment; filename=$file_name\r
.chunk_split(base64_encode($content[$b])).
;
$b++;
fclose($fp);
} else {
echo none;
}
}
$mail_attached .= --.$boundary.
;
$mail_content = --.$boundary.
. Content-Type: text/html; charset=iso-8859-1; format=flowed
. Content-Transfer-Encoding: 8bit
. $text.
.$mail_attached;
$ok = mail($to,$subject,$mail_content,$add_header
.FROM:.$fEmail,-fwebmaster@{$_SERVER[SERVER_NAME]});
return true;
}else {
$sheaders = MIME-Version: 1.0
;
$sheaders .= Content-type: text/html; charset=iso-8859-1
;
$sheaders .= From: $fEmail
;
$ok = mail($to,$subject,$text,$sheaders,-fwebmaster@{$_SERVER[SERVER_NAME]});
return true;
}
}
This is not all my code. More a miss-mash of years of editing.
Any takers?
Attached is a screen grab of the email that comes through with the issue.
|
|
Search Webmaster Help and Solution
issue with ! appearing in emailRelated ItemsQuery failed: connection to localhost:3354 failed (errno=111, msg=Connection refused). |
