prashanth ag
asked on
Invalid Address in PHPMailer
Hi,
I want to send an email with PHP page itself it was working fine before after i add extra textbox in that form user needs to add mentor E-mail id
but it shows error
"Invalid address "
"Notice: Undefined variable: mentor_email1 in"
I want to send an email with PHP page itself it was working fine before after i add extra textbox in that form user needs to add mentor E-mail id
but it shows error
"Invalid address "
"Notice: Undefined variable: mentor_email1 in"
require '../PHPMailer/class.phpmailer.php';
if (!isset($_POST['mentoremail']))
{
$mentor_email1 ="";
$mentor_email1= $_POST['mentoremail'];
}
$mail->addAddress($mentor_email1);
if(!$mail->send()) {
echo '<div class="alert alert-danger">Email error:bla bla n.</div>';
}
<div class="control-group">
<label class="control-label" for="descinput">Mentor Email ID(subordinate)</label>
<div class="controls">
<input type="text" name="mentoremail" size="30" >
</div>
</div>
<div class="controls">
<button id="submit" class="btn btn-primary" type="submit" name="submit" value="Login">Apply</button>
</div>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi,
I changed as you mentioned but it shows same error
I changed as you mentioned but it shows same error
ASKER
Notice: Undefined variable: mentor_email in and
Invalid address:
Invalid address:
ASKER
How to post data to the same page ?
example
example
$mentor_email1= $_POST['mentoremail'];
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
can you post the complete code?
ASKER
@Squinky
I made changes as you mentioned but it shows
Fatal error: Call to a member function addAddress() on a non-object in
Notice: Undefined variable: mail in
I made changes as you mentioned but it shows
Fatal error: Call to a member function addAddress() on a non-object in
Notice: Undefined variable: mail in
As I said - it looks like you've left out all your other code - you're missing a `$mail = new PHPMailer;`.
ASKER
thanks Squinky and Loganathan Natarajan
$mail->addAddress($mentor_
That's because $mentor_email1 is never assigned anything if the value $_POST['mentoremail] IS SET!
For now, the quickest way is to change
if (!isset($_POST['mentoremai
to
if (isset($_POST['mentoremail