Torna indietro   Serverplan Forum > Risorse per Webmaster > PHP

Rispondi
 
LinkBack Strumenti discussione Modalità visualizzazione
  #1 (permalink)  
Vecchio 15-09-2007, 18.00.04
Junior Member
 
Data registrazione: 09-06-2007
Messaggi: 4
web-experiments is on a distinguished road
Predefinito le email non vengono inviate con script PHP

Salve, ho fatto diverse prove con questo scrpt php:

<?php

$a="prova@tin.itt";
$oggetto="prova con tin";
$messaggio="prova con tin";

if (mail($a, $oggetto, $messaggio)) echo "ok";
else echo"ko";

?>

eseguendo lo script con destinatari diversi ho notato che le email vengono spedite correttamente verso alcuni domini come tiscali, yahoo, gmail, mentre non vengono spedite (o comunque non arrivano al destinatario) verso i domini alice.it, libero.it

pensando che ci fosse qualcosa di sbagliato nel comporre la mail (intestazioni mancanti ecc) ho provato a cambiare l'indirizzo al quale mi vengono spedite email dal form dei contatti del mio blog realizzato con Wordpress, il plugin installato per gestire i contatti si chiama "Contact Form" se inserisco la mia mail di tiscali.it le email mi vengono recapitate, mentre se inserisco le mie mail di libero.it e tin.it non arriva nulla.

Anche testando lo script che dovrebbe notificare la presenza di nuovi commenti di un articolo, le notifiche non arrivano ai domini sopra elencati.

Inviando le mail con Outlook o Thunderbird non ci sono problemi le mail vengono spedite correttamente verso qualunque dominio.

non riesco a capire, sembra un problema solo delle mail inviate con script PHP, ma perch? quelle inviate verso alcuni domini vengono inviate e le altre no? Non ricevo nessuna notifica di mancato recapito, semplicemente le mail non arrivano perdendosi nel nulla...

Ho un hosting di tipo Extra Plan Linux
Rispondi citando
  #2 (permalink)  
Vecchio 18-09-2007, 16.42.09
L'avatar di morphey
Administrator
 
Data registrazione: 13-03-2006
Messaggi: 213
morphey ha disabilitato la reputazione
Predefinito

Ciao,

se invii senza headers viene preso come riferimento nobody@hostname_macchina e molti provider scartano la mail perche' rilevata come spam.

Devi inserire l'header della mail del tipo:

Codice:
if (mail("tuo@destinatario.it","oggetto messaggio","testo del messaggio","From: <email.del@tuosito.it>\r\n")) { echo "ok"; } else { echo "errore invio mail"; }
Rispondi citando
  #3 (permalink)  
Vecchio 12-02-2008, 22.52.35
Junior Member
 
Data registrazione: 24-07-2005
Messaggi: 4
spaccasu is on a distinguished road
Question

Ciao,

anche io ho lo stesso problema, ma anche con il codice che hai mandato continua a non funzionare. L' indirizzo del mittente è una casella di posta esistente sul server, il destinatario @gmail

Ho una VPS, le configurazioni PHP /usr/local/lib/php.ini
--
[mail function]
; For Win32 only.
;SMTP = localhost
;smtp_port = 25

; For Win32 only.
;sendmail_from = user@esempio.it

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /usr/sbin/sendmail -t
--

Se invio mail da console con mail user@dom.it la mail viene inviata, ma se invio da script PHP non funziona.

Come posso fare?
grazie
Rispondi citando
  #4 (permalink)  
Vecchio 06-03-2008, 17.25.15
Junior Member
 
Data registrazione: 06-03-2008
Messaggi: 1
isbmaste is on a distinguished road
Predefinito Problema invio email

Anch'io ho lo stesso problema.
Anche mettendo il From: email@dominio.it come header nel php, il sistema antispam (in realtà almeno 2 completamente diversi tra loro), vedono l'email sempre con mittente: isbmaste@zeus.dnssplan.com in cui zeus.dnssplan.com non esiste e quindi la mail viene bloccata.
Vi decidete a configurare correttamente i server, oppure a fornire soluzioni alternative?
Rispondi citando
  #5 (permalink)  
