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

Langage PHP Discussion :

Envoie d'une page html par mail php


Sujet :

Langage PHP

  1. #1
    Membre du Club
    Homme Profil pro
    Alternance
    Inscrit en
    Février 2019
    Messages
    59
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Alternance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2019
    Messages : 59
    Points : 46
    Points
    46
    Par défaut Envoie d'une page html par mail php
    Bonjour,

    Je me permets de vous écrire puisque je rencontre un problème sur l'envoie d'un mail en php. L'envoie du mail en lui même fonctionne mais j'ai fait pour le message, une page html et quand j'envoie ce mail avec le message j'obtiens pas le résultat voulu j'obtiens tout le texte de mon code html.

    voici mon code php ->
    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
     
                        $header = "MINE-Version : 1.0\r\n";
                        $header .= 'Contact-Type: text/html; charset="utf-8"'."\n";
                        $header .= 'From:"Contact SUAPS"<contact@thomasdurst.fr>'."\r\n"."X-Mailer: PHP/".phpversion(); 
                        $header .= 'Content-Transfer-Encoding: 8Bit';
                        $subject = "Identifiant création compte SUAPS";
                        $message = '
                        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                        	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
                        <html wmlns:v="urn:schemas-microsoft-com:vml">
                        	<head>
                        		<link href="https://fonts.googleapis.com/css?family=Varela+Round&amp;display=swap" rel="stylesheet">
                        		<meta http-equiv="content-type" content="text/html; charset=utf-8">
                        		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
                        	</head>
                        	<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
                        		<table bgcolor="#343846" width="100%" border="0" cellpadding="0" cellspacing="0">
                        			<tbody>
                        				<tr>
                        					<td>
                        						<table align="center" width="590" border="0" cellpadding="0" cellspacing="0">
                        							<tbody>
                        								<tr>
                        									<td height="30" style="font-size: 30px; line-height: 30px"> &nbsp;</td>
                        								</tr>
                        								<tr>
                        									<td align="center" style="text-align: center;">
                        										<a href="https://ppesuaps.thomsdurst.fr" style="text-decoration: none; color: #FFF; font-size:40px;font-family: \'Varela Round\', Helvetica, sans-serif;">SUAPS</a><a href="https://ppesuaps.thomsdurst.fr" style="color: rgb(40, 167,69); text-decoration: none; font-size: 40px;font-family: \'Varela Round\', Helvetica, sans-serif;">.COM</a>
                        									</td>
                        								</tr>
                        								<tr>
                        									<td height="30" style="font-size: 30px; line-height: 30px"> &nbsp;</td>
                        								</tr>
                        								<tr>
                        									<td align="center" style="font-family: \'Varela Round\', Helvetica, sans-serif;text-align: center; font-size: 30px; mso-line-height-rule: exactly;color: #FFF; ;line-height: 26px;">Bienvenue sur le site de SUAPS.COM
     
                        									</td>
                        								</tr>
                        								<tr>
                        									<td height="30" style="font-size: 30px; line-height: 30px"> &nbsp;</td>
                        								</tr>
                        								<tr>
                        									<td align="center" style="font-family: Helvetica, sans-serif; text-align: center; font-size: 17px; mso-line-height-rule: exactly;color: #878b99; ;line-height: 30px;">Un compte a été créé pour vous sur le site SUAPS.COM. Vous pourrez y accéder dès à présent en cliquant sur le bouton ci-dessous.
                        									</td>
                        								</tr>
                        								<tr>
                        									<td height="30" style="font-size: 30px; line-height: 30px"> &nbsp;</td>
                        								</tr>
                        								<tr>
                        									<td align="center" style="font-family: Helvetica, sans-serif; text-align: center; font-size: 17px; mso-line-height-rule: exactly;color: #878b99; ;line-height: 30px;">
                        										<table cellpadding="0" cellspacing="0">
                        											<tbody>
                        												<tr>
                        													<td>Voici vos identifiants : </td>
                        												</tr>
                        											</tbody>
                        										</table>
                        									</td>
                        								</tr>
                        								<tr>
                        									<td height="7" style="font-size: 7px; line-height: 7px"> &nbsp;</td>
                        								</tr>
                        								<tr>
                        									<td align="center" style="font-family: Helvetica, sans-serif; text-align: center; font-size: 17px; mso-line-height-rule: exactly;color: #878b99; ;line-height: 30px;">
                        									<table cellpadding="0" cellspacing="0">
                        										<tbody>
                        											<tr>
                        												<td> - Identifiants : ' . $_POST['pseudo'] . '</td>
                        											</tr>
                        										</tbody>
                        									</table>
                        									</td>
                        								</tr>
                        								<tr>
                        									<td align="center" style="font-family: Helvetica, sans-serif; text-align: center; font-size: 17px; mso-line-height-rule: exactly;color: #878b99; ;line-height: 30px;">
                        									<table cellpadding="0" cellspacing="0">
                        										<tbody>
                        											<tr>
                        												<td> - Mot de passe : '. $mdp .' </td>
                        											</tr>
                        										</tbody>
                        									</table>
                        									</td>
                        								</tr>
                        								<tr>
                        									<td height="30" style="font-size: 30px; line-height: 30px"> &nbsp;</td>
                        								</tr>
                        								<tr>
                        									<td align="center" style="font-family: Helvetica, sans-serif; text-align: center; font-size: 17px; mso-line-height-rule: exactly;color: #878b99; ;line-height: 30px;">Pensez à modifier votre mot de passe.
                        									</td>
                        								</tr>
                        								<tr>
                        									<td height="30" style="font-size: 30px; line-height: 30px"> &nbsp;</td>
                        								</tr>
                        								<tr>
                        									<td align="center">
                        										<table align="center" width="450" cellpadding="0" cellspacing="0">
                        											<tbody>
                        												<tr>
                        													<td width="30"><img src="https://ppesuaps.thomasdurst.fr/public/image/g.png" height="60" alt="" style="display: block;"></td>
                        													<td height="60" bgcolor="#28A745"valign="middle" align="center">
                        														<a href="http://ppesuaps.thomasdurst.fr/"style="font-size: 24px; color: #FFF; text-align: center; font-family: Helvetica, sans-serif; text-decoration: none;">Se connecter</a>
     
                        													</td>
                        													<td width="30"><img src="https://ppesuaps.thomasdurst.fr/public/image/d.png" height="60" alt="" style="display: block;"></td>
                        												</tr>
                        											</tbody>
                        										</table>
                        									</td>
                        								</tr>
                        								<tr>
                        									<td height="30" style="font-size: 30px; line-height: 30px"> &nbsp;</td>
                        								</tr>
                        								<tr>
                        									<td height="30" style="font-size: 30px; line-height: 30px"> &nbsp;</td>
                        								</tr>
                        							</tbody>
                        						</table>
                        					</td>
                        				</tr>
                        			</tbody>
                        		</table>
                        	</body>
                        </html>
     
                        ';
                        mail($mail, $subject, $message, $header);
    La variable $mail est un variable contenant le $_POST['mail'].

    Si cela peut vous aider je suis sur un serveur héberger par OVH.

  2. #2
    Expert éminent sénior
    Avatar de rawsrc
    Homme Profil pro
    Dev indep
    Inscrit en
    Mars 2004
    Messages
    6 142
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Dev indep

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 142
    Points : 16 545
    Points
    16 545
    Billets dans le blog
    12
    Par défaut
    salut,

    y aurait-il pas comme une boulette là-dedans : "MINE-Version : 1.0\r\n"; ?
    Ensuite un retour à la ligne manquant :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    $header .= 'From:"Contact SUAPS"<contact@thomasdurst.fr>'."\r\n"."X-Mailer: PHP/".phpversion(); 
    $header .= 'Content-Transfer-Encoding: 8Bit';
    Pour l'envoi des mails, il faut être hyper rigoureux dans son code (suivre la norme au pied de la lettre). Chaque oubli ou erreur se paie cash sur le résultat final.

  3. #3
    Membre du Club
    Homme Profil pro
    Alternance
    Inscrit en
    Février 2019
    Messages
    59
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Alternance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2019
    Messages : 59
    Points : 46
    Points
    46
    Par défaut
    J'ai modifié ce que tu m'avais dit erreur de débutant et d'attention mais j'ai trouvé une autre erreur.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    $header .= 'Contact-Type: text/html; charset="utf-8"'."\n";
    au lieu de
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    $header .= 'Content-Type: text/html; charset="utf-8"'."\r\n";
    Merci beaucoup

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

Discussions similaires

  1. Envoi d'une page html par email
    Par moslimm dans le forum Balisage (X)HTML et validation W3C
    Réponses: 5
    Dernier message: 11/12/2012, 21h38
  2. Envoyer une page HTML par e-mail
    Par Alexandrebox dans le forum Langage
    Réponses: 6
    Dernier message: 11/03/2009, 20h33
  3. [Mail] Envoyer une page html par mail
    Par Schlapp67 dans le forum Langage
    Réponses: 7
    Dernier message: 20/10/2006, 18h16

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