3

I have a form for users to submit their inquiry which will be sent as an email. As users are able to select their inquiry type, i wish to concatenate the inquiry type into the subject of the email.

$formname = "Website Inquiry Form";
$inquirytype = "Books";
$mail->Subject = $formname . ' - ' . $inquirytype;

When I submitted the form, I got this error, Mailer Error: SMTP Error: data not accepted.

Any advise? Thanks.

Spiral1ng
  • 313
  • 1
  • 7
  • 16

2 Answers2

1

Just declare one variable subject

$subject = $formname.'-'.$inquirytype;
$mail->Subject = $subject;
Leena Patel
  • 2,423
  • 1
  • 14
  • 28
0

Read about Basic Example using SMTP
and look at this too

do like this

$sub = $formname.'-'.$inquirytype;
$mail->Subject = $sub;

to add body text use

$mail->Body = 'I'm Body text';

Basic of use

$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Host       = "mail.yourdomain.com"; // sets the SMTP server
$mail->Port       = 25;                    // set the SMTP port for the GMAIL server
$mail->Username   = "yourname@yourdomain"; // SMTP account username
$mail->Password   = "yourpassword";        // SMTP account password

$mail->SetFrom('name@yourdomain.com', 'First Last');

$mail->AddReplyTo("name@yourdomain.com","First Last");

$mail->Subject    = "PHPMailer Test Subject via smtp, basic wi
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85