good evening everone , i have phpmailer code which allow me to connect to smtp google service and send a message through it , here is the code
<?php
require_once("class.phpmailer.php");
include("class.smtp.php");
$sname="=?UTF-8?B?".base64_encode($sname)."?=\n";
$smail="";
$rname="=?UTF-8?B?".base64_encode($rname)."?=\n";
$rmail="";
$sub="=?UTF-8?B?".base64_encode($sub)."?=\n";
$body=$n;
$sname=$_POST['element_2'];
$n= $_POST['element_1'] . $_POST['element_3'];
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$gmail="account@gmail.com";
$gpass="password";
$mail->Username = $gmail;
$mail->Password = $gpass;
$mail->AddReplyTo($smail,$sname);
$rmail = "receive@hotmail.com";
$rname="me";
$mail->AddAddress($rmail, $rname);
$mail->From = $smail;
$mail->FromName = $sname;
$mail->Subject = $sub;
$mail->MsgHTML($body);
$mail->IsHTML(true);
if(!$mail->Send()) {
echo "fail";
}else{
echo "success";
}
?>
the problem is , i can’t get the name of the sender
i ‘ve tried to insert it into body but it couldn’t success
$n= $_POST['element_1'] . $_POST['element_3'];
my 2nd issue is
i have also a 3 radio buttons for the subject , i’ve used
if(isset($_POST['radio1'])){
$sub = "free";
}
if(isset($_POST['radio2'])){
$sub = "premium";
}
but still receive empty subject
could you please help me
thanks in advance
thanks for your time , me first issue was solved ,
thanks to you ,
but the second one unfortunately didn’t. i’ve gave radio buttons the same name and change their value as following
<input id="element_4_1" name="element_4" class="element radio" type="radio" value="free" />
<input id="element_4_1" name="element_4" class="element radio" type="radio" value="premium" />
when i select a radio button it suppose to have the value free or premium but it have the value 1
i tried your code (i’ve put it right under $n value )
$sub = isset($_POST['element_4']) ? $_POST['element_4'] : "no subject";
and tried this
$sub = $_POST['element_4'];
but it didn’t work
could you goon with your help please
thanks in advance
put
after
it works if in fact
$_POST['element_1'] and $_POST['element_3']are being posted to this page !and as for your radio buttons
all of them should have the same name and there values should be the subject of your email