AndrewS
AndrewS

Reputation: 1565

PHPMailer send more values

I am profun in PHP, so i need help with this one:

I added new variables to PHPmailer form, however How can i manage to send them to email?

this is the code I think I must modify:

    $mail = new PHPMailer();
    $mail->From       = $conf['email_sent_from'];
    $mail->FromName   = $conf['email_sent_from_name'];
    $mail->Subject    = $conf['email_subject'];
    $mail->WordWrap   = 50; // some nice default value

    $mail->Body = $values['message']; <-- this code
    $mail->AddReplyTo( $values['email'] );
    $mail->AddAddress( $conf['email_to'] );

Those are all values:

$values = array(
    'webname'       => $_POST['webname'],
    'business'      => $_POST['business'],
    'name'      => $_POST['name'],
    'email'     => $_POST['email'],
    'phone'     => $_POST['phone'],
    'message'   => $_POST['message'],
    );

I want webname, business, name, email, phone, & message to be in the body. How can i do this?

AND is there a way of HTML customization? like adding < br >

Upvotes: 0

Views: 84

Answers (1)

user557846
user557846

Reputation:

cheap and dirty with minimum formatting

$mail->Body = implode('<br>',$values);

a little more formatting, make sure html email is used

$body="<table>";
foreach ($values as $k=>$v){

$body.='<tr><td>'.$k.'</td><td>'.$v.'</td></tr>';
}
$body.="</table>";

$mail->IsHTML(true); // its html mail baby
$mail->Body =$body;

Upvotes: 2

Related Questions