Vecchio 06-03-2008, 22.47.18
L'avatar di morphey
Administrator
 
Data registrazione: 13-03-2006
Messaggi: 213
morphey ha disabilitato la reputazione
Predefinito

Ciao isbmaste,

abbiamo effettuato delle prove e tutte sono arrivate correttamente.
Puoi postare il codice comprensivo degli header per controllare?

spaccasu: hai una vps con cPanel?
Rispondi citando
  #6 (permalink)  
Vecchio 22-07-2008, 20.03.25
Junior Member
 
Data registrazione: 15-01-2007
Messaggi: 15
Nagol is on a distinguished road
Predefinito

Citazione:
Originalmente inviato da isbmaste Visualizza messaggio
Anch'io ho lo stesso problema.
Anche mettendo il From: email@dominio.it come header nel php, il sistema antispam (in realtà almeno 2 completamente diversi tra loro), vedono l'email sempre con mittente: isbmaste@zeus.dnssplan.com in cui zeus.dnssplan.com non esiste e quindi la mail viene bloccata.
Vi decidete a configurare correttamente i server, oppure a fornire soluzioni alternative?
Stesso e identico problema. Sto impazzendo per sta cosa e non riesco a risolvere...
E dopo molte ore con un vs. tecnico non ho ancora risolto.
In particolare, le mail che non arrivano sono quelle di libero e Co. mi ritornano indietro con il seguente errore:

SMTP error from remote mail server after MAIL FROM: SIZE=6158:
host mxlibero2.libero.it [212.xxxxx]: 553 Domain of sender address sito@ares.dnshighspeed.com does not exist. For further information contact your provider. If you are the provider, mailto:support@postmaster.libero.it?subject=Code 553

Ultima modifica di Nagol : 22-07-2008 alle ore 20.09.46.
Rispondi citando
  #7 (permalink)  
Vecchio 28-07-2008, 11.59.52
Junior Member
 
Data registrazione: 14-05-2008
Messaggi: 3
smemorex is on a distinguished road
Predefinito

Salve,
dall'errore riportato è evidente che il problema è nel campo from. Come suggerito qualche post più sopra inserisca:

mail("tuo@destinatario.it","oggetto messaggio","testo del messaggio","From: <email.del@tuosito.it>\r\n")

dove al posto di email.del@tuosito.it inserisce un account presente sul suo spazio, le assicuro che con questa sintassi tutti i nostri clienti riescono ad inviare mail anche a libero.it e co.
Rispondi citando
  #8 (permalink)  
Vecchio 12-08-2008, 15.59.59
Junior Member
 
Data registrazione: 15-01-2007
Messaggi: 15
Nagol is on a distinguished road
Predefinito

Citazione:
Originalmente inviato da smemorex Visualizza messaggio
Salve,
dall'errore riportato è evidente che il problema è nel campo from. Come suggerito qualche post più sopra inserisca:

mail("tuo@destinatario.it","oggetto messaggio","testo del messaggio","From: <email.del@tuosito.it>\r\n")

dove al posto di email.del@tuosito.it inserisce un account presente sul suo spazio, le assicuro che con questa sintassi tutti i nostri clienti riescono ad inviare mail anche a libero.it e co.
Ecco le stringhe del mio script:

sendmail($to, "redazione@mangaforever.net", $messaggio2, $titolo, 1, $totest);

Poi è un altro che fa apparire quei dati nella mail:

sendmail($to, "redazione@mangaforever.net", $messaggio, "Newsletter Settimanale", 1);

E inoltre ho questa stringa qui:

