AcademyOfR
AcademyOfR

Reputation: 21

What is the correct format for this email header?

How can I send the $email correctly?

$headers .= 'From: SUB: .$email.'  . "\r\n";

Upvotes: 2

Views: 172

Answers (4)

hakre
hakre

Reputation: 198115

You should make it quoted-printable:

$headers .= sprintf("From: \"SUB:\" <%s>\r\n", $email);

Will create a header-line like the following:

From: "SUB:" <[email protected]>

Upvotes: 0

djdy
djdy

Reputation: 6919

$headers = 'From: Sub:'. $email . "\r\n";

Upvotes: 1

Tom van der Woerdt
Tom van der Woerdt

Reputation: 29985

Either use double quotes (don't recommend it):

$headers .= "From: SUB: {$email}\r\n";

Or do it properly and get the variable outside the quotes:

$headers .= 'From: SUB: '.$email."\r\n";

As you can see, you were very close, but the ' should be placed before the first dot and not after the email variable :-)

Upvotes: 3

David Nguyen
David Nguyen

Reputation: 8508

$email should be in double quotes "From: Sub: $email\r\n"; or concat properly 'From: Sub: ' . $email . "\r\n"

Upvotes: 2

Related Questions