Spiral1ng
Spiral1ng

Reputation: 323

Concatenate mail subject in PHP mailer

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.

Upvotes: 3

Views: 2575

Answers (2)

Abdulla Nilam
Abdulla Nilam

Reputation: 38672

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

Upvotes: 0

Leena Patel
Leena Patel

Reputation: 2453

Just declare one variable subject

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

Upvotes: 1

Related Questions