Quick question about $headers and phpmailer

This is what I use to send mail:

mail($visitormail, $subject, $message);

But when it sends, it just shows the e-mail address in the “From” field when the recipient opens it. I dabbled with “$headers” after some research, and just couldn’t get it to work. I simply want it say like “From: xxx” when sent. Please help! Thanks!

Did you check out here?

https://www.php.net/manual/en/function.mail.php

Scroll down to " Example #2 Sending mail with extra headers."

1 Like

Hmm…that is sorta what I was looking for, but I’d like the “From” in the recipient’s inbox to be my name and then the e-mail address. Right now it says this for example: “e-mail address” “e-mail address” where I’d like it to say “zoldos” “e-mail address”.

Thanks!

You mention phpmailer in the title, I’d recommend using it :slight_smile:

1 Like

If i understand you correctly then try like this:

From: zoldos < [email protected] > (just remove spaces after < and before >)

And yes as @JimL said, PHPmailer is much better solution.

1 Like

@COLT Where do I put that? :slight_smile:

@JimL It’s working fine right now, so I’d rather not do a bunch of extra coding. I just wanted to personalize the sent e-mail. :slight_smile:

try like this just use your e-mails and names:

$to = ‘[email protected]’;
$subject = ‘the subject’;
$message = ‘hello’;
$headers = ‘From: John Doe < [email protected] >’ . “\r\n” .
‘Reply-To: [email protected]’ . “\r\n” .
‘X-Mailer: PHP/’ . phpversion();

mail($to, $subject, $message, $headers);

and again, just remove space after < and before > (because if there is no space this editor here dont show them)

1 Like

k got it:

$headers = "From: zoldos <[email protected]>"

Thanks!

Sponsor our Newsletter | Privacy Policy | Terms of Service