php - Bulk Email using form not working -


i trying send bulk email gmail using php in address,to address , message set form. not working..shows error

mail.php

<!doctype html> <html> <head>   <meta http-equiv="content-type" content="text/html; charset=utf-8" />   <title>phpmailer - gmail smtp test</title> </head> <body> <?php date_default_timezone_set('etc/utc'); require '../mail/class.phpmailer.php'; $mail = new phpmailer(); $mail->issmtp(); $mail->smtpdebug  = 2; $mail->debugoutput = 'html'; $mail->host       = 'smtp.gmail.com'; $mail->port       = 587; $mail->smtpsecure = 'tls'; $mail->smtpauth   = true; $mail->username   = "username@gmail.com"; $mail->password   = "passwrd"; $mail->setfrom("$_post('from')","$_post('from_name')"); $mail->addreplyto("$_post('from')","$_post('from_name')"); $mail->addaddress("$_post('to')","$_post('from_name')"); $mail->subject = 'phpmailer gmail smtp test'; $mail->msghtml("$_post('message')"); if(!$mail->send()) {   echo "mailer error: " . $mail->errorinfo; } else {   echo "message sent!"; } ?> </body> </html> 

index.php

<form action="mail.php" method="post">     <div>         from:          <input type="text" name="from" />         name:<input type="text" name="from_name" />     </div>     <div>         to:         <input type="text" name="to" />         name:<input type="text" name="to_name" />     </div>     <div>         message:         <textarea  name="message"></textarea>     </div>     <input type="submit" value ="submit"/> </form> 

it shows follwing error:

invalid address: array('from') invalid address: array('from') invalid address: array('to') mailer error: must provide @ least 1 recipient email address. 

someone please me solve problem. not getting problem is.

cargo-cult programming:

$mail->setfrom("$_post('from')","$_post('from_name')"); 

should be

$mail->setfrom($_post['from'], $_post['from_name']); 

note use of [] instead of (), , lack of " quotes around single values.

you'll have fix every line of code in script you're doing sort of bad array referencing.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -