{$SMTP_server_provider})){ $credentials=$vcap_services->{$SMTP_server_provider}[0]->credentials; //echo '
'.print_r($credentials).'
'; define ('MAILSERVER_HOSTNAME',$credentials->hostname); define ('MAILSERVER_USERNAME',$credentials->username); define ('MAILSERVER_PASSWORD',$credentials->password); if (isset($_GET['debug'])){ echo '
'.print_r($credentials->hostname, true).'
'; echo '
'.print_r($credentials->username, true).'
'; echo '
'.print_r(substr($credentials->username,0,1).'*****', true).'
'; } } }else{ if (isset($_GET['debug'])){ echo 'No ENV variables found. Are the user-provided email cedentials linked with the app ?'; } } require_once("/home/vcap/app/lib/vendor/autoload.php"); use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; $nom = $_POST['form_nom']; $adresse = $_POST['form_adresse']; $message = $_POST['form_msg']; $subject = 'Message depuis ANEUF'.(!empty($nom)?' - '.$nom:''); //*** test purposes only */ if (isset($_GET['debug'])){ $nom = $_GET['form_nom']; $adresse =$_GET['form_adresse']; $message = $_GET['form_msg']; } //*** */ if (MAILSERVER_HOSTNAME != null){ $mail = new PHPMailer; $mail->CharSet = 'UTF-8'; $mail->isSMTP();//Set PHPMailer to use SMTP. $mail->SMTPAuth = true;//Set this to true if SMTP host requires authentication to send email // config pour envoi par une adresse Office 365 (Constantes définies ailleurs) $mail->Host = MAILSERVER_HOSTNAME; //pour office un compte Office 365 c'est smtp.office365.com $mail->Username = MAILSERVER_USERNAME; // exemple : aneuf@auf.org $mail->Password = MAILSERVER_PASSWORD; // le mot de passe du compte en question $mail->From = MAILSERVER_USERNAME; // $mail->FromName = "Site web ANEUF"; $mail->SMTPSecure = "tls";//If SMTP requires TLS encryption then set it $mail->Port = 587; //Set TCP port to connect to $mail->addAddress(MAILSERVER_USERNAME); $mail->AddCC("rahma.chourabi@auf.org", "Rahma Chourabi"); $mail->AddCC("ific@auf.org", "IFIC"); $mail->addReplyTo(MAILSERVER_USERNAME, "ANEUF"); $mail->isHTML(true); $mail->Subject = $subject; $mail->Body = 'Nom : '.$nom.'
Email : '.$adresse. '

Contenu du message :
'.nl2br($message); //$mail->AltBody = $nom.'
'.$adresse.'
'.$message; $result = $mail->send(); if(!$result) { echo "error##Mailer Error: " . $mail->ErrorInfo; if (isset($_GET['debug'])){ echo '
'.print_r($mail->Subject, true).'
'; echo '
'.print_r($mail->Body, true).'
'; } }else{ echo "ok##Mail sent."; } }else{ } ?>