Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MaarchCourrier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maarch
MaarchCourrier
Commits
44b7895b
Commit
44b7895b
authored
6 years ago
by
Florian Azizian
Browse files
Options
Downloads
Patches
Plain Diff
FIX intall send email
parent
51252202
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
install/scripts/testSmtp.php
+58
-67
58 additions, 67 deletions
install/scripts/testSmtp.php
install/view/smtp_view.php
+56
-81
56 additions, 81 deletions
install/view/smtp_view.php
with
114 additions
and
148 deletions
install/scripts/testSmtp.php
+
58
−
67
View file @
44b7895b
...
...
@@ -6,7 +6,7 @@
new
\SrcCore\models\DatabasePDO
([
'customId'
=>
'cs_'
.
$_SESSION
[
'config'
][
'databasename'
]]);
if
(
!
empty
(
$pass
))
{
$pass
=
\SrcCore\models\PasswordModel
::
encrypt
([
'password'
=>
$pass
]);
$pass
=
\SrcCore\models\PasswordModel
::
encrypt
([
'password'
=>
$pass
]);
}
$data
=
[
...
...
@@ -73,73 +73,64 @@
exit
;
}
}
//if($_REQUEST['type']=='type'){}
include
(
$_SESSION
[
'config'
][
'corepath'
]
.
'/apps/maarch_entreprise/tools/mails/htmlMimeMail.php'
);
$email
=
$GLOBALS
[
'emails'
][
$currentEmail
];
$GLOBALS
[
'mailer'
]
=
new
htmlMimeMail
();
$GLOBALS
[
'mailer'
]
->
setSMTPParams
(
$host
=
$_REQUEST
[
'smtpHost'
],
$port
=
$_REQUEST
[
'smtpPort'
],
$helo
=
$_REQUEST
[
'smtpDomains'
],
$auth
=
filter_var
(
$_REQUEST
[
'smtpAuth'
],
FILTER_VALIDATE_BOOLEAN
),
$user
=
$_REQUEST
[
'smtpUser'
],
$pass
=
$_REQUEST
[
'smtpPassword'
],
$from
=
$_REQUEST
[
'smtpMailFrom'
]
);
$GLOBALS
[
'mailer'
]
->
setReturnPath
(
$email
->
sender
);
$GLOBALS
[
'mailer'
]
->
setFrom
(
$from
);
$GLOBALS
[
'mailer'
]
->
setSubject
(
"Test smtp Maarch"
);
$GLOBALS
[
'mailer'
]
->
setHtml
(
$email
->
html_body
);
$GLOBALS
[
'mailer'
]
->
setHtml
(
str_replace
(
'#and#'
,
'&'
,
$email
->
html_body
));
$GLOBALS
[
'mailer'
]
->
setTextCharset
(
"ceci est un mail de test"
);
$GLOBALS
[
'mailer'
]
->
setHtmlCharset
((
string
)
$email
->
charset
);
$GLOBALS
[
'mailer'
]
->
setHeadCharset
((
string
)
$email
->
charset
);
if
(
$_REQUEST
[
'type'
]
==
'test'
)
{
// var_dump($_REQUEST['smtpMailTo']);
// var_dump($_REQUEST['smtpType']);
$return
=
$GLOBALS
[
'mailer'
]
->
send
(
array
(
$_REQUEST
[
'smtpMailTo'
]),
$_REQUEST
[
'smtpType'
]);
if
(
$return
==
false
)
{
$return2
[
'status'
]
=
2
;
$return2
[
'text'
]
=
_SMTP_ERROR
;
$jsonReturn
=
json_encode
(
$return2
);
echo
$jsonReturn
;
exit
;
//echo("<p>" . $mail->getMessage() . "</p>");
}
else
{
require_once
'install/class/Class_Install.php'
;
setConfigSendmail_batch_config_Xml
(
$from
,
$to
,
$host
,
$user
,
$pass
,
$_REQUEST
[
'smtpType'
],
$port
,
$auth
,
$charset
,
$smtpSecure
,
$from
,
$_REQUEST
[
'smtpDomains'
]);
setConfigNotification_batch_config_Xml
(
$from
,
$to
,
$host
,
$user
,
$pass
,
$_REQUEST
[
'smtpType'
],
$port
,
$auth
,
$charset
,
$smtpSecure
,
$from
,
$_REQUEST
[
'smtpDomains'
]);
$return2
[
'status'
]
=
2
;
$return2
[
'text'
]
=
_SMTP_OK
;
$jsonReturn
=
json_encode
(
$return2
);
echo
$jsonReturn
;
exit
;
}
}
elseif
(
$_REQUEST
[
'type'
]
==
'add'
)
{
setConfigSendmail_batch_config_Xml
(
$from
,
$to
,
$host
,
$user
,
$pass
,
$_REQUEST
[
'smtpType'
],
$port
,
$auth
,
$charset
,
$smtpSecure
,
$from
,
$_REQUEST
[
'smtpDomains'
]);
setConfigNotification_batch_config_Xml
(
$from
,
$to
,
$host
,
$user
,
$pass
,
$_REQUEST
[
'smtpType'
],
$port
,
$auth
,
$charset
,
$smtpSecure
,
$from
,
$_REQUEST
[
'smtpDomains'
]);
$return2
[
'status'
]
=
2
;
$return2
[
'text'
]
=
_INFO_SMTP_OK
;
$jsonReturn
=
json_encode
(
$return2
);
echo
$jsonReturn
;
exit
;
}
$GLOBALS
[
'mailer'
]
=
new
htmlMimeMail
();
$GLOBALS
[
'mailer'
]
->
setSMTPParams
(
$host
=
$_REQUEST
[
'smtpHost'
],
$port
=
$_REQUEST
[
'smtpPort'
],
$helo
=
$_REQUEST
[
'smtpDomains'
],
$auth
=
filter_var
(
$_REQUEST
[
'smtpAuth'
],
FILTER_VALIDATE_BOOLEAN
),
$user
=
$_REQUEST
[
'smtpUser'
],
$pass
=
$_REQUEST
[
'smtpPassword'
],
$from
=
$_REQUEST
[
'smtpMailFrom'
]
);
$GLOBALS
[
'mailer'
]
->
setFrom
(
$from
);
$GLOBALS
[
'mailer'
]
->
setSubject
(
"Test smtp Maarch"
);
$GLOBALS
[
'mailer'
]
->
setHtml
(
"Ceci est un email de test"
);
$GLOBALS
[
'mailer'
]
->
setHtmlCharset
(
'utf-8'
);
$GLOBALS
[
'mailer'
]
->
setHeadCharset
(
'utf-8'
);
if
(
$_REQUEST
[
'type'
]
==
'test'
)
{
$return
=
$GLOBALS
[
'mailer'
]
->
send
(
array
(
$_REQUEST
[
'smtpMailTo'
]),
$_REQUEST
[
'smtpType'
]);
if
(
$return
==
false
)
{
$return2
[
'status'
]
=
2
;
$return2
[
'text'
]
=
_SMTP_ERROR
;
$jsonReturn
=
json_encode
(
$return2
);
echo
$jsonReturn
;
exit
;
}
else
{
require_once
'install/class/Class_Install.php'
;
setConfigSendmail_batch_config_Xml
(
$from
,
$to
,
$host
,
$user
,
$pass
,
$_REQUEST
[
'smtpType'
],
$port
,
$auth
,
$charset
,
$smtpSecure
,
$from
,
$_REQUEST
[
'smtpDomains'
]);
setConfigNotification_batch_config_Xml
(
$from
,
$to
,
$host
,
$user
,
$pass
,
$_REQUEST
[
'smtpType'
],
$port
,
$auth
,
$charset
,
$smtpSecure
,
$from
,
$_REQUEST
[
'smtpDomains'
]);
$return2
[
'status'
]
=
2
;
$return2
[
'text'
]
=
_SMTP_OK
;
$jsonReturn
=
json_encode
(
$return2
);
echo
$jsonReturn
;
exit
;
}
}
elseif
(
$_REQUEST
[
'type'
]
==
'add'
)
{
setConfigSendmail_batch_config_Xml
(
$from
,
$to
,
$host
,
$user
,
$pass
,
$_REQUEST
[
'smtpType'
],
$port
,
$auth
,
$charset
,
$smtpSecure
,
$from
,
$_REQUEST
[
'smtpDomains'
]);
setConfigNotification_batch_config_Xml
(
$from
,
$to
,
$host
,
$user
,
$pass
,
$_REQUEST
[
'smtpType'
],
$port
,
$auth
,
$charset
,
$smtpSecure
,
$from
,
$_REQUEST
[
'smtpDomains'
]);
$return2
[
'status'
]
=
2
;
$return2
[
'text'
]
=
_INFO_SMTP_OK
;
$jsonReturn
=
json_encode
(
$return2
);
echo
$jsonReturn
;
exit
;
}
This diff is collapsed.
Click to expand it.
install/view/smtp_view.php
+
56
−
81
View file @
44b7895b
...
...
@@ -28,12 +28,9 @@
* @ingroup install
*/
?>
<!--script type="text/javascript" src="js/prototype.js"></script-->
<script>
function
envoiMailTestSmtp
(
url
,
type
,
smtpHost
,
smtpType
,
smtpPort
,
smtpUser
,
smtpPassword
,
smtpAuth
,
smtpMailTo
,
smtpDomains
,
smtpMailFrom
){
//alert(type);
<script>
function
envoiMailTestSmtp
(
url
,
type
,
smtpHost
,
smtpType
,
smtpPort
,
smtpUser
,
smtpPassword
,
smtpAuth
,
smtpMailTo
,
smtpDomains
,
smtpMailFrom
)
{
$
(
document
).
ready
(
function
()
{
var
oneIsEmpty
=
false
;
if
(
smtpHost
.
length
<
1
)
{
...
...
@@ -45,12 +42,6 @@
if
(
smtpPort
.
length
<
1
)
{
var
oneIsEmpty
=
true
;
}
// if (smtpUser.length
<
1
)
{
// var oneIsEmpty = true;
// }
// if (smtpPassword.length
<
1
)
{
// var oneIsEmpty = true;
// }
if
(
smtpAuth
.
length
<
1
)
{
var
oneIsEmpty
=
true
;
}
...
...
@@ -65,37 +56,34 @@
$
(
'
#ajaxReturn_testConnect_ko
'
).
html
(
'
<?php
echo
_ONE_FIELD_EMPTY
;
?>
'
);
return
;
}
$
(
'
.wait
'
).
css
(
'
display
'
,
'
block
'
);
$
(
'
.wait
'
).
css
(
'
display
'
,
'
block
'
);
$
(
'
#ajaxReturn_testConnect_ko
'
).
html
(
''
);
ajaxDB
(
'
testSmtp
'
,
'
type|
'
+
type
+
'
|smtpHost|
'
+
smtpHost
+
'
|smtpType|
'
+
smtpType
+
'
|smtpPort|
'
+
smtpPort
+
'
|smtpUser|
'
+
smtpUser
+
'
|smtpPassword|
'
+
smtpPassword
+
'
|smtpAuth|
'
+
smtpAuth
+
'
|smtpMailTo|
'
+
smtpMailTo
+
'
|smtpDomains|
'
+
smtpDomains
+
'
|smtpMailFrom|
'
+
smtpMailFrom
,
'
type|
'
+
type
+
'
|smtpHost|
'
+
smtpHost
+
'
|smtpType|
'
+
smtpType
+
'
|smtpPort|
'
+
smtpPort
+
'
|smtpUser|
'
+
smtpUser
+
'
|smtpPassword|
'
+
smtpPassword
+
'
|smtpAuth|
'
+
smtpAuth
+
'
|smtpMailTo|
'
+
smtpMailTo
+
'
|smtpDomains|
'
+
smtpDomains
+
'
|smtpMailFrom|
'
+
smtpMailFrom
,
'
ajaxReturn_testConnect
'
,
'
false
'
);
if
(
!
oneIsEmpty
)
{
$
(
'
#ajaxReturn_testConnect_ok
'
).
html
(
'
<?php
echo
"connexion ok"
;
?>
'
);
$
(
'
.wait
'
).
css
(
'
display
'
,
'
none
'
);
return
;
}
});
}
</script>
<div
class=
"blockWrapper"
>
<div
class=
"titleBlock"
>
<h2
onClick=
"slide('configNotificationSendmail');"
style=
"cursor: pointer;"
>
...
...
@@ -117,45 +105,51 @@
:
</td>
<td>
<input
type=
"text"
name=
"smtpHost"
id=
"smtpHost"
value=
"ssl://smtp.yourdomain.com"
/>
<input
type=
"text"
name=
"smtpHost"
id=
"smtpHost"
value=
"ssl://smtp.yourdomain.com"
/>
</td>
<td>
<FONT
COLOR=
"#7F8FA6"
><i>
exemple: ssl://smtp.gmail.com; smtp2.example.com
</i></FONT>
</td>
<td><FONT
COLOR=
"#7F8FA6"
><i>
exemple: ssl://smtp.gmail.com; smtp2.example.com
</i></FONT></td>
</tr>
<tr>
<td>
<?php
echo
_SMTP_TYPE
;
?>
</td>
<td>
<?php
echo
_SMTP_TYPE
;
?>
</td>
<td>
:
</td>
<td>
<!--input type="text" name="smtpType" id="smtpType" value="smtp"/-->
<td>
<SELECT
name=
"smtpType"
id=
"smtpType"
>
<OPTION
selected
>
smtp
<OPTION>
sendmail
<OPTION>
mail
</SELECT>
</td>
<td><FONT
COLOR=
"#7F8FA6"
><i>
<?php
echo
_SENDER_TYPE
?>
</i></FONT></td>
<td>
<FONT
COLOR=
"#7F8FA6"
><i>
<?php
echo
_SENDER_TYPE
?>
</i></FONT>
</td>
</tr>
<tr>
<td>
<?php
echo
_SMTP_PORT
;
?>
</td>
<td>
<?php
echo
_SMTP_PORT
;
?>
</td>
<td>
:
</td>
<td><input
type=
"text"
name=
"smtpPort"
id=
"smtpPort"
value=
"465"
/></td>
<td><input
type=
"text"
name=
"smtpPort"
id=
"smtpPort"
value=
"465"
/></td>
</tr>
<tr>
<td>
<?php
echo
_SMTP_USER
;
?>
</td>
<td>
<?php
echo
_SMTP_USER
;
?>
</td>
<td>
:
</td>
<td><input
type=
"text"
name=
"smtpUser"
id=
"smtpUser"
value=
"server@yourdomain.com"
/></td>
<td><FONT
COLOR=
"#7F8FA6"
><i>
<?php
echo
_SMTP_USER_CONNECT
;
?>
</i></FONT></td>
<td><input
type=
"text"
name=
"smtpUser"
id=
"smtpUser"
value=
"server@yourdomain.com"
/></td>
<td>
<FONT
COLOR=
"#7F8FA6"
><i>
<?php
echo
_SMTP_USER_CONNECT
;
?>
</i></FONT>
</td>
</tr>
<tr>
<td>
<?php
echo
_SMTP_PASSWORD
;
?>
</td>
<td>
<?php
echo
_SMTP_PASSWORD
;
?>
</td>
<td>
:
</td>
<td><input
type=
"password"
name=
"smtpPassword"
id=
"smtpPassword"
value=
"password"
/></td>
<td><input
type=
"password"
name=
"smtpPassword"
id=
"smtpPassword"
value=
"password"
/></td>
</tr>
<!--tr>
<td>
<?php
echo
_SMTP_AUTH
;
?>
</td>
<td>:</td>
<td><input type="text" name="smtpAuth" id="smtpAuth" value="true or false"/></td>
</tr-->
<tr>
<td>
<?php
echo
_SMTP_AUTH
;
?>
</td>
<td>
<?php
echo
_SMTP_AUTH
;
?>
</td>
<td>
:
</td>
<td>
<SELECT
name=
"smtpAuth"
id=
"smtpAuth"
>
...
...
@@ -164,44 +158,41 @@
</SELECT>
</td>
</tr>
<!--tr>
<td>
<?php
echo
_SMTP_CHARSET
;
?>
</td>
<td>:</td>
<td><input type="text" name="smtpCharset" id="smtpCharset" value="utf-8"/></td>
</tr-->
<tr>
<td>
<?php
echo
_SMTP_DOMAINS
;
?>
</td>
<td>
<?php
echo
_SMTP_DOMAINS
;
?>
</td>
<td>
:
</td>
<td><input
type=
"text"
name=
"smtpDomains"
id=
"smtpDomains"
value=
"gmail"
/></td>
<td><input
type=
"text"
name=
"smtpDomains"
id=
"smtpDomains"
value=
"gmail"
/></td>
</tr>
<tr>
<td>
<?php
echo
_SMTP_MAILFROM
;
?>
</td>
<td>
<?php
echo
_SMTP_MAILFROM
;
?>
</td>
<td>
:
</td>
<td><input
type=
"text"
name=
"smtpMailFrom"
id=
"smtpMailFrom"
value=
"notifications@maarch.fr"
/></td>
<td><input
type=
"text"
name=
"smtpMailFrom"
id=
"smtpMailFrom"
value=
"notifications@maarch.fr"
/></td>
</tr>
<tr>
<td>
<?php
echo
_SMTP_MAILTO
;
?>
</td>
<td>
<?php
echo
_SMTP_MAILTO
;
?>
</td>
<td>
:
</td>
<td><input
type=
"text"
name=
"smtpMailTo"
id=
"smtpMailTo"
value=
"example@domain.com"
/></td>
<td><FONT
COLOR=
"#7F8FA6"
><i>
<?php
echo
_SMTP_MAILTO_BOX
;
?>
</i></FONT></td>
<td><input
type=
"text"
name=
"smtpMailTo"
id=
"smtpMailTo"
value=
"example@domain.com"
/></td>
<td>
<FONT
COLOR=
"#7F8FA6"
><i>
<?php
echo
_SMTP_MAILTO_BOX
;
?>
</i></FONT>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<input
type=
"button"
id=
"ajaxReturn_testConnect_button"
onClick=
"$('.wait').css('display','block');envoiMailTestSmtp( 'testSmtp','test', $('#smtpHost').val(), $('#smtpType').val(), $('#smtpPort').val(), $('#smtpUser').val(), $('#smtpPassword').val(), $('#smtpAuth').val(), $('#smtpMailTo').val(), $('#smtpDomains').val(), $('#smtpMailFrom').val());"
value=
"
<?php
echo
_VERIF_SMTP
;
?>
"
/>
<input
type=
"button"
id=
"ajaxReturn_testConnect_button"
onClick=
"$('.wait').css('display','block');envoiMailTestSmtp( 'testSmtp','test', $('#smtpHost').val(), $('#smtpType').val(), $('#smtpPort').val(), $('#smtpUser').val(), $('#smtpPassword').val(), $('#smtpAuth').val(), $('#smtpMailTo').val(), $('#smtpDomains').val(), $('#smtpMailFrom').val());"
value=
"
<?php
echo
_VERIF_SMTP
;
?>
"
/>
</td>
<!-- <td>
<input type="button" id="ajaxReturn_testConnect_button" onClick="$('.wait').css('display','block');envoiMailTestSmtp( 'testSmtp','add', $('#smtpHost').val(), $('#smtpType').val(), $('#smtpPort').val(), $('#smtpUser').val(), $('#smtpPassword').val(), $('#smtpAuth').val(), $('#smtpMailTo').val(), $('#smtpDomains').val(), $('#smtpMailFrom').val());" value="
<?php
echo
_ADD_INFO_SMTP
;
?>
"/>
</td> -->
</tr>
</table>
</form>
<br
/>
<div
id=
"ajaxReturn_testConnect_ko"
></div>
<div
align=
"center"
>
<img
src=
"img/wait.gif"
width=
"100"
class=
"wait"
style=
"display: none; background-color: rgba(0, 0, 0, 0.2);"
/>
<img
src=
"img/wait.gif"
width=
"100"
class=
"wait"
style=
"display: none; background-color: rgba(0, 0, 0, 0.2);"
/>
</div>
<div
id=
"ajaxReturn_testConnect_ok"
></div>
</p>
...
...
@@ -212,31 +203,15 @@
<div
class=
"contentBlock"
id=
"docservers"
>
<p>
<div
id=
"buttons"
>
<!--div style="float: left;" class="previousButton" id="previous">
<a href="#" onClick="goTo('index.php?step=docservers');" style="display:none;">
<?php
echo
_PREVIOUS
;
?>
</a>
</div-->
<!--div style="float: left;" class="previousButton" id="next">
<a href="#" onClick="goTo('index.php?step=password');" id="ajaxReturn_testConnect" >
<?php
echo
"Sauter étape"
;
?>
</a>
</div-->
<!--div style="float: right;" class="nextButton" id="next">
<a href="#" onClick="goTo('index.php?step=password');" id="ajaxReturn_testConnect">
<?php
echo
_NEXT
;
?>
</a>
</div-->
<div
style=
"float: right;"
class=
"nextButton"
id=
"next"
>
<a
href=
"#"
onClick=
"envoiMailTestSmtp( 'testSmtp','add', $('#smtpHost').val(), $('#smtpType').val(), $('#smtpPort').val(), $('#smtpUser').val(), $('#smtpPassword').val(), $('#smtpAuth').val(), $('#smtpMailTo').val(), $('#smtpDomains').val(), $('#smtpMailFrom').val());goTo('index.php?step=password');"
>
<a
href=
"#"
onClick=
"envoiMailTestSmtp( 'testSmtp','add', $('#smtpHost').val(), $('#smtpType').val(), $('#smtpPort').val(), $('#smtpUser').val(), $('#smtpPassword').val(), $('#smtpAuth').val(), $('#smtpMailTo').val(), $('#smtpDomains').val(), $('#smtpMailFrom').val());goTo('index.php?step=password');"
>
<?php
echo
_NEXT_INSTALL
;
?>
</a>
</div>
</div>
<br
/>
<br
/>
</p>
</div>
</div>
</div>
\ No newline at end of file
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