Board index   FAQ   Search  
Register  Login
Board index PHP Your Scripts

Need Help - Mail function smtp

This is where you share YOUR scripts with others

Moderators: macek, egami, gesf

Need Help - Mail function smtp

Postby BenjaminVL » Wed Nov 02, 2011 9:48 am

I use this code to send my contactform information to my mailbox.
But it won't work. I won't receive an e-mail.
Normal i use ASP.net but i'm learning PHP, so everyone's help is welcome!


<?php
$voornaam = $_REQUEST['naam'];
$from = $_REQUEST['mail'];
$tel = $_REQUEST['tel'];
$fax = $_REQUEST['fax'];
$bedrijf = $_REQUEST['bedrijf'];
$soort = $_REQUEST['soort'];
$bericht = $_REQUEST['bericht'];

$to = "benjamin@mijndomein.com";
$subject = "Emailbericht mijndomein.com";
$headers = "From:" . $from;
$host = "mail.mijndomein.com";
$username = "benjamin@mijndomein.com";
$password = "mijnpaswoord";

$message = "
U heeft een bericht ontvangen van het CONTACTFORMULIER \n
\n
$voornaam van het bedrijf $bedrijf ($mail) schreef het volgende bericht: \n \n

Omschrijving: $soort \n \n

$bericht \n \n

$bedrijf \n
$voornaam \n
$mail \n
$fax \n
$tel

**EINDE BERICHT**

";

mail($to, $subject, $message, $headers, $host, $username, $password);
?>

execute HTML file
BenjaminVL
New php-forum User
New php-forum User
 
Posts: 1
Joined: Wed Nov 02, 2011 9:43 am

Re: Need Help - Mail function smtp

Postby egami » Wed Nov 02, 2011 10:43 am

Aso.. mein Deutsch ist leider ganz schlecht, aber vieleicht Ich kann ein bissien hilfe geben..

Zuerst,
Ich mache dis dingie auf English.


First of all, $_REQUEST should be either _POST or _GET, depending on how you have your form set up. Relying on Request is marginal.

Next,
use the following

IF mail($to,$subject,$message,$headers) {
echo "Mail sent successfully...";
} else {
echo "Mail not sent. There was an error. Check your error logs or figure out how to have the MAIL error displayed on THIS SCREEN.";
}
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: Need Help - Mail function smtp

Postby HvWinkel » Thu Nov 10, 2011 2:42 pm

Many good examples are available thru Google "php contactformulier"

This one http://www.phphulp.nl/php/script/data-v ... mulier/12/
contains only a little bit af dutch language but it should not be a problem.

Works immediately after changing the e-mail address
HvWinkel
New php-forum User
New php-forum User
 
Posts: 8
Joined: Thu Nov 10, 2011 2:36 pm


Return to Your Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron