Toon posts:

[phpmailer] Smtp host ??

Pagina: 1
Acties:
  • 59 views sinds 30-01-2008

Verwijderd

Topicstarter
Hallo, als ik de mail() functie gebruik van de phpmailer dan werkt het emailen niet. Wel als ik hem op smtp zet. Alleen de smtp host is dan bij mij mail.chello.nl....Mijn vraag is kan iedereen ook met andere smtp hosts gebruik maken van deze functie. Als iemand bijvoorbeeld bij tiscali zit en die vult het form in, wordt de mail dan alsnog verzonden??

Hoe kan ik de mail() functie van php zelf wel werkend krijgen of hoe kan ik met smtp er voor zorgen dat welke smtp host de gebruiker ook heeft de mail wel werkt?

hieronder de pagina's met code.
vacatures.html
code:
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>TopSales.nu -- Vacatures</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href= "style.css" media="screen" rel="stylesheet" type="text/css"/>
</head>

<body background="img/backgroundVacatures.png">
                
                <div id="logo"> [img]"img/TopaSalesLogo.png">[/img]
                            
                <div id="contentLeft"> 
                        <a href="home.html" > <img src="img/btnHome.png"
                        onmouseover= "this.src='img/btnHomeOver.png'" 
                        onmouseout= "this.src='img/btnHome.png'" alt="btn"/> </a> <br><br>
                        <a href="vacatures.html" > <img src="img/btnVacatures.png"
                        onmouseover= "this.src='img/btnVacaturesOver.png'" 
                        onmouseout= "this.src='img/btnVacatures.png'" alt="btn" /> </a><br><br>
                        <a href="diensten.html"> <img src="img/btnDiensten.png"
                        onmouseover= "this.src='img/btnDienstenOver.png'" 
                        onmouseout= "this.src='img/btnDiensten.png'" alt="btn" /> </a><br><br>
                        <a href="nieuws.html" > <img src="img/btnNieuws.png"
                        onmouseover= "this.src='img/btnNieuwsOver.png'" 
                        onmouseout= "this.src='img/btnNieuws.png'" alt="btn" /> </a><br><br>
                        <a href="fotos.html" > <img src="img/btnFotos.png"
                        onmouseover= "this.src='img/btnFotosOver.png'" 
                        onmouseout= "this.src='img/btnFotos.png'" alt="btn" /> </a><br><br>
                        <a href="contact.php" > <img src="img/btnContact.png"
                        onmouseover= "this.src='img/btnContactOver.png'" 
                        onmouseout= "this.src='img/btnContact.png'" alt="btn" /> </a><br><br>
                </div>
                <div id="contentNieuws">
                
                Vul onderstaand formulier in om een open sollicitatie te sturen om deel te nemen aan het team: "Sales door mensen met Skills!"<br><br>
                <table width="250px" style="font-size:10px;">
                
                <form method="post" action="vacatures.php">
                    <tr>
                        <td>Roepnaam*<br><input style="width:275px;" type="text" name="roepnaam"></td>
                    </tr>   
                </table>    
                
                <table width="250px" style="font-size:10px;"> 
                    <tr>
                        <td>Voorletters*<br><input style="width:60px;" type="text" name="voorletters"></td>             
                        <td>Achternaam*<br><input style="width:140px;" type="text" name="achternaam"></td>                  
                        <td>Geslacht*<br><input style="width:20px;" type="radio" name="geslacht" value="Man">M<input style="width:20px;" type="radio" name="geslacht" value="Vrouw">V</td>
                    </tr>
                </table>
                
                <table width="250px" style="font-size:10px;">
                    <tr>
                        <td>Geboortedatum*<br><input style="width:95px;" type="text" name="geboortedatum"></td>
                        <td>Geboortplaats*<br><input style="width:170px;" type="text" name="geboorteplaats"></td>
                    </tr>
                </table>
                
                <table width="250px" style="font-size:10px;">
                    <tr>
                        <td>Adres*<br><input style="width:275px;" type="text" name="adres"></td>
                    </tr>
                </table>
                <table width="250px" style="font-size:10px;">
                    <tr>
                        <td>Postcode*<br><input maxlength="6" style="width:80px;" type="text" name="postcode"></td>             
                        <td>Woonplaats*<br><input style="width:185px;" type="text" name="woonplaats"></td>
                    </tr>       
                </table>
                <table width="250px" style="font-size:10px;">
                    <tr>                
                        <td>Telefoonnr.*<br><input maxlength="10" style="width:80px;" type="text" name="telefoon"></td>
                        <td>E-mailadres*<br><input style="width:185px;" type="text" name="email"></td>
                    </tr>
                </table>    
                <table width="250px" style="font-size:10px;">
                    <tr>                
                        <td>Opleidingsniveau*<br><input style="width:20px;" type="radio" name="opleidingsniveau" value="VMBO">VMBO<input style="width:20px;" type="radio" name="opleidingsniveau" value="MBO">MBO<input style="width:20px;" type="radio" name="opleidingsniveau" value="HBO">HBO<input style="width:20px;" type="radio" name="opleidingsniveau" value="Universitair">Universitair</td>
                    </tr>
                </table>
                <div id="line">================================</div>
                <table width="250px" style="font-size:10px;">
                    <tr>                
                        <td>Werkervaring*<br><input style="width:20px;" type="radio" name="werkervaring" value="1 jaar">1 jaar<input style="width:20px;" type="radio" name="werkervaring" value="3 jaar">3 jaar<input style="width:20px;" type="radio" name="werkervaring" value="5 jaar">5 jaar<input style="width:20px;" type="radio" name="werkervaring" value="10 jaar">10 jaar</td>
                    </tr>
                </table>
                
                <table>
                    <tr>
                        <td><input height="20" style="background-color:#CCCCCC" type="submit" name="submit" value="Vervolg sollicitatieformulier"  /></td>
                    </tr>
                </table>

                </form>     
                </table>                
                <div style="font-size:10px;">*Deze velden zijn verplicht</div> 
                <br>
                
                </div>

