Forum

php mail gönde...
 
Bildirimler
Hepsini Temizle

php mail gönderim Acil yardım

5 Yazılar
2 Üyeler
0 Likes
1,572 Görüntüleme
(@oguzhangor)
Gönderiler: 26
Eminent Member
Konu başlatıcı
 

Merhaba

Php ile mail gönderimi ve veri tabanına kaydını yapmaya çalışıyorum şuan çalışmıyor nedenini bilmediğin sorundan dolayı acil olarak yardım ederseniz programın çalışacak hale getirebilirsek çok sevinirim.teşşekürler şimdiden.

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>PHPMailer ile E-posta Gönderimi (DEMO) - Erbilen.NET</title>

<style type="text/css">
* {
padding: 0; margin: 0; list-style: none; border: none; font-family: Arial; font-size: 14px
}
textarea, input {
border: 1px solid #ddd;
border-top-color: #aaa;
border-left-color: #aaa;
padding: 7px;
resize: none
}
input:focus, textarea:focus {
outline: 1px solid #205ec1
}
button {
background: #205ec1;
color: #fff;
padding: 7px 13px;
cursor: pointer
}
form {
width: 400px;
margin: 20px auto;
background: #f9f9f9;
padding: 10px;
border: 1px solid #ddd;
border-top-color: #aaa;
border-left-color: #aaa
}
form h3 {
font-size: 21px;
font-weight: normal;
margin-bottom: 10px;
border-bottom: 1px solid #ddd;
padding-bottom: 10px
}
table tr td {
padding: 6px
}
.success {
border: 1px solid green;
color: green;
padding: 10px;
margin: 20px auto;
width: 400px
}
.error {
border: 1px solid red;
color: red;
padding: 10px;
margin: 20px auto;
width: 400px
}
</style>

</head>
<body>
<?php

require_once("ayarlar.php");

?>

<?php

if ( $_POST ){

$adsoyad = htmlspecialchars(trim($_POST['eposta']));
$eposta = htmlspecialchars(trim($_POST['eposta']));
$mesaj = htmlspecialchars(trim($_POST['mesaj']));

include 'class.phpmailer.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->Username = '[email protected]';
$mail->Password = 'deneme';
$mail->SetFrom($mail->Username, 'Oğuzhan Gör');
$mail->AddAddress($eposta,$isim);
$mail->CharSet = 'UTF-8';
$mail->Subject = 'E-POSTA KONUSU';
$content = '<div style="background: #eee; padding: 10px; font-size: 14px">'.$mesaj.'</div>';
$mail->MsgHTML($content);
if($mail->Send()) {

echo '<div class="success">E-posta başarıyla gönderildi, lütfen kontrol edin.</div>';
} else {

echo '<div class="error">'.$mail->ErrorInfo.'</div>';
}

}

?>
<?php
if($_POST)
{
$isim = $_POST["isim"];
$soyad = $_POST["soyad"];
$eposta = $_POST["eposta"];
$mesaj = $_POST["mesaj"];

if (empty($isim) || empty ($soyad))
{
echo "Boş alan bırakmayınız!";
}else{
$ekle = $db->prepare("insert into kayıt(isim,soyad,eposta,mesaj) values(?,?,?,?)");
$ekle->execute(array($isim,$soyad,$eposta,$mesaj));

$hata = $ekle->errorInfo();
if($hata[2])
{
echo "Ekleme işlemi başarısız";
}else {
echo "Ekleme işkemi BAŞARILI - ".$db->lastInsertId();
}
}
}

?>

<form action="" method="post">
<h3>E-Posta Gönder</h3>
<table>
<tr>
<td width="70">E-Posta</td>
<td><input type="text" name="eposta" style="width: 200px" /></td>
</tr>
<tr>
<td>Ad-Soyad</td>
<td><input type="text" name="isim" style="width: 200px" /></td>
</tr>
<tr>
<td>Mesaj</td>
<td><textarea name="mesaj" cols="40" rows="5"></textarea></td>
</tr>
<tr>
<td></td>
<td><button type="submit">Gönder</button></td>
</tr>
</table>
</form>

</body>
</html>

 
Gönderildi : 01/11/2016 14:44

(@HalitSiMSEK)
Gönderiler: 94
Estimable Member
 

gmailde yapman gereken ayarlar var yaptınmı ?

 
Gönderildi : 01/11/2016 15:59

(@oguzhangor)
Gönderiler: 26
Eminent Member
Konu başlatıcı
 

Hocam gmail ayarlarını yaptım mail gmail düşüyor ama bu seferde veri tabanına eklemiyor 

Notice: Undefined variable: isim in C:\wamp64\www\php\mail\index.php on line 90
Call Stack
# Time Memory Function Location
1 0.0010 260488 {main}( ) ...\index.php:0
 

 

( ! ) Notice: Undefined index: soyad in C:\wamp64\www\php\mail\index.php on line 110
Call Stack
# Time Memory Function Location
1 0.0010 260488 {main}( ) ...\index.php:0

bu hatayı alıyorum.Benim yapmak istediğim mail atarken aynı anda veritabanınada kaydetmesi 

 

 
Gönderildi : 01/11/2016 16:11

(@HalitSiMSEK)
Gönderiler: 94
Estimable Member
 

<?php
require_once 'class.phpmailer.php';

if($_POST)
{
$isim = $_POST["isim"];
$email = $_POST["email"];
$konu = $_POST["konu"];
$mesaj = $_POST["mesaj"];
if (empty($isim)){
echo "İsim Alanı Boş<br/>";
}
if (empty($email)){
echo "Email Alanı Boş<br/>";
}
if (empty($konu)){
echo "Konu Alanı Boş<br/>";
}
if (empty($mesaj)){
echo "Mesaj Alanı Boş<br/>";
}
if (!empty($isim) && !empty($email) && !empty($konu) && !empty($mesaj))

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = "smtp.gmail.com";
//$mail->SMTPDebug = 0;
$mail->Port = 587;
$mail->SMTPSecure = "tls";
$mail->Username = "@gmail.com";
$mail->Password = "";
$mail->SetFrom($email, $isim);
$mail->AddAddress("@gmail.com", "Halit ŞİMŞEK");
$mail->CharSet = "UTF-8";
$mail->Subject = "$konu";
$mail->MsgHTML("$mesaj");
}

if($mail->Send()) {

echo 'Mail gönderildi!';
header("Location:index.html");
} else {
echo 'Mail gönderilirken bir hata oluştu: ' . $mail->ErrorInfo;
}

?>

bu bnm daha önce yaptığım bi çalışmadan..

senin kodunda bazı hatalar var büyük ihtimalle hata veriyi post edemediği için geliyor. post yaptığın kısımları birdaha kontrol edermisin.

html kısmında soyad diye bir input açmamışsın, ama sql komutuna soyad diye bir parametre eklemişsin acaba sql tablondaki kolon isimlerinde bir hata olabilirmi ?

 
Gönderildi : 01/11/2016 20:01

(@oguzhangor)
Gönderiler: 26
Eminent Member
Konu başlatıcı
 

Hocam bazı eksikleri tamamlayarak çalıştırdım teşekkürederim yardımlarınız için

 
Gönderildi : 02/11/2016 12:08

Paylaş: