Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
372ecf4e
Commit
372ecf4e
authored
15 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Fix: Use of other field in mailing-send
parent
db74ace6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/emailings/mailing-prepare.php
+21
-39
21 additions, 39 deletions
scripts/emailings/mailing-prepare.php
scripts/emailings/mailing-send.php
+74
-74
74 additions, 74 deletions
scripts/emailings/mailing-send.php
with
95 additions
and
113 deletions
scripts/emailings/mailing-prepare.php
+
21
−
39
View file @
372ecf4e
...
...
@@ -14,32 +14,14 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*
* Export simple des contacts
*
* L'utilisation d'adresses de courriers électroniques dans les opérations
* de prospection commerciale est subordonnée au recueil du consentement
* préalable des personnes concernées.
*
* Le dispositif juridique applicable a été introduit par l'article 22 de
* la loi du 21 juin 2004 pour la confiance dans l'économie numérique.
*
* Les dispositions applicables sont définies par les articles L. 34-5 du
* code des postes et des télécommunications et L. 121-20-5 du code de la
* consommation. L'application du principe du consentement préalable en
* droit français résulte de la transposition de l'article 13 de la Directive
* européenne du 12 juillet 2002 « Vie privée et communications électroniques ».
*/
/**
\file scripts/mailing/mailing-prepare.php
\ingroup mailing
\brief Script pour préparer les destinataires d'un mailing
*/
* \file scripts/emailing/mailing-prepare.php
* \ingroup mailing
* \brief Script pour preparer les destinataires d'un mailing
* \version $Id$
*/
require_once
(
"../../htdocs/master.inc.php"
);
...
...
@@ -49,28 +31,28 @@ $sql = "SELECT m.rowid, m.cible";
$sql
.
=
" FROM "
.
MAIN_DB_PREFIX
.
"mailing as m"
;
$sql
.
=
" WHERE m.statut in (0,1)"
;
if
(
$db
->
query
(
$sql
)
)
if
(
$db
->
query
(
$sql
)
)
{
$num
=
$db
->
num_rows
();
$i
=
0
;
while
(
$i
<
$num
)
{
$row
=
$db
->
fetch_row
();
$num
=
$db
->
num_rows
();
$i
=
0
;
while
(
$i
<
$num
)
{
$row
=
$db
->
fetch_row
();
dol_syslog
(
"mailing-prepare: mailing
$row[0]
"
);
dol_syslog
(
"mailing-prepare: mailing module
$row[1]
"
);
dol_syslog
(
"mailing-prepare: mailing
$row[0]
"
);
dol_syslog
(
"mailing-prepare: mailing module
$row[1]
"
);
require_once
(
DOL_DOCUMENT_ROOT
.
'/includes/modules/mailings/'
.
$row
[
1
]
.
'.modules.php'
);
require_once
(
DOL_DOCUMENT_ROOT
.
'/includes/modules/
mailing
s/'
.
$row
[
1
]
.
'.modules.php'
)
;
$classname
=
"
mailing
_"
.
$row
[
1
];
$classname
=
"mailing_"
.
$row
[
1
];
$obj
=
new
$classname
(
$db
);
$obj
->
add_to_target
(
$row
[
0
]);
$obj
=
new
$classname
(
$db
);
$obj
->
add_to_target
(
$row
[
0
]);
$i
++
;
$i
++
;
}
}
}
?>
This diff is collapsed.
Click to expand it.
scripts/emailings/mailing-send.php
+
74
−
74
View file @
372ecf4e
...
...
@@ -20,7 +20,7 @@
/**
* \file scripts/mailing/mailing-send.php
* \file scripts/
e
mailing
s
/mailing-send.php
* \ingroup mailing
* \brief Script d'envoi d'un mailing prepare et valide
* \version $Id$
...
...
@@ -30,13 +30,13 @@
// Test if CLI mode
$sapi_type
=
php_sapi_name
();
if
(
substr
(
$sapi_type
,
0
,
3
)
==
'cgi'
)
{
echo
"Error: You are using PH for CGI/Web. To execute "
.
$script_file
.
" from command line, you must use PHP for CLI mode.
\n
"
;
exit
;
echo
"Error: You are using PH for CGI/Web. To execute "
.
$script_file
.
" from command line, you must use PHP for CLI mode.
\n
"
;
exit
;
}
if
(
!
isset
(
$argv
[
1
])
||
!
$argv
[
1
])
{
print
"Usage: mailing-send.php ID_MAILING
\n
"
;
exit
;
print
"Usage: mailing-send.php ID_MAILING
\n
"
;
exit
;
}
$id
=
$argv
[
1
];
...
...
@@ -91,37 +91,37 @@ $nbok=0; $nbko=0;
// On choisit les mails non deja envoyes pour ce mailing (statut=0)
// ou envoyes en erreur (statut=-1)
$sql
=
"SELECT mc.rowid, mc.nom, mc.prenom, mc.email"
;
$sql
=
"SELECT mc.rowid, mc.nom, mc.prenom, mc.email
, mc.other
"
;
$sql
.
=
" FROM "
.
MAIN_DB_PREFIX
.
"mailing_cibles as mc"
;
$sql
.
=
" WHERE mc.statut < 1 AND mc.fk_mailing = "
.
$id
;
$resql
=
$db
->
query
(
$sql
);
if
(
$resql
)
{
$num
=
$db
->
num_rows
(
$resql
);
$num
=
$db
->
num_rows
(
$resql
);
if
(
$num
)
{
dol_syslog
(
"mailing-send: nb of targets = "
.
$num
,
LOG_DEBUG
);
if
(
$num
)
{
dol_syslog
(
"mailing-send: nb of targets = "
.
$num
,
LOG_DEBUG
);
// Positionne date debut envoi
$sql
=
"UPDATE "
.
MAIN_DB_PREFIX
.
"mailing SET date_envoi=SYSDATE() WHERE rowid="
.
$id
;
$resql2
=
$db
->
query
(
$sql
);
if
(
!
$resql2
)
{
dol_print_error
(
$db
);
}
// Positionne date debut envoi
$sql
=
"UPDATE "
.
MAIN_DB_PREFIX
.
"mailing SET date_envoi=SYSDATE() WHERE rowid="
.
$id
;
$resql2
=
$db
->
query
(
$sql
);
if
(
!
$resql2
)
{
dol_print_error
(
$db
);
}
// Boucle sur chaque adresse et envoie le mail
$i
=
0
;
while
(
$i
<
$num
)
{
$res
=
1
;
// Boucle sur chaque adresse et envoie le mail
$i
=
0
;
while
(
$i
<
$num
)
{
$res
=
1
;
$obj
=
$db
->
fetch_object
(
$resql
);
$obj
=
$db
->
fetch_object
(
$resql
);
// sendto en RFC2822
$sendto
=
eregi_replace
(
','
,
' '
,
$obj
->
prenom
.
" "
.
$obj
->
nom
)
.
" <"
.
$obj
->
email
.
">"
;
// sendto en RFC2822
$sendto
=
eregi_replace
(
','
,
' '
,
$obj
->
prenom
.
" "
.
$obj
->
nom
)
.
" <"
.
$obj
->
email
.
">"
;
// Make subtsitutions on topic and body
$other
=
split
(
';'
,
$obj
->
other
);
...
...
@@ -146,9 +146,9 @@ if ($resql)
$newsubject
=
make_substitutions
(
$subject
,
$substitutionarray
);
$newmessage
=
make_substitutions
(
$message
,
$substitutionarray
);
// Fabrication du mail
$mail
=
new
CMailFile
(
$newsubject
,
$sendto
,
$from
,
$newmessage
,
array
(),
array
(),
array
(),
// Fabrication du mail
$mail
=
new
CMailFile
(
$newsubject
,
$sendto
,
$from
,
$newmessage
,
array
(),
array
(),
array
(),
''
,
''
,
0
,
$msgishtml
,
$errorsto
);
if
(
$mail
->
error
)
...
...
@@ -161,63 +161,63 @@ if ($resql)
$res
=
0
;
}
// Send Email
// Send Email
if
(
$res
)
{
$res
=
$mail
->
sendfile
();
$res
=
$mail
->
sendfile
();
}
if
(
$res
)
{
// Mail successful
$nbok
++
;
if
(
$res
)
{
// Mail successful
$nbok
++
;
dol_syslog
(
"mailing-send: ok for #"
.
$i
.
(
$mail
->
error
?
' - '
.
$mail
->
error
:
''
),
LOG_DEBUG
);
dol_syslog
(
"mailing-send: ok for #"
.
$i
.
(
$mail
->
error
?
' - '
.
$mail
->
error
:
''
),
LOG_DEBUG
);
$sql
=
"UPDATE "
.
MAIN_DB_PREFIX
.
"mailing_cibles"
;
$sql
=
"UPDATE "
.
MAIN_DB_PREFIX
.
"mailing_cibles"
;
$sql
.
=
" SET statut=1, date_envoi=SYSDATE() WHERE rowid="
.
$obj
->
rowid
;
$resql2
=
$db
->
query
(
$sql
);
if
(
!
$resql2
)
{
dol_print_error
(
$db
);
}
}
else
{
// Mail failed
$nbko
++
;
dol_syslog
(
"mailing-send: error for #"
.
$i
.
(
$mail
->
error
?
' - '
.
$mail
->
error
:
''
),
LOG_DEBUG
);
$sql
=
"UPDATE "
.
MAIN_DB_PREFIX
.
"mailing_cibles"
;
$resql2
=
$db
->
query
(
$sql
);
if
(
!
$resql2
)
{
dol_print_error
(
$db
);
}
}
else
{
// Mail failed
$nbko
++
;
dol_syslog
(
"mailing-send: error for #"
.
$i
.
(
$mail
->
error
?
' - '
.
$mail
->
error
:
''
),
LOG_DEBUG
);
$sql
=
"UPDATE "
.
MAIN_DB_PREFIX
.
"mailing_cibles"
;
$sql
.
=
" SET statut=-1, date_envoi=SYSDATE() WHERE rowid="
.
$obj
->
rowid
;
$resql2
=
$db
->
query
(
$sql
);
if
(
!
$resql2
)
{
dol_print_error
(
$db
);
}
}
$i
++
;
}
}
// Loop finished, set global statut of mail
$statut
=
2
;
if
(
!
$nbko
)
$statut
=
3
;
$sql
=
"UPDATE "
.
MAIN_DB_PREFIX
.
"mailing SET statut="
.
$statut
.
" WHERE rowid="
.
$id
;
dol_syslog
(
"mailing-send: update global status sql="
.
$sql
,
LOG_DEBUG
);
$resql2
=
$db
->
query
(
$sql
);
if
(
!
$resql2
)
{
dol_print_error
(
$db
);
}
$resql2
=
$db
->
query
(
$sql
);
if
(
!
$resql2
)
{
dol_print_error
(
$db
);
}
}
$i
++
;
}
}
// Loop finished, set global statut of mail
$statut
=
2
;
if
(
!
$nbko
)
$statut
=
3
;
$sql
=
"UPDATE "
.
MAIN_DB_PREFIX
.
"mailing SET statut="
.
$statut
.
" WHERE rowid="
.
$id
;
dol_syslog
(
"mailing-send: update global status sql="
.
$sql
,
LOG_DEBUG
);
$resql2
=
$db
->
query
(
$sql
);
if
(
!
$resql2
)
{
dol_print_error
(
$db
);
}
}
else
{
dol_syslog
(
$db
->
error
());
dol_print_error
(
$db
);
dol_syslog
(
$db
->
error
());
dol_print_error
(
$db
);
}
?>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment