php - Swift Mailer automatic sending form data -


i'm trying configure swift mailer send form data email account in short: have website, using going sell stuff in local city there 3 simple forms appear when 'buy' button active point send data, filled in these forms directly email account, being newbie php, have tried several days make simple script work, ended failure here code of mail.php:

<?php $name=$_post["name"]; $email=$_post["email"]; $phone=$_post["phone"]; if (isset ($name)) { $name = substr($name,0,30);  if (empty($name)) { echo "<center><b>invalid name<p>"; echo "<a href=index.php>come , fill form properly</a>"; exit; } } else { $name = "invalid name"; } if (isset ($email)) { $email = substr($email,0,30); //Не может быть более 20 символов if (empty($email)) { echo "<center><b>email invalid!<p>"; echo "<a href=index.php>try again</a>"; exit; } } else { $email = "invalid"; } if (isset ($phone)) { $phone = substr($phone,0,15);  if (empty($phone)) { echo "<center><b>empty message!!!<p>"; echo "<a href=index.php>try again</a>"; exit; } } else { $phone = "invalid"; } $i = "invalid"; if ($name == $i , $email == $i , $phone == $i) { echo "error! no data transferred script"; exit; } $to = "zakaz@playpad2.ru";   $subject = "new order "; $message = "name:$name::::::::::email:$email::::::::::phone no:$phone:::::::::; require_once 'lib/swift_required.php'; $transport = swift_smtptransport::newinstance('smtp.yandex.ru', 465, 'ssl')  ->setusername('zakaz@playpad2.ru')  ->setpassword('jhfy;tdjtujdyj');  $mailer = swift_mailer::newinstance($transport);  // create message $message = swift_message::newinstance('wonderful subject')   ->setfrom(array('kirabidzu@gmail.com' => 'playpad 2 kids tablet order'))   ->setto(array('zakaz@playpad2.ru', 'zakaz@playpad2.ru' => 'a name'))   ->setbody('name:$name::::::::::email:$email::::::::::phone no:$phone:::::::::');  // send message $numsent = $mailer->send($message);  if (!$numsent) {   print "can't send message"; }  echo "<center><b>thank you<a href=index.php>proceed</a> continue...>"; exit; ?>" 

here form, located on main page:

<form name="form" action="mail.php" method="post"><b>name here </b>  <br> <input type="text" size="70%" name="name" maxlength="45"> <br> <b>phone no </b>  <br> <input type="text" size="70%" name="phone" maxlength="15"> <br> <b>e-mail </b>  <br> <input type="text" size="70% " name="email" maxlength="45"> <br>  <input type="submit"><div class="button"></div> 

please help!

changed smtp server port, , new error appears: php fatal error: uncaught exception 'swift_transportexception' message 'expected response code 250 got code "553", message "553 5.7.1 sender address rejected: not owned auth user.\r\n"' can't understand why need "from" field if message sent site?? person fills form , wnat email data or filled in? should write in "from" field?

upd: emails sent!!! made 'from' , 'to' email addresses equal of help

looks missing closing double quote on line:

$message = "name:$name::::::::::email:$email::::::::::phone no:$phone:::::::::; 

should be:

$message = "name:$name::::::::::email:$email::::::::::phone no:$phone:::::::::;"; 

also, shouldn't have posted mail account information. it's time change account's password.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -