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
842d2409
Commit
842d2409
authored
15 years ago
by
Regis Houssin
Browse files
Options
Downloads
Patches
Plain Diff
Add: build style css in mail
parent
59920dc6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
htdocs/comm/mailing/fiche.php
+6
-2
6 additions, 2 deletions
htdocs/comm/mailing/fiche.php
htdocs/lib/CMailFile.class.php
+48
-38
48 additions, 38 deletions
htdocs/lib/CMailFile.class.php
with
54 additions
and
40 deletions
htdocs/comm/mailing/fiche.php
+
6
−
2
View file @
842d2409
...
...
@@ -288,6 +288,11 @@ if ($_POST["action"] == 'send' && ! $_POST["cancel"])
$arr_file
=
array
();
$arr_mime
=
array
();
$arr_name
=
array
();
$arr_css
=
array
();
// Ajout CSS
if
(
!
empty
(
$mil
->
bgcolor
))
$arr_css
[
'bgcolor'
]
=
$mil
->
bgcolor
;
if
(
!
empty
(
$mil
->
bgimage
))
$arr_css
[
'bgimage'
]
=
$mil
->
bgimage
;
// Le message est-il en html
$msgishtml
=-
1
;
// Inconnu par defaut
...
...
@@ -298,8 +303,7 @@ if ($_POST["action"] == 'send' && ! $_POST["cancel"])
$mil
->
body
=
make_substitutions
(
$mil
->
body
,
$substitutionarrayfortest
);
$mailfile
=
new
CMailFile
(
$mil
->
sujet
,
$mil
->
sendto
,
$mil
->
email_from
,
$mil
->
body
,
$arr_file
,
$arr_mime
,
$arr_name
,
''
,
''
,
0
,
$msgishtml
);
$arr_file
,
$arr_mime
,
$arr_name
,
''
,
''
,
0
,
$msgishtml
,
''
,
$arr_css
);
$result
=
$mailfile
->
sendfile
();
if
(
$result
)
...
...
This diff is collapsed.
Click to expand it.
htdocs/lib/CMailFile.class.php
+
48
−
38
View file @
842d2409
...
...
@@ -60,6 +60,10 @@ class CMailFile
var
$sName
;
var
$sEmail
;
//CSS
var
$css
;
var
$styleCSS
;
// Image
var
$html
;
var
$image_boundary
;
...
...
@@ -87,12 +91,14 @@ class CMailFile
* \param mimefilename_list List of attached file name in message
* \param addr_cc Email cc
* \param addr_bcc Email bcc
* \param deliveryreceipt Ask a delivery receipt
* \param msgishtml 1=String IS already html, 0=String IS NOT html, -1=Unknown need autodetection
* \param deliveryreceipt Ask a delivery receipt
* \param msgishtml 1=String IS already html, 0=String IS NOT html, -1=Unknown need autodetection
* \param error_to Email errors
* \param css Css option
*/
function
CMailFile
(
$subject
,
$to
,
$from
,
$msg
,
$filename_list
=
array
(),
$mimetype_list
=
array
(),
$mimefilename_list
=
array
(),
$addr_cc
=
""
,
$addr_bcc
=
""
,
$deliveryreceipt
=
0
,
$msgishtml
=
0
,
$errors_to
=
''
)
$addr_cc
=
""
,
$addr_bcc
=
""
,
$deliveryreceipt
=
0
,
$msgishtml
=
0
,
$errors_to
=
''
,
$css
=
''
)
{
global
$conf
;
...
...
@@ -270,7 +276,13 @@ class CMailFile
if
(
$this
->
msgishtml
)
{
if
(
!
empty
(
$this
->
html
))
{
{
if
(
!
empty
(
$css
))
{
$this
->
css
=
$css
;
$this
->
styleCSS
=
$this
->
buildCSS
();
}
$msg
=
$this
->
html
;
$msg
=
$this
->
checkIfHTML
(
$msg
);
...
...
@@ -315,9 +327,13 @@ class CMailFile
$smtps
->
setTO
(
$this
->
getValidAddress
(
$to
,
2
));
$smtps
->
setFrom
(
$from
);
//if ($this->atleastoneimage) $msg = $this->html;
if
(
!
empty
(
$this
->
html
))
{
if
(
!
empty
(
$css
))
{
$this
->
css
=
$css
;
$this
->
styleCSS
=
$this
->
buildCSS
();
}
$msg
=
$this
->
html
;
$msg
=
$this
->
checkIfHTML
(
$msg
);
}
...
...
@@ -639,8 +655,6 @@ class CMailFile
$out
=
''
;
// if ($this->atleastonefile || $this->atleastoneimage)
// {
if
(
$this
->
msgishtml
)
{
$out
.
=
"--"
.
$this
->
mime_boundary
.
$this
->
eol
;
...
...
@@ -652,39 +666,23 @@ class CMailFile
$out
.
=
"Content-Type: text/plain; charset=
\"
"
.
$conf
->
file
->
character_set_client
.
"
\"
"
.
$this
->
eol
;
}
$out
.
=
$this
->
eol
;
// }
if
(
$this
->
msgishtml
)
{
// Check if html header already in message
$strContent
=
$this
->
checkIfHTML
(
$msgtext
);
/*if ($this->atleastonefile || $this->atleastoneimage)
{
if ($this->atleastonefile && $this->atleastoneimage)
{
$out.= $this->eol . "--" . $this->related_boundary . $this->eol;
}
else
{
$out.= $this->eol . "--" . $this->mime_boundary . $this->eol;
}
}*/
}
else
{
$strContent
.
=
$msgtext
;
/* if ($this->atleastonefile || $this->atleastoneimage)
{
$out.= $this->eol . "--" . $this->mime_boundary . $this->eol;
}*/
}
// Make RFC821 Compliant, replace bare linefeeds
$strContent
=
preg_replace
(
"/(?<!
\r
)
\n
/si"
,
"
\r\n
"
,
$strContent
);
$strContent
=
preg_replace
(
"/(?<!
\r
)
\n
/si"
,
"
\r\n
"
,
$strContent
);
$strContent
=
rtrim
(
wordwrap
(
$strContent
));
$strContent
=
rtrim
(
wordwrap
(
$strContent
));
$out
.
=
$strContent
.
$this
->
eol
;
$out
.
=
$strContent
.
$this
->
eol
;
return
$out
;
}
...
...
@@ -695,12 +693,12 @@ class CMailFile
* @param unknown_type $msg
* @return unknown
*/
function
checkIfHTML
(
$msg
,
$css
=
''
)
function
checkIfHTML
(
$msg
)
{
if
(
!
eregi
(
'^[ \t]*<html'
,
$msg
))
{
$out
=
"<html><head><title></title>"
;
if
(
!
empty
(
$
css
))
$out
.
=
$css
;
if
(
!
empty
(
$
this
->
styleCSS
))
$out
.
=
$this
->
styleCSS
;
$out
.
=
"</head><body>"
;
$out
.
=
$msg
;
$out
.
=
"</body></html>"
;
...
...
@@ -716,18 +714,30 @@ class CMailFile
/**
* Build a css style
*
* @param $value
* @return css
*/
function
buildCSS
(
$value
)
function
buildCSS
()
{
// Todo: finir la construction
$out
=
'<style type="text/css">'
.
'body {'
.
' background-image: url("cid:'
.
$bg
.
'");'
.
'}'
.
'</style>'
;
$out
=
''
;
if
(
!
empty
(
$this
->
css
))
{
$out
.
=
'<style type="text/css">'
;
$out
.
=
'body {'
;
if
(
$this
->
css
[
'bgcolor'
])
{
$out
.
=
' background-color: '
.
$this
->
css
[
'bgcolor'
]
.
';'
;
}
if
(
$this
->
css
[
'bgimage'
])
{
// Todo: rcuprer cid
$out
.
=
' background-image: url("cid:'
.
$this
->
css
[
'bgimage_cid'
]
.
'");'
;
}
$out
.
=
'}'
;
$out
.
=
'</style>'
;
}
return
$out
;
}
...
...
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