Problema invio e-mail in WebSite X5

harley

Nuovo Utente
16 Gen 2009
23
0
0
Questo è il codice contenuto in un file imemail.inc.php
che mi crea un software.
Praticamente mi succede che quando mi arriva una mail letta con outlook expres o con qualunque altro software la mail mi arriva in formato html completamente spaginata.Invece letta direttamente da web e perfettamente formattatta
Il problema si verifica solo utilizzando l'host aruba linux (su tutti gli altri host nessun problema) contattato aruba e loro sostengono che non è un problema dei loro server.
Ora mi potete dare qualche consiglio su come modificare questo codice per il risolvere il problema?
Grazie
Saluti
<?php
//Incomedia WebSite X5 EMail Class. All rights reserved.
class imEMail {
var $from;
var $to;
var $subject;
var $charset;
var $text;
var $html;

var $attachments;

function imEMail($from,$to,$subject,$charset) {
$this->from = $from;
$this->to = $to;
$this->subject = $subject;
$this->charset = $charset;
}

function setFrom($from) {
$this->from = $from;
}

function setTo($to) {
$this->to = $to;
}

function setSubject($subject) {
$this->subject = $subject;
}

function setCharset($charset) {
$this->charset = $charset;
}

function setText($text) {
$this->text = $text;
}

function setHTML($html) {
$this->html = $html;
}

function attachFile($name,$content,$mime_type) {
$attachment['name'] = $name;
$attachment['content'] = base64_encode($content);
$attachment['mime_type'] = $mime_type;
$this->attachments[] = $attachment;
}

function send() {
if($this->from == "" || $this->to == "" || ($this->text == "" && $this->html == ""))
return false;

$boundary = md5(time());

$headers .= "From: " . $this->from . "\r\n";
$headers .= "Message-ID: <" . time() . rand(0,9) . rand(0,9) . "@websitex5.users>\r\n";
$headers .= "X-Mailer: WebSiteX5 Mailer\r\n";

$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"" . $boundary . "\"\r\n\r\nThis is a multi-part message in MIME format\r\n\r\n";

$msg = "--" . $boundary . "\r\n";

if($this->html == "") {
$msg .= "Content-Type: text/plain; charset=" . $this->charset . "\r\n";
$msg .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
$msg .= $this->text . "\r\n\r\n";
}
else if($this->text == "") {
$msg .= "Content-Type: text/html; charset=" . $this->charset . "\r\n";
$msg .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
$msg .= $this->html . "\r\n\r\n";
}
else {
$alt_boundary = $boundary . "_alt";
$msg .= "Content-Type: multipart/alternative; boundary=\"" . $alt_boundary . "\"\r\n\r\n";

$msg .= "--" . $alt_boundary . "\r\n";
$msg .= "Content-Type: text/plain; charset=" . $this->charset . "\r\n";
$msg .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$msg .= $this->text . "\r\n\r\n";

$msg .= "--" . $alt_boundary . "\r\n";
$msg .= "Content-Type: text/html; charset=" . $this->charset . "\r\n";
$msg .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$msg .= $this->html . "\r\n\r\n";

$msg .= "--" . $alt_boundary . "--\r\n\r\n";
}

if(is_array($this->attachments)) {
foreach($this->attachments as $attachment) {
$msg .= "--" . $boundary . "\r\n";
$msg .= "Content-Type: " . $attachment["mime_type"] . "; name=\"" . $attachment["name"] . "\"\r\n";
$msg .= "Content-Transfer-Encoding: base64\r\n";
$msg .= "Content-Disposition: attachment; filename=\"" . $attachment["name"] . "\"\r\n\r\n";
$msg .= chunk_split($attachment["content"]) . "\r\n\r\n";
}
}

$msg .= "--" . $boundary . "--\r\n\r\n";

$r = @mail($this->to, $this->subject, $msg, $headers, "-f" . $this->from);
if(!$r) {
$headers = "To: " . $this->to . "\r\n" . $headers;
$r = @mail($this->to, $this->subject, $msg, $headers);
}
return $r;
}
}
?>
 
Discussioni simili
Autore Titolo Forum Risposte Data
Daniele_Carrara Problema timeout - invio mail PHP 7
A [PHP] Problema invio mail con funzione mail() PHP 3
Punix [PHP] problema script invio e-mail PHP 2
cobra_72 [PHP] problema invio multiplo allegati mail PHP 21
Il Matta Problema Form e invio mail PHP 2
B Problema form mail per invio doppio allegato PHP 1
A Problema orario invio mail per form PHP 4
O [PHP] Problema Invio Mail PHP 2
A problema invio mail PHP 5
C problema invio mail con form php PHP 0
D Problema invio mail [GIA POSTATO ERRONEAMENTE IN HTML] PHP 0
D Problema invio mail PHP 6
LaKanka Problema invio e-mail, prima riga vuota PHP 0
C Mail e php problema invio PHP 11
L Problema invio allegati via mail con libero PHP 5
V Problema con l'invio delle mail in locale (usando quindi easy php) PHP 16
S Problema invio mail da form Classic ASP 6
Angel0 Problema invio e-mail (era: problemi con xoom) Posta Elettronica 4
B Problema invio mail con script php verso i dominii libero PHP 9
A problema con invio e-mail con CDONTS Classic ASP 0
V problema con invio mail Hosting 2
M [PHP] Problema script ricezione e invio posta... PHP 1
C [PHP] Problema Invio Email Elseif PHP 2
S Problema in PHP per invio file XML - RISOLTO- PHP 8
S Problema invio form php/html PHP 3
R PROBLEMA INVIO EMAIL AL CAMBIO DI STATO ORDINE E-Commerce 1
L invio smtp con phpmailer - problema invia due volte la email allo stesso utente PHP 0
asevenx problema invio email tramite form PHP 3
A Problema invio dati form contatti PHP 12
D Problema modulo invio messaggio da sito web PHP 7
A Problema invio messaggio col form PHP 1
S Problema con invio dati PHP 0
P Problema di invio dati PHP 4
L Problema di invio "value" PHP 1
Task Mc Problema form invio email da sito ç__ç PHP 4
L problema invio newsletter con script proprio in php PHP 10
Z Problema invio dati da textarea PHP 2
S Problema con l'invio del form in php PHP 0
F Problema form invio email php PHP 3
A Problema form invio dati PHP 2
T Problema invio dati ad altra pagina PHP 1
D Problema nell'invio dei dati di un form ad uno script AJAX Ajax 8
A problema con l'invio della password tramite email PHP 23
P Problema invio email da php PHP 9
J problema con apache2+php ed invio file con cURL Apache 2
J Problema invio file con cURL php su server verso server PHP 1
C Problema con il doppio invio nel form con onsubmit HTML e CSS 9
M problema script invio email multiplo PHP 8
B problema invio email PHP 7
B problema invio email PHP 7

Discussioni simili