</body>
</html>


vacatures.php
code:
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
<? session_start(); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>TopSales.nu -- Vacatures</title>
<link href= "style.css" media="screen" rel="stylesheet" type="text/css"/>
</head>

<body background="img/backgroundVacatures.png">
                
                <div id="logo"> [img]"img/TopaSalesLogo.png">[/img]
                            
                <div id="contentLeft"> 
                        <a href="home.html" > <img src="img/btnHome.png"
                        onmouseover= "this.src='img/btnHomeOver.png'" 
                        onmouseout= "this.src='img/btnHome.png'" alt="btn"/> </a> <br><br>
                        <a href="vacatures.html" > <img src="img/btnVacatures.png"
                        onmouseover= "this.src='img/btnVacaturesOver.png'" 
                        onmouseout= "this.src='img/btnVacatures.png'" alt="btn" /> </a><br><br>
                        <a href="diensten.html"> <img src="img/btnDiensten.png"
                        onmouseover= "this.src='img/btnDienstenOver.png'" 
                        onmouseout= "this.src='img/btnDiensten.png'" alt="btn" /> </a><br><br>
                        <a href="nieuws.html" > <img src="img/btnNieuws.png"
                        onmouseover= "this.src='img/btnNieuwsOver.png'" 
                        onmouseout= "this.src='img/btnNieuws.png'" alt="btn" /> </a><br><br>
                        <a href="fotos.html" > <img src="img/btnFotos.png"
                        onmouseover= "this.src='img/btnFotosOver.png'" 
                        onmouseout= "this.src='img/btnFotos.png'" alt="btn" /> </a><br><br>
                        <a href="contact.php" > <img src="img/btnContact.png"
                        onmouseover= "this.src='img/btnContactOver.png'" 
                        onmouseout= "this.src='img/btnContact.png'" alt="btn" /> </a><br><br>
                </div>
                
                <div id="contentNieuws">
                
                <?

                    /*
                    $ontvanger = "info@yourcreations.nl";
                    $onderwerp = "Open sollicitatie van Topsales.nu";
                    $verzender = "From: topsales.nu"; 
                    */
                    

                    
                    $msg .= "Roepnaam: " . $_POST["roepnaam"] . "<BR />\r\n";
                    $msg .= "Voorletters: " . $_POST["voorletters"] . "<BR />\r\n";
                    $msg .= "Achternaam: " . $_POST["achternaam"] . "<BR />\r\n";
                    $msg .= "Geslacht: " . $_POST["geslacht"] . "<BR />\r\n";
                    $msg .= "Geboortedatum: " . $_POST["geboortedatum"] . "<BR />\r\n";
                    $msg .= "Geboorteplaats: " . $_POST["geboorteplaats"] . "<BR />\r\n";
                    $msg .= "Adres: " . $_POST["adres"] . "<BR />\r\n";
                    $msg .= "Postcode: " . $_POST["postcode"] . "<BR />\r\n";
                    $msg .= "Woonplaats: " . $_POST["woonplaats"] . "<BR />\r\n";
                    $msg .= "Telefoonnr.: " . $_POST["telefoon"] . "<BR />\r\n";
                    $msg .= "Email: " . $_POST["email"] . "<BR />\r\n";
                    $msg .= "Opleidingsniveau: " . $_POST["opleidingsniveau"] . "<BR />\r\n";
                    $msg .= "Werkervaring: " . $_POST["werkervaring"] . "<BR />\r\n";

                    $_SESSION['email']['msg'] = $msg;
                    
                        
                    /*
                    if (mail($ontvanger, $onderwerp, $msg, $verzender))
                    {
                        echo 'Er is helaas een fout opgetreden bij het versturen van uw bericht.';
                    }
                    else
                    {
                        echo 'Uw bericht is verzonden.';
                    }*/
                    
                    
                ?>
                

                <table width="250px" style="font-size:10px;">
                
                <form method="post" action="vacatures2.php">
                    <tr>
                        <td>Verkoopervaring*<br><input style="width:20px;" type="radio"  name="verkoopervaring" value="Ja">Ja<input style="width:20px;" type="radio" name="verkoopervaring" value="Nee">Nee</td>
                    </tr>   
                </table>
                <table width="250px" style="font-size:10px;">
                    <tr>
                        <td>Huidg salarisniveau*<br><input style="width:275px;" type="text" name="salaris"></td>
                    </tr>
                </table>    
                <table width="250px" style="font-size:10px;">
                    <tr>
                        <td>Opzegtermijn sollicitatie*<br><input style="width:20px;" type="radio" name="opzegtermijn" value="Geen">Geen<input style="width:20px;" type="radio" name="opzegtermijn" value="1 maand">1 maand<input style="width:20px;" type="radio" name="opzegtermijn" value="2 maanden">2 maanden</td>
                    </tr>
                </table>
                <div id="line">================================</div>
                <table width="250px" style="font-size:10px;">
                    <tr>
                        <td>Beschikbaarheid*<br><input style="width:20px;" type="radio" name="beschikbaarheid" value="Fulltime">Fulltime<input style="width:20px;" type="radio" name="beschikbaarheid" value="Parttime">Parttime</td>
                        <td>Avonduren*<br><input style="width:20px;" type="radio" name="avonduren" value="Ja">Ja<input style="width:20px;" type="radio" value="Nee" name="avonduren">Nee</td>
                        <td>Weekenduren*<br><input style="width:20px;" type="radio" name="weekenduren" value="Ja">Ja<input style="width:20px;" type="radio" name="weekenduren" value="Nee">Nee</td>
                    </tr>
                </table>
                <div id="line">================================</div>
                <table width="250px" style="font-size:10px;">
                    <tr>
                        <td>Eigen vervoer*<br><input style="width:20px;" type="radio" name="vervoer" value="Auto en of Motor">Auto/motor<input style="width:20px;" type="radio" name="vervoer" value="Fiets en of Brommer">Fiets/brommer<input style="width:20px;" type="radio" name="vervoer" value="Openbaar Vervoer">OV</td>
                    </tr>
                </table>
                <table width="250px" style="font-size:10px;">
                    <tr>
                        <td>Functie interesse*<br><input style="width:275px;" type="text" name="interesse"></td>
                    </tr>
                </table>    
                <table width="250px" style="font-size:10px;">
                    <tr>
                        <td>Motivatie*<br><textarea style="width:275px;" rows="3" type="text" name="motivatie"></textarea></td>
                    </tr>
                </table>
                <table width="250px" style="font-size:10px;">
                    <tr>
                        <td>Curriculum Vitae*<br><input style="width:280px;" type="file" name="uploadcv" alt="uploadcv" value="uploadcv"></td>
                    </tr>
                </table>
                <table width="250px">
                    <tr>
                        <td> <input height="20" style="background-color:#CCCCCC" type="submit" name="Versturen" alt="versturen" value="Versturen"></td>
                    </tr>
                </form>     
                </table>                
                <div style="font-size:10px;">*Deze velden zijn verplicht</div> 
                </div>



    
