phpmailer - PHP Mailer Coding Issue -
i having issue getting php mailer code work correctly. can send email on page load fine, issue isset command submit form 1 time submit button has been pressed. have tried putting in various places still can't work. help appreciated.
<?php require '/phpmailer/phpmailerautoload.php'; require_once '/phpmailer/class.phpmailer.php'; include '/phpmailer/class.smtp.php'; if(isset($_post["submit"])) { $emailaddress = '****@**********'; $message= 'name: '.$_post['name'].'<br /> email: '.$_post['email'].'<br /> ip: '.$_server['remote_addr'].'<br /><br /> message:<br /><br /> '.nl2br($_post['message']).' '; $mail = new phpmailer(); $mail->issmtp(); // telling class utilize smtp $mail->host = "********"; // smtp server $mail->smtpdebug = 1; // 1 = errors , messages,2 = messages $mail->smtpauth = false; // enable smtp authentication $mail->port = 25; // set smtp port gmail server $mail->smtpsecure = 'false'; // enable encryption, 'ssl' accepted $mail->charset = 'utf-8'; // interprets foreign characters $mail->setfrom('***********'); $mail->addreplyto('**********'); $mail->subject = "contact form submission ".$_post['name']." "; $mail->msghtml($message); $mail->addaddress($emailaddress); if(!$mail->send()) { echo "message not sent. <p>"; echo "mailer error: " . $mail->errorinfo; exit; } echo "thank you, message has been sent!"; }
i'm going create comment answer, because conclusion can come , be, without seeing op's html form.
your conditional statement if(isset($_post["submit"]))
based on submit button named submit
. if submit button has name="submit"
instead of name="submit"
, explain it. if isn't named, do.
i.e.:
<input type="submit" name="submit" value="send email">
is not same as
<input type="submit" name="submit" value="send email">
post variables case-sensitive. your presently shown code has proper bracing.
having used error reporting , placed top of file(s) right after opening <?php
tag
error_reporting(e_all); ini_set('display_errors', 1);
would have signaled undefined index submit...
warning message.
php phpmailer
No comments:
Post a Comment