diff --git a/src/app/configuration/controllers/ConfigurationController.php b/src/app/configuration/controllers/ConfigurationController.php index 9aae22c362560ead2eec848fff3b3aff2a4694b7..97c4d2fa94d285d33fb7c63b8a8816f3dcb3467a 100755 --- a/src/app/configuration/controllers/ConfigurationController.php +++ b/src/app/configuration/controllers/ConfigurationController.php @@ -83,7 +83,7 @@ class ConfigurationController return ['errors' => 'Configuration type is missing', 'code' => 400]; } - if ($aArgs['type'] == 'smtp') { + if (in_array($aArgs['type'], ['smtp', 'mail'])) { $check = Validator::stringType()->notEmpty()->validate($aArgs['host']); $check = $check && Validator::intVal()->notEmpty()->validate($aArgs['port']); $check = $check && Validator::boolType()->validate($aArgs['auth']); @@ -94,7 +94,7 @@ class ConfigurationController $check = $check && Validator::stringType()->validate($aArgs['secure']); $check = $check && Validator::stringType()->validate($aArgs['from']); if (!$check) { - return ['errors' => "smtp configuration data is missing or not well formatted", 'code' => 400]; + return ['errors' => "Configuration data is missing or not well formatted", 'code' => 400]; } } diff --git a/src/app/email/controllers/EmailController.php b/src/app/email/controllers/EmailController.php index f261d078e159d40d682849e1e3f8d2d50705c969..5ae418b5e4f17b7ca5b2f36de23229d9b9e4fe29 100644 --- a/src/app/email/controllers/EmailController.php +++ b/src/app/email/controllers/EmailController.php @@ -247,8 +247,13 @@ class EmailController $phpmailer = new PHPMailer(); - if ($configuration['type'] == 'smtp') { - $phpmailer->isSMTP(); + if (in_array($configuration['type'], ['smtp', 'mail'])) { + if ($configuration['type'] == 'smtp') { + $phpmailer->isSMTP(); + } elseif ($configuration['type'] == 'mail') { + $phpmailer->isMail(); + } + $phpmailer->Host = $configuration['host']; $phpmailer->Port = $configuration['port']; if (!empty($configuration['secure'])) { diff --git a/src/frontend/app/administration/sendmail/sendmail-administration.component.html b/src/frontend/app/administration/sendmail/sendmail-administration.component.html index 680e9b5193df31f4fd312c980685e62167e8a52e..62f4f84a4d694a3989760355a481df1d242772b0 100644 --- a/src/frontend/app/administration/sendmail/sendmail-administration.component.html +++ b/src/frontend/app/administration/sendmail/sendmail-administration.component.html @@ -25,20 +25,19 @@ <div class="form-group"> <div class="col-md-12" style="margin-bottom: 20px;"> <mat-form-field> - <mat-select #smtpType (selectionChange)="changeDesc(smtpType)" name="smtpType" + <mat-select #smtpType name="smtpType" placeholder="{{lang.configurationType}}" [(ngModel)]="sendmail.type" required> <mat-option *ngFor="let type of smtpTypeList" [value]="type.id"> {{type.label}} </mat-option> </mat-select> - <mat-hint>{{smtpTypeDesc}}</mat-hint> </mat-form-field> </div> </div> - <div class="form-group" [style.opacity]="sendmail.type != 'smtp' ? '0.5' : '1'"> + <div class="form-group" [style.opacity]="['smtp', 'mail'].indexOf(sendmail.type) > -1 ? '1' : '0.5'"> <div class="col-md-2"> <mat-form-field> - <mat-select name="SMTPSecure" placeholder="{{lang.smtpAuth}}" [disabled]="sendmail.type != 'smtp'" + <mat-select name="SMTPSecure" placeholder="{{lang.smtpAuth}}" [disabled]="['smtp', 'mail'].indexOf(sendmail.type) == -1" [(ngModel)]="sendmail.secure"> <mat-option *ngFor="let security of smtpSecList" [value]="security.id"> {{security.label}} @@ -48,43 +47,43 @@ </div> <div class="col-md-9"> <mat-form-field> - <input matInput name="host" [disabled]="sendmail.type != 'smtp'" [(ngModel)]="sendmail.host" + <input matInput name="host" [disabled]="['smtp', 'mail'].indexOf(sendmail.type) == -1" [(ngModel)]="sendmail.host" placeholder="{{lang.host}}" required> </mat-form-field> </div> <div class="col-md-1"> <mat-form-field> <input name="port" type="number" matInput [(ngModel)]="sendmail.port" - [disabled]="sendmail.type != 'smtp'" placeholder="{{lang.port}}" required> + [disabled]="['smtp', 'mail'].indexOf(sendmail.type) == -1" placeholder="{{lang.port}}" required> </mat-form-field> </div> </div> - <div class="form-group" [style.opacity]="sendmail.type != 'smtp' ? '0.5' : '1'"> + <div class="form-group" [style.opacity]="['smtp', 'mail'].indexOf(sendmail.type) > -1 ? '1' : '0.5'"> <div class="col-md-12"> <mat-slide-toggle color="primary" name="SMTPAuth" [(ngModel)]="sendmail.auth" - [disabled]="sendmail.type != 'smtp'"(change)="cleanAuthInfo($event)">{{lang.enableAuth}}</mat-slide-toggle> + [disabled]="['smtp', 'mail'].indexOf(sendmail.type) == -1"(change)="cleanAuthInfo($event)">{{lang.enableAuth}}</mat-slide-toggle> </div> </div> - <div class="form-group" [style.opacity]="sendmail.type != 'smtp' ? '0.5' : '1'"> + <div class="form-group" [style.opacity]="['smtp', 'mail'].indexOf(sendmail.type) > -1 ? '1' : '0.5'"> <div class="col-md-12"> <mat-form-field> - <input name="user" [(ngModel)]="sendmail.user" [disabled]="!sendmail.auth || sendmail.type != 'smtp'" + <input name="user" [(ngModel)]="sendmail.user" [disabled]="!sendmail.auth || ['smtp', 'mail'].indexOf(sendmail.type) == -1" matInput placeholder="{{lang.id}}" required> </mat-form-field> </div> <div class="col-md-12"> <mat-form-field> <input name="password" [type]="hidePassword ? 'password' : 'text'" [(ngModel)]="sendmail.password" - [disabled]="!sendmail.auth || sendmail.type != 'smtp'" matInput [placeholder]="sendmail.passwordAlreadyExists === true ? this.lang.passwordModification : this.lang.password" [required]="!sendmail.passwordAlreadyExists"> + [disabled]="!sendmail.auth || ['smtp', 'mail'].indexOf(sendmail.type) == -1" matInput [placeholder]="sendmail.passwordAlreadyExists === true ? this.lang.passwordModification : this.lang.password" [required]="!sendmail.passwordAlreadyExists"> <mat-icon color="primary" style="cursor: pointer;" matSuffix (click)="hidePassword = !hidePassword" class="fa fa-2x" [ngClass]="[hidePassword ? 'fa-eye-slash' : 'fa-eye']"></mat-icon> </mat-form-field> </div> </div> - <div class="form-group" [style.opacity]="sendmail.type != 'smtp' ? '0.5' : '1'"> + <div class="form-group" [style.opacity]="['smtp', 'mail'].indexOf(sendmail.type) > -1 ? '1' : '0.5'"> <div class="col-md-12"> <mat-form-field> - <input name="mailFrom" [(ngModel)]="sendmail.from" [disabled]="sendmail.type != 'smtp'" + <input name="mailFrom" [(ngModel)]="sendmail.from" [disabled]="['smtp', 'mail'].indexOf(sendmail.type) == -1" matInput placeholder="{{lang.mailFrom}}" pattern="(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)"> </mat-form-field> </div> @@ -104,7 +103,7 @@ (opened)="onSubmit();initEmailSend()"> <mat-nav-list disableRipple="true" style="display: flex;flex-direction: column;"> <h3 mat-subheader>{{lang.emailSendTest}}</h3> - <div class="form-group" [style.opacity]="sendmail.type != 'smtp' ? '0.5' : '1'"> + <div class="form-group" [style.opacity]="['smtp', 'mail'].indexOf(sendmail.type) > -1 ? '1' : '0.5'"> <div class="col-md-12"> <form #testSendmailForm="ngForm"> <mat-form-field> diff --git a/src/frontend/app/administration/sendmail/sendmail-administration.component.ts b/src/frontend/app/administration/sendmail/sendmail-administration.component.ts index 38db14526b9ee25bf8bd659f3c432888a296f5d8..4a9aa0071061b03a94c178041b246c3eddfe1fb1 100644 --- a/src/frontend/app/administration/sendmail/sendmail-administration.component.ts +++ b/src/frontend/app/administration/sendmail/sendmail-administration.component.ts @@ -43,18 +43,21 @@ export class SendmailAdministrationComponent implements OnInit { smtpTypeList = [ { id: 'smtp', - label: this.lang.smtp + label: this.lang.smtpclient }, { id: 'sendmail', - label: 'Sendmail' + label: this.lang.smtprelay }, { id: 'qmail', - label: 'Qmail' + label: this.lang.qmail + }, + { + id: 'mail', + label: this.lang.phpmail } ]; - smtpTypeDesc = ''; smtpSecList = [ { id : '', @@ -103,7 +106,6 @@ export class SendmailAdministrationComponent implements OnInit { .subscribe((data: any) => { this.sendmail = data.configuration.value this.sendmailClone = JSON.parse(JSON.stringify(this.sendmail)); - this.smtpTypeDesc = this.lang[this.sendmail.type + 'Desc']; this.loading = false; }, (err) => { @@ -115,10 +117,6 @@ export class SendmailAdministrationComponent implements OnInit { this.sendmail = JSON.parse(JSON.stringify(this.sendmailClone)); } - changeDesc(e: any) { - this.smtpTypeDesc = this.lang[e.selected.value + 'Desc']; - } - onSubmit() { this.http.put(this.coreUrl + 'rest/configurations/admin_email_server', this.sendmail) .subscribe((data: any) => { diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts index b127ee8011582908f01d18646c4364d1ca6f779b..cfff8229ae16d8243c5020dd8952c418d0507ad7 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -850,9 +850,11 @@ export const LANG_EN = { "since" : "Since", "siret" : "SIRET number", "siretCode" : "SIRET code", - "smtp" : "Internal configuration", + "phpmail" : "Function php 'mail'", + "qmail" : "Local mail server 'Qmail'", + "smtprelay" : "Smtp relay (sendmail)", + "smtpclient" : "Smtp client (smtp)", "smtpAuth" : "Authentication methode", - "smtpDesc" : "Internal configuration", "status" : "Status", "statusAdded" : "Status added", "statusCreation" : "Status creation", diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index 4293db85cc758cc95309725a56cfcb003bff161f..b356dc6c35aaccbc565891e7f7927f1fc025b44f 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -882,7 +882,10 @@ export const LANG_FR = { "since" : "Depuis", "siret" : "Numéro SIRET", "siretCode" : "Numéro SIRET", - "smtp" : "Configuration interne", + "phpmail" : "Fonction php 'mail'", + "qmail" : "Serveur mail local 'Qmail'", + "smtprelay" : "Relai smtp (sendmail)", + "smtpclient" : "Client smtp (smtp)", "smtpAuth" : "Méthode d'authentification", "SPH" : "Supérieur hiérarchique", "status" : "Statut", @@ -893,7 +896,6 @@ export const LANG_FR = { "statusModification" : "Modification du statut", "statusName" : "Nom du statut", "statusUpdated" : "Statut mis à jour", - "stmpDesc" : "Utilisateur du module interne phpmailer de l'application", "string" : "Chaine de caractère", "subEntities" : "Entités (et sous-entités)", "subject" : "Objet", diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts index 37d9fea91d6e6361bee0e7f1ae094024a7b2f9c0..dfd65a07d5bd6fa4884eb9282fb5b07840e39bec 100755 --- a/src/frontend/lang/lang-nl.ts +++ b/src/frontend/lang/lang-nl.ts @@ -878,9 +878,11 @@ export const LANG_NL = { "since" : "Sinds", "siret" : "SIRET number", //_TO_TRANSLATE "siretCode" : "SIRET-nummer", - "smtp" : "_TO_TRANSLATE", + "phpmail" : "Function php 'mail'", //_TO_TRANSLATE + "qmail" : "Qmail", + "smtprelay" : "Sendmail", + "smtpclient" : "Smtp", "smtpAuth" : "_TO_TRANSLATE", - "smtpDesc" : "_TO_TRANSLATE", "status" : "Status", "statusAdded" : "Status toegevoegd", "statusCreation" : "Aanmaak van een status",