phpmailer and gmail

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Senior, Medior and Junior SAP HANA Developer

Vacature details Vakgebied: Software/IT Opleiding: Medior Werklocatie: Veldhoven Vacature ID: 12696 Introductie Our client is the world's leading provider of lithography systems for the semiconductor industry, manufacturing complex machines that are critical to the production of integrated circuits or chips. Our purpose is “unlocking the potential of people and society by pushing technology to new limits”. We do this guided by the principles “Challenge”, “Collaborate” and “Care”. Wat verwachten we van jou? SAP Certified Application Associate - SAP HANA Cloud Modeling (training and/or certification) Bachelor degree or higher Excellent understanding of SAP HANA (2.0 / Cloud), Data Modelling and writing

Bekijk vacature »

Jack Maessen

Jack Maessen

12/11/2013 15:28:33
Quote Anchor link
Ik gebruik phpmailer om mijn mails te verzenden. Het verzenden lukt en ik krijg de mail ook netjes binnen bij mijn gmail maar ik krijg naast mijn normale echo nog een hoop andere info retour als verzenden gelukt is.
Dit is wat ik zie:
Afbeelding

Dit is mijn mailcode met form eronder:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?php

// functie spamcheck
function spamcheck($field)
  {

  //filter_var() sanitizes the e-mail
  //address using FILTER_SANITIZE_EMAIL

  $field=filter_var($field, FILTER_SANITIZE_EMAIL);

  //filter_var() validates the e-mail
  //address using FILTER_VALIDATE_EMAIL

  if(filter_var($field, FILTER_VALIDATE_EMAIL))
    {

    return TRUE;
    }

  else
    {
    return FALSE;
    }
  }


if($_SERVER['REQUEST_METHOD'] == 'POST')
{
  
  
// definieren variabelen
// PHP mailer settings

require_once ('../phpmailer/class.phpmailer.php');

$mail = new PHPMailer(true);

$mail->CharSet = 'utf-8'; //sets character set

$mail->IsSMTP();  //To inform that we are using SMTP

$mail->SMTPDebug = 2;  //Shows long message set to 1 to avoid it

$mail->Host = "smtp.gmail.com"; // As we are using gmail SMTP

$mail->Port = "465";  // smtp port number

$mail->SMTPSecure = "ssl"; //gmail requires authentication through ssl or tls

$mail->SMTPAuth = true;

// your account details for authentication provide correct user name and password
$mail->Username = "[email protected]";

$mail->Password = "mijnpassword";

$mail->From = $_POST['email'];

$mail->FromName = $_POST['naam'];

$mail->AddAddress("[email protected]", "Jack Maessen");

$mail->Subject = "Contactformulier";

// variabelen body en body email opmaken

$naam = $_POST['naam'];
$achternaam = $_POST['achternaam'];
$email = $_POST['email'];
$bericht = $_POST['bericht'];

              

$body = "";
$body .= "Naam: ";
$body .= $naam;
$body .= "<br />";
$body .= "Achternaam: ";
$body .= $achternaam;
$body .= "<br />";    
$body .= "Email: ";
$body .= $email;
$body .= "<br />";
$body .= "Bericht: ";
$body .= $bericht;
$body .= "<br />";


$mail->WordWrap = 80;

$mail->MsgHTML($body, dirname(__FILE__), true); //Create message bodies and embed images



// check of submitter een robot is en of er geldige input is geleverd

$mailcheck = spamcheck($_POST['email']);

if($_POST['robot'] != "test_spambot") {
    die();                    
}

//check of email geldig is
elseif ($mailcheck==FALSE) {
    echo "Ongeldige input";
}

else {

// email verzenden
$formsent = $mail->Send();

// echo's als verzenden goed of fout is gegaan
if ($formsent){
  echo 'Dank voor het versturen';
}

else{
  echo 'Sorry, maar er is iets misgegaan met het formulier, probeer het later nog eens.';
    }
  }
}
// eind request method
?>


<form action="" method="post" name="" id="">
  <input type="hidden" name="robot" value="test_spambot" /><br />
  Naam: <br />
  <input type="text" name="naam" /><br />
  Achternaam: <br />
  <input type="text" name="achternaam" /><br />
  Email: <br />
  <input type="email" name="email" /><br />
  Bericht: <br />
  <textarea name="bericht" /></textarea>
  <br /><br />
  <input type="reset" value="Reset" />
  <input type="submit" value="Verzenden" />
  
</form>


Hoe kan ik die overbodige informatie weg krijgen zodat alleen de echo verschijnt?
Gewijzigd op 12/11/2013 15:36:47 door Jack Maessen
 
PHP hulp

PHP hulp

03/05/2024 20:17:22
 
Michael -

Michael -

12/11/2013 15:42:34
Quote Anchor link
Regel 35
$mail->SMTPDebug = 2; //Shows long message set to 1 to avoid it
 
Kris Peeters

Kris Peeters

12/11/2013 15:48:22
Quote Anchor link
En dan nog dit:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
<?php
...
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
...


exit; // Op deze manier wordt het formulier niet opnieuw getoond
} // eind request method
?>

<form ...>
...
 
Michael -

Michael -

12/11/2013 15:52:54
Quote Anchor link
Kris Peeters op 12/11/2013 15:48:22:
En dan nog dit:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
<?php
...
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
...


exit; // Op deze manier wordt het formulier niet opnieuw getoond
} // eind request method
?>

<form ...>
...


exit; is onnodig voor dit.
 
Jack Maessen

Jack Maessen

12/11/2013 15:57:17
Quote Anchor link
yep idd; echter als ik de waarde op 1 zet gaf ie nog steeds alles weer, maar heb de hele regel eruit gehaald en nu krijg ik alleen nog maar de echo
@Kris: dat ziet er idd wat professioneler uit als men de form verzonden heet
Dank voor support
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.