</body>
</html>


vacatures2.php
code:
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
<? session_start();  ?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>TopSales.nu -- Vacatures</title>
<link href= "style.css" media="screen" rel="stylesheet" type="text/css"/>
</head>

<body background="img/backgroundVacatures.png">
                
                <div id="logo"> [img]"img/TopaSalesLogo.png">[/img]
                            
                <div id="contentLeft"> 
                        <a href="home.html" > <img src="img/btnHome.png"
                        onmouseover= "this.src='img/btnHomeOver.png'" 
                        onmouseout= "this.src='img/btnHome.png'" alt="btn"/> </a> <br><br>
                        <a href="vacatures.html" > <img src="img/btnVacatures.png"
                        onmouseover= "this.src='img/btnVacaturesOver.png'" 
                        onmouseout= "this.src='img/btnVacatures.png'" alt="btn" /> </a><br><br>
                        <a href="diensten.html"> <img src="img/btnDiensten.png"
                        onmouseover= "this.src='img/btnDienstenOver.png'" 
                        onmouseout= "this.src='img/btnDiensten.png'" alt="btn" /> </a><br><br>
                        <a href="nieuws.html" > <img src="img/btnNieuws.png"
                        onmouseover= "this.src='img/btnNieuwsOver.png'" 
                        onmouseout= "this.src='img/btnNieuws.png'" alt="btn" /> </a><br><br>
                        <a href="fotos.html" > <img src="img/btnFotos.png"
                        onmouseover= "this.src='img/btnFotosOver.png'" 
                        onmouseout= "this.src='img/btnFotos.png'" alt="btn" /> </a><br><br>
                        <a href="contact.php" > <img src="img/btnContact.png"
                        onmouseover= "this.src='img/btnContactOver.png'" 
                        onmouseout= "this.src='img/btnContact.png'" alt="btn" /> </a><br><br>
                </div>
                
                <div id="contentNieuws">
                
                <?
                    require("plugins/phpmailer/class.phpmailer.php");

                    $uploadcv = $_POST['uploadcv'];
                                        
                    $msg2 .= "Verkoopervaring: " . $_POST['verkoopervaring'] . "<BR />\r\n";
                    $msg2 .= "Salaris: " . $_POST['salaris'] . "<BR />\r\n";
                    $msg2 .= "Opzegtermijn: " . $_POST['opzegtermijn'] . "<BR />\r\n";
                    $msg2 .= "Beschikbaarheid: " . $_POST['beschikbaarheid'] . "<BR />\r\n";
                    $msg2 .= "Avonduren: " . $_POST['avonduren'] . "<BR />\r\n";
                    $msg2 .= "Weekenduren: " . $_POST['weekenduren'] . "<BR />\r\n";
                    $msg2 .= "Vervoer: " . $_POST['vervoer'] . "<BR />\r\n";
                    $msg2 .= "Interesse: " . $_POST['interesse'] . "<BR />\r\n";
                    $msg2 .= "Motivatie: " . $_POST['motivatie'] . "<BR />\r\n";
                    
                    $_SESSION['email']['msg2'] = $msg2;
                    $_SESSION['email']['upload'] = $uploadcv;
                    
                    
                    
                    /*
                    ##########################################
                    Begin stuk configuratie
                    
                    hey gary, hij is mommenteel ingesteld op mijn
                    email adres en ontvang ik dus alle emails
                    als je em op je eigen email adres wil testen.. even configureren dan.
                    
                    Effe een hint maar via phpmailer en smtp kan het even duren voordat de 
                    email binnen komt. heeft iets te maken met tracen van een intern ipadres
                    een backward ofzoiets... boeie!!.. maar het werkt in igv. met en of zonder
                    attachment.
                    
                    Alvast veel plezier ermee. Was wel effe wat werk 
                    
                    en de rest niet veranderen alleen wat tussen het begin en eind stuk van configuratie staat
                    en natuurlijk je html code.
                    ###########################################
                    */
                    
                    
                    //vul hier een email adres in dat verzend (in dit geval een onzinnige en hij mag niet het zelfde zijn als ontvanger).
                    $verzender = "noemail@noemail.nl";
                    $verzender_naam = "theo nobel [nobeltheo@hotmail.com]"; 
                    
                    //vul hier even het email adres in van james 
                    $ontvanger = "james.meulemans@topsales.nu";
                    $ontvanger_naam = "James";
                    //vul hier even een onderwerp in als je dat wil wijzigen
                    $onderwerp = "Open sollicitatie van Topsales.nu";
                    
                    //vul het type mailer in ( of smtp of mail)
                    //smtp is via smtp en mail is via phpmailer functie van php zelf
                    $mailer_type = "smtp";
                    //vul hier de smtp host in
                    $smtp_host = "mail.chello.nl";
                    
                    /*
                    ####################################
                    Eind stuk configuratie
                    ####################################
                    */
                    
                    $attachmentcv = $_SESSION['email']['upload'];
                    $body1 = $_SESSION['email']['msg'];
                    $body2 = $_SESSION['email']['msg2'];
                    $body = $body1.'<BR />'.$body2;
                    $subject = $onderwerp;

                    $mail = new PHPMailer();
                    
                    $mail->From     = $verzender;
                    $mail->FromName = $verzender_naam;
                    $mail->IsHTML(true);
                    
                    $mail->Subject = $subject;
                    $mail->AddAddress($ontvanger,$ontvanger_naam);
                    
                    
                    $mail->Host     = $smtp_host;
                    $mail->Mailer   = $mailer_type;
                    
                    $mail->Body    = $body;
                    
                    if(!empty($uploadcv)){
                        $mail->AddAttachment($attachmentcv, "bestand");  // optional name
                    }
                    
                    if(!$mail->Send()){
                       echo "Er was een error om dit bericht te versturen";
                       exit;
                    }else{                  
                        session_destroy();
                    }
                    

                                        
                ?>
                
                <h1>Uw email is verzonden!</h1>
                </div>



    
