Archief - Kan email niet ontvangen

Het archief is een bevroren moment uit een vorige versie van dit forum, met andere regels en andere bazen. Deze posts weerspiegelen op geen enkele manier onze huidige ideeën, waarden of wereldbeelden en zijn op sommige plaatsen gecensureerd wegens ontoelaatbaar. Veel zijn in een andere tijdsgeest gemaakt, al dan niet ironisch - zoals in het ironische subforum Off-Topic - en zouden op dit moment niet meer gepost (mogen) worden. Toch bieden we dit archief nog graag aan als informatiedatabank en naslagwerk. Lees er hier meer over of start een gesprek met anderen.

Timph

Legacy Member
Hallo,
Ik ontvang emails niet van mijn website.
Dit is de PHP code:
Code:
<?php
if(isset($_post['email'])){
	$email_to = "[email protected]";    
    $email_subject = "website html form submissions";
	
	$first_name = $_POST['name']; // required
    $email_from = $_POST['email']; // required
    $telephone = $_POST['subject']; // not required
    $comments = $_POST['message']; // required
	
	$email_message .= "naam: $first_name";
    $email_message .= "Email: $email_from";
    $email_message .= "onderwerp: $telephone";
    $email_message .= "bericht: $comments";
	
	$headers = 'From: '.$email_from."\r\n";
mail($email_to, $email_subject, $email_message, $headers);

}

?>]

HTML:
Code:
<form action="html_form_send.php" class="contact-form" method="post">
                <div class="col-md-9  wow fadeInRight animated">
                        <div class="row">
                            <div class="col-md-6">
                                <input type="text" class="form-control" id="name" placeholder="Naam">
                                <input type="email" class="form-control" id="email" placeholder="Email">
                                <input type="text" class="form-control" id="subject" placeholder="Onderwerp">                                
                            </div>
                            <div class="col-md-6">
                                <textarea class="form-control" id="message" rows="25" cols="10" placeholder="  Uw bericht"></textarea>
                                <input type="submit" id='email' class="btn btn-default submit-btn form_submit" value="VERSTUUR BERICHT"/>                               
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>

maarten_

Legacy Member
Je kunt de e-mail niet versturen vanop jouw server als gmail adres zonder je te autoriseren, wat logisch is anders kun je e-mails gaan versturen uit ieders naam.

Meest eenvoudige manier is gebruik te maken van een library zoals bv phpmailer heel eenvoudig in installatie en configuratie.
Het bevat een aantal voorbeelden zoals deze die toont hoe je via gmail kunt sturen.

Timph

Legacy Member
maarten_ zei:
Je kunt de e-mail niet versturen vanop jouw server als gmail adres zonder je te autoriseren, wat logisch is anders kun je e-mails gaan versturen uit ieders naam.

Meest eenvoudige manier is gebruik te maken van een library zoals bv phpmailer heel eenvoudig in installatie en configuratie.
Het bevat een aantal voorbeelden zoals deze die toont hoe je via gmail kunt sturen.

Wat moet ik nu doen nu ik het gedownload heb en in mijn website gezet heb

maarten_

Legacy Member
Onderstaand script is te gebruiken voor het versturen van de mail. Opzich is het mooi zelf verklarend - tenzij je geen Engels snapt - en kun je snel de gegevens aanpassen die moeten aangepast worden.

Succes!

Code:
<?php
/**
 * This example shows settings to use when sending via Google's Gmail servers.
 */

//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');

require '../PHPMailerAutoload.php';

//Create a new PHPMailer instance
$mail = new PHPMailer;

//Tell PHPMailer to use SMTP
$mail->isSMTP();

//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;

//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';

//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
// use
// $mail->Host = gethostbyname('smtp.gmail.com');
// if your network does not support SMTP over IPv6

//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587;

//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';

//Whether to use SMTP authentication
$mail->SMTPAuth = true;

//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "[email protected]";

//Password to use for SMTP authentication
$mail->Password = "yourpassword";

//Set who the message is to be sent from
$mail->setFrom('[email protected]', 'First Last');

//Set an alternative reply-to address
$mail->addReplyTo('[email protected]', 'First Last');

//Set who the message is to be sent to
$mail->addAddress('[email protected]', 'John Doe');

//Set the subject line
$mail->Subject = 'PHPMailer GMail SMTP test';

//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));

//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';

//Attach an image file
$mail->addAttachment('images/phpmailer_mini.png');

//send the message, check for errors
if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}

Timph

Legacy Member
maarten_ zei:
Onderstaand script is te gebruiken voor het versturen van de mail. Opzich is het mooi zelf verklarend - tenzij je geen Engels snapt - en kun je snel de gegevens aanpassen die moeten aangepast worden.

Succes!

Code:
<?php
/**
 * This example shows settings to use when sending via Google's Gmail servers.
 */

//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');

require '../PHPMailerAutoload.php';

//Create a new PHPMailer instance
$mail = new PHPMailer;

//Tell PHPMailer to use SMTP
$mail->isSMTP();

//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;

//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';

//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
// use
// $mail->Host = gethostbyname('smtp.gmail.com');
// if your network does not support SMTP over IPv6

//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587;

//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';

//Whether to use SMTP authentication
$mail->SMTPAuth = true;

//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "[email protected]";

//Password to use for SMTP authentication
$mail->Password = "yourpassword";

//Set who the message is to be sent from
$mail->setFrom('[email protected]', 'First Last');

//Set an alternative reply-to address
$mail->addReplyTo('[email protected]', 'First Last');

//Set who the message is to be sent to
$mail->addAddress('[email protected]', 'John Doe');

//Set the subject line
$mail->Subject = 'PHPMailer GMail SMTP test';

//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));

//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';

//Attach an image file
$mail->addAttachment('images/phpmailer_mini.png');

//send the message, check for errors
if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}

Moet ik dat vervangen met mijn php script?

Recipe4hate

Legacy Member
Programmeren en webdevelopment is niet zomaar 'downloaden van het internet' en vervolgens 'in mijn website plakken'.
Begin eens eerst met de basis vooraleer je blind scriptjes begint te kopieren.
Je gaat hier niemand vinden die (gratis) jouw code gaat schrijven hoor.
Het archief is een bevroren moment uit een vorige versie van dit forum, met andere regels en andere bazen. Deze posts weerspiegelen op geen enkele manier onze huidige ideeën, waarden of wereldbeelden en zijn op sommige plaatsen gecensureerd wegens ontoelaatbaar. Veel zijn in een andere tijdsgeest gemaakt, al dan niet ironisch - zoals in het ironische subforum Off-Topic - en zouden op dit moment niet meer gepost (mogen) worden. Toch bieden we dit archief nog graag aan als informatiedatabank en naslagwerk. Lees er hier meer over of start een gesprek met anderen.
Terug
Bovenaan