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
1e8b148e
Commit
1e8b148e
authored
9 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Work on tracking id into emails
parent
c89c89c7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
htdocs/core/actions_sendmails.inc.php
+4
-2
4 additions, 2 deletions
htdocs/core/actions_sendmails.inc.php
htdocs/core/class/CMailFile.class.php
+25
-7
25 additions, 7 deletions
htdocs/core/class/CMailFile.class.php
htdocs/core/class/smtps.class.php
+40
-7
40 additions, 7 deletions
htdocs/core/class/smtps.class.php
with
69 additions
and
16 deletions
htdocs/core/actions_sendmails.inc.php
+
4
−
2
View file @
1e8b148e
...
...
@@ -22,7 +22,7 @@
*/
// TODO Include this include file into all
class objects
// TODO Include this include file into all
element pages allowing email sending
// $id must be defined
// $actiontypecode must be defined
...
...
@@ -161,9 +161,11 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$filename
=
$attachedfiles
[
'names'
];
$mimetype
=
$attachedfiles
[
'mimes'
];
$trackid
=
GETPOST
(
'trackid'
,
'aZ'
);
// Send mail
require_once
DOL_DOCUMENT_ROOT
.
'/core/class/CMailFile.class.php'
;
$mailfile
=
new
CMailFile
(
$subject
,
$sendto
,
$from
,
$message
,
$filepath
,
$mimetype
,
$filename
,
$sendtocc
,
$sendtobcc
,
$deliveryreceipt
,
-
1
);
$mailfile
=
new
CMailFile
(
$subject
,
$sendto
,
$from
,
$message
,
$filepath
,
$mimetype
,
$filename
,
$sendtocc
,
$sendtobcc
,
$deliveryreceipt
,
-
1
,
''
,
''
,
$trackid
);
if
(
$mailfile
->
error
)
{
$mesgs
[]
=
'<div class="error">'
.
$mailfile
->
error
.
'</div>'
;
...
...
This diff is collapsed.
Click to expand it.
htdocs/core/class/CMailFile.class.php
+
25
−
7
View file @
1e8b148e
...
...
@@ -4,7 +4,7 @@
* Copyright (C) Eric Seigne
* Copyright (C) 2000-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-201
2
Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-201
5
Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -31,7 +31,7 @@
/**
* Class to send emails (with attachments or not)
* Usage: $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to);
* Usage: $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to
,$css,$trackid
);
* $mailfile->sendfile();
*/
class
CMailFile
...
...
@@ -45,6 +45,7 @@ class CMailFile
var
$addr_to
;
var
$addr_cc
;
var
$addr_bcc
;
var
$trackid
;
var
$mixed_boundary
;
var
$related_boundary
;
...
...
@@ -65,6 +66,9 @@ class CMailFile
//! Defined background directly in body tag
var
$bodyCSS
;
var
$headers
;
var
$message
;
// Image
var
$html
;
var
$image_boundary
;
...
...
@@ -95,10 +99,11 @@ class CMailFile
* @param string $addr_bcc Email bcc (Note: This is autocompleted with MAIN_MAIL_AUTOCOPY_TO if defined)
* @param int $deliveryreceipt Ask a delivery receipt
* @param int $msgishtml 1=String IS already html, 0=String IS NOT html, -1=Unknown make autodetection (with fast mode, not reliable)
* @param string $errors_to Email errors
* @param string $errors_to Email
for
errors
-to
* @param string $css Css option
* @param string $trackid Tracking string
*/
function
__construct
(
$subject
,
$to
,
$from
,
$msg
,
$filename_list
=
array
(),
$mimetype_list
=
array
(),
$mimefilename_list
=
array
(),
$addr_cc
=
""
,
$addr_bcc
=
""
,
$deliveryreceipt
=
0
,
$msgishtml
=
0
,
$errors_to
=
''
,
$css
=
''
)
function
__construct
(
$subject
,
$to
,
$from
,
$msg
,
$filename_list
=
array
(),
$mimetype_list
=
array
(),
$mimefilename_list
=
array
(),
$addr_cc
=
""
,
$addr_bcc
=
""
,
$deliveryreceipt
=
0
,
$msgishtml
=
0
,
$errors_to
=
''
,
$css
=
''
,
$trackid
=
''
)
{
global
$conf
;
...
...
@@ -124,7 +129,7 @@ class CMailFile
// If ending method not defined
if
(
empty
(
$conf
->
global
->
MAIN_MAIL_SENDMODE
))
$conf
->
global
->
MAIN_MAIL_SENDMODE
=
'mail'
;
dol_syslog
(
"CMailFile::CMailfile: MAIN_MAIL_SENDMODE="
.
$conf
->
global
->
MAIN_MAIL_SENDMODE
.
" charset="
.
$conf
->
file
->
character_set_client
.
" from=
$from
, to=
$to
, addr_cc=
$addr_cc
, addr_bcc=
$addr_bcc
, errors_to=
$errors_to
"
,
LOG_DEBUG
);
dol_syslog
(
"CMailFile::CMailfile: MAIN_MAIL_SENDMODE="
.
$conf
->
global
->
MAIN_MAIL_SENDMODE
.
" charset="
.
$conf
->
file
->
character_set_client
.
" from=
$from
, to=
$to
, addr_cc=
$addr_cc
, addr_bcc=
$addr_bcc
, errors_to=
$errors_to
, trackid=
$trackid
"
,
LOG_DEBUG
);
dol_syslog
(
"CMailFile::CMailfile: subject=
$subject
, deliveryreceipt=
$deliveryreceipt
, msgishtml=
$msgishtml
"
,
LOG_DEBUG
);
// Detect if message is HTML (use fast method)
...
...
@@ -190,6 +195,7 @@ class CMailFile
$this
->
addr_cc
=
$addr_cc
;
$this
->
addr_bcc
=
$addr_bcc
;
$this
->
deliveryreceipt
=
$deliveryreceipt
;
$this
->
trackid
=
$trackid
;
$smtp_headers
=
$this
->
write_smtpheaders
();
// Define mime_headers
...
...
@@ -249,6 +255,7 @@ class CMailFile
$smtps
->
setSubject
(
$this
->
encodetorfc2822
(
$subject
));
$smtps
->
setTO
(
$this
->
getValidAddress
(
$to
,
0
,
1
));
$smtps
->
setFrom
(
$this
->
getValidAddress
(
$from
,
0
,
1
));
$smtps
->
setTrackId
(
$trackid
);
if
(
!
empty
(
$this
->
html
))
{
...
...
@@ -301,6 +308,7 @@ class CMailFile
$this
->
phpmailer
->
Subject
(
$this
->
encodetorfc2822
(
$subject
));
$this
->
phpmailer
->
setTO
(
$this
->
getValidAddress
(
$to
,
0
,
1
));
$this
->
phpmailer
->
SetFrom
(
$this
->
getValidAddress
(
$from
,
0
,
1
));
// TODO Add trackid into smtp header
if
(
!
empty
(
$this
->
html
))
{
...
...
@@ -516,7 +524,7 @@ class CMailFile
/**
* Encode subject according to RFC 2822 - http://en.wikipedia.org/wiki/MIME#Encoded-Word
*
*
* @param string $stringtoencode String to encode
* @return string string encoded
*/
...
...
@@ -674,7 +682,17 @@ class CMailFile
//$out.= "X-Priority: 3".$this->eol2;
$out
.
=
'Date: '
.
date
(
"r"
)
.
$this
->
eol2
;
$out
.
=
'Message-ID: <'
.
time
()
.
'.phpmail@'
.
$host
.
">"
.
$this
->
eol2
;
$trackid
=
$this
->
trackid
;
if
(
$trackid
)
{
$out
.
=
'Message-ID: <'
.
time
()
.
'.phpmail-'
.
$trackid
.
'@'
.
$host
.
">"
.
$this
->
eol2
;
$out
.
=
'references: <'
.
time
()
.
'.phpmail-'
.
$trackid
.
'@'
.
$host
.
">"
.
$this
->
eol2
;
}
else
{
$out
.
=
'Message-ID: <'
.
time
()
.
'.phpmail@'
.
$host
.
">"
.
$this
->
eol2
;
}
$out
.
=
"X-Mailer: Dolibarr version "
.
DOL_VERSION
.
" (using php mail)"
.
$this
->
eol2
;
$out
.
=
"Mime-Version: 1.0"
.
$this
->
eol2
;
...
...
This diff is collapsed.
Click to expand it.
htdocs/core/class/smtps.class.php
+
40
−
7
View file @
1e8b148e
<?php
/*
* Copyright (C) Walter Torres <walter@torres.ws> [with a *lot* of help!]
* Copyright (C) 2005-201
2
Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-201
5
Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2011 Regis Houssin
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -224,7 +224,7 @@ class SMTPs
var
$log
=
''
;
var
$_errorsTo
=
''
;
var
$_deliveryReceipt
=
0
;
var
$_trackId
=
''
;
/**
...
...
@@ -248,6 +248,27 @@ class SMTPs
return
$this
->
_deliveryReceipt
;
}
/**
* Set trackid
*
* @param string $_val Value
* @return void
*/
function
setTrackId
(
$_val
=
''
)
{
$this
->
_trackId
=
$_val
;
}
/**
* get trackid
*
* @return string Delivery receipt
*/
function
getTrackId
()
{
return
$this
->
_trackId
;
}
/**
* Set errors to
*
...
...
@@ -1106,11 +1127,23 @@ class SMTPs
$host
=
preg_replace
(
'@ssl://@i'
,
''
,
$host
);
// Remove prefix
//NOTE: Message-ID should probably contain the username of the user who sent the msg
$_header
.
=
'Subject: '
.
$this
->
getSubject
()
.
"
\r\n
"
.
'Date: '
.
date
(
"r"
)
.
"
\r\n
"
.
'Message-ID: <'
.
time
()
.
'.SMTPs@'
.
$host
.
">
\r\n
"
;
// . 'Read-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n"
// . 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n";
$_header
.
=
'Subject: '
.
$this
->
getSubject
()
.
"
\r\n
"
;
$_header
.
=
'Date: '
.
date
(
"r"
)
.
"
\r\n
"
;
$trackid
=
$this
->
getTrackId
();
if
(
$trackid
)
{
$_header
.
=
'Message-ID: <'
.
time
()
.
'.SMTPs-'
.
$trackid
.
'@'
.
$host
.
">
\r\n
"
;
$_header
.
=
'references: <'
.
time
()
.
'.SMTPs-'
.
$trackid
.
'@'
.
$host
.
">
\r\n
"
;
}
else
{
$_header
.
=
'Message-ID: <'
.
time
()
.
'.SMTPs@'
.
$host
.
">
\r\n
"
;
}
//$_header .=
// 'Read-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n"
// 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n";
if
(
$this
->
getSensitivity
()
)
$_header
.
=
'Sensitivity: '
.
$this
->
getSensitivity
()
.
"
\r\n
"
;
...
...
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