</body>
</html>

Verwijderd

Je zult per host waarop de PHP file gedeployed is een werkende SMTP host moeten instellen. De Chello SMTP server zal emails vanaf een Tiscali IP-adres waarschijnlijk niet ontvangen en andersom ook niet.

Verder moet je nog maar eens de quick start lezen in de P & W FAQ, want deze startpost voldoet op verschillende fronten niet aan de voorwaarden.

  • NMe
  • Registratie: Februari 2004
  • Laatst online: 15-04 22:07

NMe

Quia Ego Sic Dico.

PHP:
1
2
3
4
5
6
7
8
                    if (mail($ontvanger, $onderwerp, $msg, $verzender))
                    {
                        echo 'Er is helaas een fout opgetreden bij het versturen van uw bericht.';
                    }
                    else
                    {
                        echo 'Uw bericht is verzonden.';
                    }
Als het goed gaat is er bij jou dus een fout opgetreden? Geen wonder dat het niet werkt. :P

Verder is het niet de bedoeling dat je honderden regels code post, en dat wij die dan voor je gaan debuggen. Isoleer je probleem naar een paar regels (zie ook onze FAQ daarover) en post dan een nieuw topic, mocht het probleem blijven. Dit topic gaat in elk geval op slot. :)

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.


  • Creepy
  • Registratie: Juni 2001
  • Laatst online: 23:02

Creepy

Tactical Espionage Splatterer

Hmmja.. Zie MrX dus.

De "oplossing" lijkt me duidelijk. Let in het vervolg even op P&W FAQ - De "quickstart" zodat je volgende keer alleen de relevante code en dus niet alle code post. Dit is echt een gigantische lap en dat weerhoudt er een hoop mensen van om je code te bekijken (waar het feitelijk probleem niet eens in zit ;) )

-NMe- :w

"I had a problem, I solved it with regular expressions. Now I have two problems". That's shows a lack of appreciation for regular expressions: "I know have _star_ problems" --Kevlin Henney


Dit topic is gesloten.