IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

Mail Quotidien PHP


Sujet :

PHP & Base de données

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Inscrit en
    Janvier 2007
    Messages
    439
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 439
    Par défaut Mail Quotidien PHP
    Bonjour à tous

    je vous écris ce jour, car j'ai mis en place sur mon site un systéme de newletters d'annonce qui s'envoient par mail aux abonnées de mon site, j'ai déjà la forme du texte avec le code mais j'aimerai que ce mail s'envoient automatiquement sans manipulation humaine 1 fois par jour à une heure précise .

    comment je peux faire pour que ce mail s'envoie donc automatiquement ?

    cordialement

  2. #2
    Membre Expert
    Avatar de cavo789
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mai 2004
    Messages
    1 797
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Mai 2004
    Messages : 1 797
    Par défaut
    Bonsoir

    Pour cela il faut de l'automatisation et, sur un serveur Unix, c'est la tâche du cron.

    Vois auprès de ton hébergeur s'il te propose une solution "cron" qui n'est rien d'autre qu'un planificateur.

    Plus d'info : https://fr.wikipedia.org/wiki/Cron

  3. #3
    Expert confirmé
    Avatar de Séb.
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    5 322
    Détails du profil
    Informations personnelles :
    Âge : 47
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mars 2005
    Messages : 5 322
    Billets dans le blog
    17
    Par défaut
    Ton hébergeur propose sans doute un planificateur de tâches / un cron ou crontab.

    Prépare ton script et utilise l'outil en question pour l'exécuter en temps voulu.

    EDIT : grilled

  4. #4
    Membre éclairé
    Inscrit en
    Janvier 2007
    Messages
    439
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 439
    Par défaut
    l'hebergeur c'est moi ^^ j'ai un serveur dédié je vais regarder les liens je reviens vers vous rapidement

  5. #5
    Membre éclairé
    Inscrit en
    Janvier 2007
    Messages
    439
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 439
    Par défaut
    Aprés avoir regarder sur mon panel j'ai pu voir qu'il y avait la possibilité de geré les taches crons, choses que j'ai tester qui fonctionne .

    maintenant j'ai un autre souci je souhaite donc récupérer tous les id de mes membres (ça c'est pas un probleme ) et ensuite leurs envoyer un mail a chacun comme ceci
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    <?php
    header('Content-Type: application/json');
    session_start();
    include("../mysqlcon.php");
     
     
     
     
    $test ="-800";
     
     
     
    	$the_check = explode("-",$test);
     
        for ($i =0; $i<count($the_check); $i++)
        {
          $current_check = $the_check[$i];
    	  $q = "Select * from commande where id='$current_check'";
    	  $q = $conn->query($q);
    	  $f = mysqli_fetch_array($q);
     
    	  $boundary = md5(rand());
     
     
     
     
     
    $select = "SELECT * from commercant ORDER BY rand() LIMIT 1,100000000000";
     $req = $conn->query($select);
     
     while($data = mysqli_fetch_array($req)){
     
    	 $promotion = $data["promotion"]."<br>";
    	  $nomcommerce = $data["nomcommerce"]."<br>";
     $tel = $data["tel"];
     $adresse = $data["adressep"];
     }
     $promotion = nl2br($promotion);
     $nomcommerce = nl2br($nomcommerce);
     $adressep = nl2br($adressep);
     
     
    	$prenom = $f["prenom"];
    	  $iduser = $f["id"];
    	  $numerocarte = $f["numerocarte"];
     
    	$validation = $f["validation"];
    	$email = $f["email"];
    	$pseudo = $f["pseudo"];
     
    	if (!preg_match("#^[a-z0-9._-]+@(hotmail|live|msn).[a-z]{2,4}$#", $email)) // On filtre les serveurs qui rencontrent des bogues.
     
    {
     
        $passage_ligne = "\r\n";
     
    }
     
    else
     
    {
     
        $passage_ligne = "\n";
     
    }
     
     
    //=====Déclaration des messages au format texte et au format HTML.
     
     
    $message_html = '<html xmlns="https://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,300,700,600" rel="stylesheet" type="text/css">
    <head>
    <!--[if gte mso 12]>
     <style type="text/css">
     [a.btn {
    	padding:15px 22px !important;
    	display:inline-block !important;
    }]
    </style>
     <![endif]-->
    <style type="text/css">
    div, p, a, li, td {
    	-webkit-text-size-adjust:none;
    }
    .ReadMsgBody {
    	width: 100%;
    	background-color: #d1d1d1;
    }
    .ExternalClass {
    	width: 100%;
    	background-color: #d1d1d1;
    	line-height:100%;
    }
    .distri {
    	border: 1px solid;
    	text-align: center;
    	margin-bottom: 5px;
    }
    body {
    	width: 100%;
    	height: 100%;
    	background-color: #d1d1d1;
    	margin:0;
    	padding:0;
    	-webkit-font-smoothing: antialiased;
    	-webkit-text-size-adjust:100%;
    }
    html {
    	width: 100%;
    }
    img {
    	-ms-interpolation-mode:bicubic;
    }
    table[class=full] {
    	padding:0 !important;
    	border:none !important;
    }
    table td img[class=imgresponsive] {
    	width:100% !important;
    	height:auto !important;
    	display:block !important;
    }
    @media only screen and (max-width: 800px) {
    body {
     width:auto!important;
    }
    table[class=full] {
     width:100%!important;
    }
    table[class=devicewidth] {
     width:100% !important;
     padding-left:20px !important;
     padding-right: 20px!important;
    }
    table td img.responsiveimg {
     width:100% !important;
     height:auto !important;
     display:block !important;
    }
    }
    @media only screen and (max-width: 640px) {
    table[class=devicewidth] {
     width:100% !important;
    }
    table[class=inner] {
     width:100%!important;
     text-align: center!important;
     clear: both;
    }
    table td a[class=top-button] {
     width:160px !important;
      font-size:14px !important;
     line-height:37px !important;
    }
    table td[class=readmore-button] {
     text-align:center !important;
    }
    table td[class=readmore-button] a {
     float:none !important;
     display:inline-block !important;
    }
    .hide {
     display:none !important;
    }
    table td[class=smallfont] {
     border:none !important;
     font-size:26px !important;
    }
    table td[class=sidespace] {
     width:10px !important;
    }
    }
     @media only screen and (max-width: 520px) {
    }
    @media only screen and (max-width: 480px) {
    
     table {
     border-collapse: collapse;
    }
    table td[class=template-img] img {
     width:100% !important;
     display:block !important;
    }
    }
    @media only screen and (max-width: 320px) {
    }
    </style>
    </head>
    <body>
    
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="full">
      <tr>
        <td align="center"><table width="600" border="0" cellspacing="0" cellpadding="0" align="center" class="devicewidth">
            <tr>
              <td><table width="100%" bgcolor="#ffffff" border="0" cellspacing="0" cellpadding="0" align="center" class="full" style="background-color:#ffffff;">
                  <tr>
                    <td height="23">&nbsp;</td>
                  </tr>
                  <tr>
                    <td><table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
    				
                        <tr>
                          <td width="23" class="sidespace">&nbsp;</td>
                          <td><table width="76%" border="0" cellspacing="0" cellpadding="0" align="left" class="inner" id="banner" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;">
                              <tr>
                                <td style="font:bold 27px Arial, Helvetica, sans-serif; border-right:1px solid #dbdbdb;" class="smallfont">Information T\'ES DE MURET</td>
                              </tr>
                              <tr>
                                <td height="20">&nbsp;</td>
                              </tr>
                            </table>
                            <table width="22%" border="0" cellspacing="0" cellpadding="0" align="right" class="inner" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;">
                              <tr>
                                <td align="center"><a href="https://www.facebook.com/groups/1383840451862587/" style="margin-top:5px; display:inline-block;"><img src="https://www.tesdemuret.fr/mail/images/facebook.png" width="32" height="atuo" alt="Social Media" /></a></td>
                                
                              </tr>
                              <tr>
                                <td height="20">&nbsp;</td>
                                <td height="20">&nbsp;</td>
                                <td height="20">&nbsp;</td>
                              </tr>
                            </table></td>
                          <td width="23" class="sidespace">&nbsp;</td>
                        </tr>
                      </table>
                      <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
                        <tr>
                          <td width="3.33%" class="sidespace">&nbsp;</td>
                          <td width="93.33%"><img class="imgresponsive" src="https://www.tesdemuret.fr/mail/images/couvtdm.jpg" width="554" height="atuo" alt="Banner" /></td>
                          <td width="3.33%" class="sidespace">&nbsp;</td>
                        </tr>
                        <tr>
                          <td height="20">&nbsp;</td>
                          <td height="20">&nbsp;</td>
                          <td height="20">&nbsp;</td>
                        </tr>
                      </table>
                      <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
                        <tr>
                          <td width="23" class="sidespace">&nbsp;</td>
                          <td>
                            <table width="100%" border="0" cellspacing="0" cellpadding="0" align="left" class="inner">
                              <tr>
                                <td style="font:14px/19px Arial, Helvetica, sans-serif; color:#333332;">
     
                          <div class="top-button" style="text-align: center; font:bold 13px/37px Arial, Helvetica, sans-serif; color:#ffffff; text-decoration:none; background:#16c4a9; display:block; border-radius:24px; text-transform:uppercase;">Bonjour '.$prenom.'</div>
                         
     Aujourd\'hui <b>'.$nomcommerce.'</b> te proposes ses services, en effet ce commerçant te proposes en ce moment:<p> <b>'.$promotion.'</b><p> c\'est génial n\'est ce pas ? <p>
     Réserves vite au <b>'.$tel.'</b> et rends toi vite dans sa boutique situé <b>'.$adresse.'</b>
    <p>
    | Ton numéro de carte <b>'.$numerocarte.'</b> |<p>
    
    
    
    <b>
    Désormais tu peux maintenant rejoindres l\'association TDM sur www.tesdemuret.fr en cliquant sur l\'onglet "L\'Association" puis "Nous rejoindres" trop cool hein ? 
    </b><p>
    <P>
    
    Si vous n\'avez pas reçu votre carte vous pouvez la récupérer chez un de nos distributeurs suivant : <p>
    ';
     
     
    $select = "SELECT * from commercant where distribution = 1  and valide = 1";
     $req = $conn->query($select);
     
     while($data = mysqli_fetch_array($req)){
     
    	 $promotion = $data["promotion"];
    	  $nomcommercee = $data["nomcommerce"];
     $tele = $data["tel"];
     $adressee = $data["adressep"];
     
     
    $message_html .='<div class="distri"><b>'.$nomcommercee.'</b> situé à l\'adresse <b>'.$adressee.'</b> contact : <b>'.$tele.'</b></div>';
     
     }
     
     
     
    $message_html .='
    
    
    <i>Tu ne souhaites plus recevoir l\'offre de nos partenaires ? C\'est dommage mais tu peux annuler ton abonnement en cliquant : <a href =\'https://www.tesdemuret.fr/nonews.php?email='.$email.'&iduser='.$iduser.'\'>>>> ICI <<<</a></i></p>
    Si tu ne vois pas le lien copie/colle celui-ci dans ton navigateur https://www.tesdemuret.fr/nonews.php?email='.$email.'&iduser='.$iduser.'<p>
    
    
    <P>
    
    Cordialement<br>
    Alain Paltou <br>
    Support TDM<br>
    <p></td>
                              </tr>
                              <tr>
                                <td height="20">&nbsp;</td>
                              </tr>
                              
                            </table></td>
                          <td width="23" class="sidespace">&nbsp;</td>
                        </tr>
                        <tr>
                          <td height="16">&nbsp;</td>
                          <td height="16">&nbsp;</td>
                          <td height="16">&nbsp;</td>
                        </tr>
                      </table></td>
                  </tr>
                  <tr>
                    <td style="border-bottom:1px solid #dbdbdb;">&nbsp;</td>
                  </tr>
                </table></td>
            </tr>
          </table></td>
      </tr>
    </table>
    
    
    
    ';
    //==========
     
     
     
    //=====Création de la boundary
     
    $boundary = "-----=".md5(rand());
     
    //==========
     
     
     
    //=====Définition du sujet.
     
    $sujet = "Partenaire du jour";
     $sujet = nl2br($sujet);
     
    //=========
     
     
     
    //=====Création du header de l'e-mail.
    $adresse_exp = "contact@tesdemuret.fr";
    $adresse_exp2 = "tesdemuret@hotmail.com";
    $header = "From: \"Support TDM\"<$adresse_exp>".$passage_ligne;
     
    $header.= "Reply-to: \"Support TDM\" <$adresse_exp2>".$passage_ligne;
     
    $header.= "MIME-Version: 1.0".$passage_ligne;
    $header .= "X-Priority: 1".$passage_ligne;
     
    $header.= "Content-Type: multipart/alternative;".$passage_ligne." boundary=\"$boundary\"".$passage_ligne;
     
    //==========
     
     
     
    //=====Création du message.
    $message = $passage_ligne."--".$boundary.$passage_ligne;
     
    //=====Ajout du message au format texte.
     
    $message.= "Content-Type: text/plain; charset=\"UTF_8\"".$passage_ligne;
     
    $message.= "Content-Transfer-Encoding: 8bit".$passage_ligne;
     
    $message.= $passage_ligne.$message_txt.$passage_ligne;
     
    //==========
     
    $message.= $passage_ligne."--".$boundary.$passage_ligne;
     
    //=====Ajout du message au format HTML
     
    $message.= "Content-Type: text/html; charset=\"UTF-8\"".$passage_ligne;
     
    $message.= "Content-Transfer-Encoding: 8bit".$passage_ligne;
     
    $message.= $passage_ligne.$message_html.$passage_ligne;
     
    //==========
     
    $message.= $passage_ligne."--".$boundary."--".$passage_ligne;
     
    $message.= $passage_ligne."--".$boundary."--".$passage_ligne;
     
    //==========
     
    //=====Envoi de l'e-mail.
     
    mail($email,$sujet,$message,$header);
     
    //==========
     
     
     
     
     
     
     
     
     
     
     
     
        }
     
    echo json_encode(['reponse' => 'ok' , 'rep' => $email]);
     
    ?>
    je souhaite donc remplacer le $test = "-800" par tous les id et ensuite le récuperer dans le explode pour continuer a envoyé

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Mail] Fonction mail () de php
    Par goma771 dans le forum Langage
    Réponses: 5
    Dernier message: 20/02/2006, 21h18
  2. [Mail] Serveur de mail en PHP sur serveur dédié
    Par dralik dans le forum Langage
    Réponses: 15
    Dernier message: 16/01/2006, 15h11
  3. [Mail] Le php pourrait il résoudre mon problème???
    Par mayoouketchup dans le forum Langage
    Réponses: 3
    Dernier message: 20/12/2005, 13h10
  4. [Mail] Transferer un mail en PHP.
    Par tissot dans le forum Langage
    Réponses: 2
    Dernier message: 04/10/2005, 19h23
  5. Probleme d'envois de mail serveur PHP/ASP
    Par oulahoup dans le forum ASP
    Réponses: 2
    Dernier message: 23/08/2005, 14h38

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo