0
Обновление: теперь мой send.php выглядит так и, когда я нажимаю кнопку send, получает пустую страницу и ничего не посылает. У меня есть class.phpmailer.php в нужном месте.Отправить html-форму в php с smtp
<html>
<head>
<title>PHPMailer - SMTP basic test with authentication</title>
</head>
<body>
<?php
error_reporting(E_STRICT);
date_default_timezone_set('America/Toronto');
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.******.hu"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.******.hu"; // sets the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]******.hu"; // SMTP account username
$mail->Password = "******"; // SMTP account password
$mail->SetFrom('[email protected]******.hu', 'First Last');
$mail->AddReplyTo("[email protected]******.hu","First Last");
$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$address = "[email protected]******.hu";
$mail->AddAddress($address, "[email protected]******.hu");
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$call = $_POST['call'];
$website = $_POST['website'];
$priority = $_POST['priority'];
$type = $_POST['type'];
$message = $_POST['message'];
$address = "[email protected]******.hu";
$formcontent=" From: $name \n Phone: $phone \n Call Back: $call \n Website: $website \n Priority: $priority \n Type: $type \n Message: $message";
$formcontent= eregi_replace("[\]",'',$formcontent);
$mail->MsgHTML($formcontent);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
</body>
</html>
Helo! Я хочу отправить html-форму по электронной почте с этим кодом php, но не работает ... Не знаю, почему ... Если вы знаете решение, пожалуйста, помогите мне :) Спасибо!
HTML-форма:
<div id="stylized" class="myform">
<form id="form1" action="send.php" method="POST">
<label>Név
<span class="small">Kérem adja meg nevét</span>
</label>
<input type="text" name="name">
<label>Email
<span class="small">Kérem valós címet adjon meg</span>
</label>
<input type="text" name="email">
<br />
<br />
<label>Telefon
<span class="small">Visszahíváshoz adja meg telefonszámát</span>
</label>
<input type="text" name="phone">
<br />
<br />
<label>Elérhetőség
<span class="small">Kérem adja meg mikor érhetjük el telefonon</span>
</label>
<select name="priority" size="1">
<option value="Low">Délelőtt</option>
<option value="Normal">Délután</option>
<option value="High">Este</option>
<option value="Emergency">Egész nap</option>
</select>
<br />
<br />
<br />
<label>Szolgáltatás
<span class="small">Mivel kapcsolatban keres minket?</span>
</label>
<select name="type" size="1">
<option value="update">Szolgáltatás Megrendelése</option>
<option value="change">Szolgáltatás Lemondás</option>
<option value="addition">Információ</option>
<option value="new">Hiba Bejelentése</option>
</select>
<br />
<br />
<br />
<label>Tárgy
<span class="small">Írja le az üzenet tárgyát</span>
</label>
<input type="text" name="website">
<br />
<br />
<br />
<label>Üzenet
<span class="small">Írja le üzenetét</span>
</label>
<textarea name="message" rows="15" cols="29"></textarea><br />
<button type="submit" value="Send" style="margin-top:15px;">Küldés</button>
<div class="spacer"></div>
</form>
</div>
И мой PHP:
<?php
//error_reporting(E_ALL);
error_reporting(E_STRICT);
$mail = new PHPMailer();
$formcontent = eregi_replace("[\]",'',$formcontent);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.myserver.hu"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.myserver.hu"; // sets the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]"; // SMTP account username
$mail->Password = "myserverpass"; // SMTP account password
$mail->SetFrom('[email protected]', 'First Last');
$mail->AddReplyTo("[email protected]","First Last");
$mail->Subject = "test";
$mail->AltBody = "test"; // optional, comment out and test
$mail->MsgHTML($formcontent);
$formcontent=" From: $name \n Phone: $phone \n Call Back: $call \n Website: $website \n Priority: $priority \n Type: $type \n Message: $message";
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$call = $_POST['call'];
$website = $_POST['website'];
$priority = $_POST['priority'];
$type = $_POST['type'];
$message = $_POST['message'];
$address = "[email protected]";
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
</body>
</html>
Пожалуйста, помогите мне, если вы можете! :) Thaks!
Какая ошибка? – KiwiJuicer
Проверьте конец кода PHP. Он имеет '