if ( !@mail($to, $subject, $message, $headers) ) {
if ( !@mail($to, $subject, $message, "From: <$from>\r\nReturn-Path: <$from>\r\n") ) {
echo "\n";

$headers = "From: <$from>" . $delimiter;
$headers .= "Return-Path: <$from>" . $delimiter;

Cosa dovrei modificare?


Da notare che quando lo script viene inviato direttamente da web digitando l'indirizzo dello script il return path è questo

Return-path: <nobody@ares.dnshighspeed.com>

Quando lo script viene inviato attraverso il cron job il return path è questo:

Return-path: <mangxxx (nome utende del server) @ares.dnshighspeed.com>

Ultima modifica di Nagol : 12-08-2008 alle ore 18.07.08.
Rispondi citando
  #9 (permalink)  
Vecchio 12-08-2008, 18.09.29
Junior Member
 
Data registrazione: 15-01-2007
Messaggi: 15
Nagol is on a distinguished road
Predefinito

Posto il codice completo, così speriamo di risolvere questo problema che va avanti da troppo, troppo, tempo e mi sta facendo perdere davvero moltissimo tempo...

<?PHP
// Inclusione file MKPortal per collegamento al database
define ( 'IN_MKP', 1 );
$MK_PATH = "../";
require $MK_PATH."mkportal/conf_mk.php";
require $MK_PATH."mkportal/include/SMF/smf_driverf.php";
$prefix = DBPREFIX;

// Leggo i dati dal database
$query = $DB->query("
SELECT *
FROM mkp_newsletter
WHERE data <= UNIX_TIMESTAMP()
");

// Se c'è qualcosa da spedire proseguo
//if ( $DB->get_num_row() == 0 ) exit();

// Mi creo l'array con gli utenti del sito
//$prefix = DBPREFIX;
$elenco = array();
$users = $DB->query("
SELECT ID_MEMBER, memberName, emailAddress
FROM {$prefix}members
ORDER BY ID_MEMBER
");
while ( $row1 = $DB->fetch_row($users) ) {
$id = $row1['ID_MEMBER'];
$elenco[$id]['name'] = $row1['memberName'];
$elenco[$id]['email'] = $row1['emailAddress'];
}

if ( isset($_GET['totest']) ) {
$elenco = array();
$elenco['1']['name'] = "xxx";
$elenco['1']['email'] = "xxx@libero.it";
$elenco['2']['name'] = "Redazione";
$elenco['2']['email'] = "redazione@mangaforever.net";
}

$numero_di_utenti = count($elenco);
echo $numero_di_utenti;
echo "<br />";
#print_r($elenco);

while ( $row = $DB->fetch_row($query) ) {
$id = $row['id'];
$titolo = $row['titolo'];
$testo = stripslashes($row['testo']);
$data = $row['data'];
$weekly = (int)$row['weekly'];

$totest = 0;
$data_invio = getdate($data);
$data_attuale = getdate(time());
// Per le newsletter settimanali serve a farle inviare SOLO il giorno giusto
if ( $weekly == 2 && ($data_invio['wday'] != $data_attuale['wday']) ) {
$totest = 1;
}

$messaggio = getemail($titolo, $testo);

foreach ( $elenco AS $utente ) {
$to = trim($utente['email']);
$messaggio2 = str_replace("{username}", $utente['name'], $messaggio);
sendmail($to, "redazione@mangaforever.net", $messaggio2, $titolo, 1, $totest);
}

if ( $weekly == 1 && $totest == 0) {
$DB->query("DELETE FROM mkp_newsletter WHERE id = '$id'");
}
}
/*
================================================== ======
GESTIONE NEWSLETTER SUNTO SETTIMANALE AUTOMATICO
================================================== ======
Dettagli giorni:
0 => Domenica
1 => Lunedì
2 => Martedì
3 => Mercoledì
4 => Giovedì
5 => Venerdì
6 => Sabato
*/

// Sceglie di che giorno inviare la newsletter settimanale automatica
$data_attuale = getdate(time());
if ( $data_attuale['wday'] != 2 ) {
exit();
}

$cont = "";

// News
$query_news = "
SELECT id, titolo, testo, data, image
FROM mkp_news
WHERE validate = '1' AND CURDATE() - INTERVAL 7 DAY <= FROM_UNIXTIME(data) AND data <= UNIX_TIMESTAMP()
ORDER BY data DESC
LIMIT 89
";
$cont .= "<tr><td colspan=\"2\" bgcolor=\"#d5d5d5\" align=\"center\"><strong>NEWS DELLA SETTIMANA</strong></td></tr>";
$cont .= build($query_news, "news", "news_show_single", "ide");

// Recensioni
$query_reviews = "
SELECT id, title AS titolo, review AS testo, date AS data, image
FROM mkp_reviews
WHERE validate = '1' AND CURDATE() - INTERVAL 7 DAY <= FROM_UNIXTIME(date) AND date <= UNIX_TIMESTAMP()
ORDER BY date DESC
";
$cont .= "<tr><td colspan=\"2\" bgcolor=\"#d5d5d5\" align=\"center\"><strong>RUBRICHE E RECENSIONI DELLA SETTIMANA</strong></td></tr>";
$cont .= build($query_reviews, "reviews", "entry_view", "iden");

// Download
$query_downloads = "
SELECT id, name AS titolo, description AS testo, data, screen1 AS image
FROM mkp_download
WHERE validate = '1' AND CURDATE() - INTERVAL 7 DAY <= FROM_UNIXTIME(data) AND data <= NOW()
ORDER BY data DESC
";
$cont .= "<tr><td colspan=\"2\" bgcolor=\"#d5d5d5\" align=\"center\"><strong>DOWNLOAD DELLA SETTIMANA</strong></td></tr>";
$cont .= build($query_downloads, "download", "entry_view", "iden");

// Messaggio Email
$content = "
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">
{$cont}
</table>
";

$messaggio = getemail("Newsletter Settimanale", $content);
foreach ( $elenco AS $utente ) {
$to = trim($utente['email']);
sendmail($to, "redazione@mangaforever.net", $messaggio, "Newsletter Settimanale", 1);
}

/*
================================================== ===========
FINE GESTIONE NEWSLETTER SUNTO SETTIMANALE AUTOMATICO
================================================== ===========
*/


// FUNZIONE GENERAZIONE NEWSLETTER SETTIMANALE
function build($query1, $ind, $op, $ide, $col = 2) {
global $DB;

$cont = "";
$count = 0;
$query = $DB->query($query1);

while ( $row = $DB->fetch_row($query) ) {
$id = $row['id'];
$titolo = stripslashes($row['titolo']);
$testo = stripslashes(substr(strip_tags($row['testo']), 0, 150)) . "...";
$data = date("d/m/Y", $row['data']);
$image = $row['image'];

$grid_image = "<img src=\"http://www.mangaforever.net/mkportal/modules/reviews/images/a_no_image.gif\" width=\"64px\" alt=\"\" border=\"0\">";
if ( $image ) {

if ( strtolower(substr($image, 0, 7)) == 'http://' )
$grid_image = "<img src=\"$image\" width=\"64px\" alt=\"\" border=\"0\">";
elseif ( $ind == "reviews" && strtolower(substr($image, 0, 8)) != 'mkportal')
$grid_image = "<img src=\"http://www.mangaforever.net/mkportal/modules/reviews/images/$image\" width=\"64px\" alt=\"\" border=\"0\">";
}

if ( $count == 0 ) {
$cont .= "
<tr>
";
}

$cont .= "
<td class=\"tabnews\" width=\"50%\" valign=\"top\">
<table cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">
<tr>
<td colspan=\"2\" style=\"font: 11px Curier New\">[$data] - <a href=\"http://www.mangaforever.net/index.php?ind=$ind&op=$op&amp;$ide={$row['id']}\"><strong>$titolo</strong></a></td>
</tr>
<tr>
<td bgcolor=\"#FFFFFF\" align=\"center\" width=\"64px\" style=\"height: 64px; margin: auto;\">
<a href=\"http://www.mangaforever.net/index.php?ind=$ind&op=$op&amp;$ide={$row['id']}\">$grid_image</a>
</td>

<td class=\"tdblock\" valign=\"top\">
<div align=\"justify\" style=\"font: 10px Curier New\">$testo</div>
</td>
</tr>
</table>
</td>
";

$count = ( $count + 1 ) % $col;
if ( $count == 0 ) {
$cont .= "
</tr>
";
}
}
if ( $count == 1 ) {
$cont .= "
<td class=\"tabnews\" width=\"50%\">
</td>
</tr>
";
}

return $cont;
}

// FUNZIONE PER INVIO EMAIL
function sendmail($to, $from, $message, $subject, $html = 0, $test = 0) {
if ( !$to ) return false;

$delimiter = "\n";
$encoding = 'UTF-8';
$http_host = "www.mangaforever.net";

$headers = "From: <$from>" . $delimiter;
$headers .= "Return-Path: <$from>" . $delimiter;

if ($_SERVER['HTTP_HOST'] OR $_ENV['HTTP_HOST'])
{
$http_host = $_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_ENV['HTTP_HOST'];
}
else if ($_SERVER['SERVER_NAME'] OR $_ENV['SERVER_NAME'])
{
$http_host = $_SERVER['SERVER_NAME'] ? $_SERVER['SERVER_NAME'] : $_ENV['SERVER_NAME'];
}
$http_host = trim($http_host);

$msgid = '<' . gmdate('YmdHs') . '.' . substr(md5($message . microtime()), 0, 6) . rand(100000, 999999) . '@' . $http_host . '>';
$headers .= 'Message-ID: ' . $msgid . $delimiter;

$headers .= 'MIME-Version: 1.0' . $delimiter;

if ( $html == 0 ) {
$headers .= 'Content-Type: text/plain' . ("; charset=\"iso-8859-1\"") . $delimiter;
} else {
$headers .= 'Content-Type: text/html' . ("; charset=\"iso-8859-1\"") . $delimiter;
}

$headers .= 'Content-Transfer-Encoding: 8bit' . $delimiter;
$headers .= 'X-Priority: 3' . $delimiter;
$headers .= 'X-Mailer: MangaForever Mail via PHP' . $delimiter;

if ( $test == 1 ) {
return true;
}

// Introduce una pausa di 0.01 secondi
usleep(90000);

if ( !@mail($to, $subject, $message, $headers) ) {
if ( !@mail($to, $subject, $message, "From: <$from>\r\nReturn-Path: <$from>\r\n") ) {
echo "\n";
echo "Indirizzo ".$to." - Non inviata";
return false;
}
#return @mail($to, $subject, $message, "From: <$from>");
}
echo "\n";
echo "Indirizzo ".$to." - Inviata";
return true;
}
Rispondi citando
  #10 (permalink)  
Vecchio 12-08-2008, 18.09.59
Junior Member
 
Data registrazione: 15-01-2007
Messaggi: 15
Nagol is on a distinguished road
Predefinito

// FUNZIONE PER LA FORMATTAZIONE DELLA EMAIL
function getemail($titolo, $messaggio) {
RETURN <<<EOF
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>$title</title>
</head>
<body bgcolor="#bfbfbf">
<center>
<div style="width: 553px; border: 2px solid #306B95; background-color: #FFF;">
<div>
<a href="http://www.mangaforever.net"><img src="http://www.mangaforever.net/mkportal/icone/logo_newsletter.jpg" alt="MangaForever HTML Mail Logo" border="0" width="553px"></a>
</div>

<div align="justify" style="margin: 20px; font: 13px Tahoma, Arial, Helvetica, sans-serif;">
$messaggio
</div>
<div align="center">
<p style="font-family: Tahoma,Arial,Helvetica,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(204, 204, 204);"><font size="1">Ricevi questa mail perch&egrave; iscritto sul sito <a href="http://www.mangaforever.net">www.mangaforever.net</a>. Se vuoi cancellarti dal portale spedisci una mail <a href="mailto:redazione@mangaforever.net">a questo indirizzo,</a> specificando mail e nick di registrazione al portale. In questo modo verrai cancellato contemporaneamente dal portale, dal forum e dalla newsletter. </font></p>
</div>
<div align="center">
<p style="font: 11px Tahoma, Arial, Helvetica, sans-serif;">
<div align="center">
<p style="font: 11px Tahoma, Arial, Helvetica, sans-serif;">
<strong>© Copyright 2006-2008 MangaForever.net</strong>
</p>
</div>
</div>
</center>
</body>
</html>

EOF;
}

?>
Rispondi citando
Rispondi

Strumenti discussione
Modalità visualizzazione

Regole di scrittura
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Attivato
Le faccine sono Attivato
Il codice [IMG] è Attivato
Il codice HTML è Disattivato
Trackbacks are Attivato
Pingbacks are Attivato
Refbacks are Attivato



Tutti gli orari sono GMT +1. Adesso sono le 22.54.12.


Powered by vBulletin versione 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0
Traduzione italiana : www.vbulletin.it