0
我是新來的PHP,並拼命地嘗試使用swiftmailer在我的網站上獲得一個簡單的聯繫表單。所以,我已經安裝到正確的位置的庫,和形式是這樣開的:讓swiftmailer工作
<form action="mailhandler_girls.php" method="post" enctype="multipart/form-data">
然後在我的「mailhandler_girls.php」文件我有以下幾點:
<?php
$_SESSION["post"] = $_POST;
$name = $_POST["Name"]; $email = $_POST["Email"]; $phone = $_POST["Phone"]; $dob = $_POST['DOBDay'] ."\t" .$_POST['DOBMonth'] ."\t" .$_POST['DOBYear'];$address = $_POST['AddressLine1'] ."\n" .$_POST['AddressLine2'] ."\n" .$_POST['PostCode'];$experience = $_POST["Experience"];$height = $_POST["Height"]; $size = $_POST["DressSize"];$bra = $_POST["Bra"];$waist = $_POST["Waist"];$hipwidest = $_POST["HipWidest"];$bicep = $_POST["Bicep"];$thigh = $_POST["Thigh"];$shoe = $_POST["Shoe"];
require_once 'lib/swift_required.php';
// Create the Transport
$transport = Swift_SmtpTransport::newInstance('auth.smtp.1and1.co.uk', 25)
->setUsername('[email protected]')
->setPassword('test')
;
// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
// Create a message
$message = Swift_Message::newInstance('Be A Model application: Girls')
// Set the From address with an associative array
->setFrom(array('$email' => '$name'))
// Set the To addresses with an associative array
->setTo(array('[email protected]', '[email protected]' => 'contact test'))
// Give it a body
->setBody('Name: ' .$name ."\n"
.'Email: ' .$email ."\n"
.'Phone: ' .$phone ."\n"
.'Address: ' .$address ."\n"
.'DOB: ' .$dob ."\n"
.'Experience: ' .$experience ."\n"
.'Height: ' .$height ."\n"
.'Dress Size: ' .$size ."\n"
.'Bra: ' .$bra ."\n"
.'Waist: ' .$waist ."\n"
.'Hip at Widest: ' .$hipwidest ."\n"
.'Bicep: ' .$bicep ."\n"
.'Thigh: ' .$thigh ."\n"
.'Shoe Size: ' .$shoe ."\n")
// And optionally an alternative body
->addPart('<q>Here is the message itself</q>', 'text/html');
// Send the message
$result = $mailer->send($message);
?>
什麼也沒有發生。我確定我做錯了什麼是顯而易見的,但我迷失了。我一直在使用這個文件,這個文件已經讓我走了這麼遠,但仍然停滯不前。
我只想得到這個基本版本的工作,然後擔心與圖像附件闡述。我也對SMTP傳輸的事情感到困惑。當然,將用戶名和密碼放在網上的文件中不是一個好主意嗎?
所以沒有SMTP用戶名和密碼如何使用它。 – 2013-03-18 10:31:42
set'php_ini('display_errors',true);''和'error_reporting(E_ALL);',dump信息:'var_dump($ result);',如果有錯誤,我們會找到他。 – mkjasinski 2013-03-18 10:34:00
什麼,怎麼樣?對不起,正如我所說,我知道這一切.. – 2013-03-18 11:03:38