Quick question about $headers and phpmailer

#1

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!

#2

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
#3

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!

#4

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

1 Like
#5

If i understand you correctly then try like this:

From: zoldos < zoldos@website.com > (just remove spaces after < and before >)

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

1 Like
#6

@COLT Where do I put that? :slight_smile:

#7

@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:

#8

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

$to = ‘nobody@website.com’;
$subject = ‘the subject’;
$message = ‘hello’;
$headers = ‘From: John Doe < colt@website.com >’ . “\r\n” .
‘Reply-To: colt@example.com’ . “\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
#9

k got it:

$headers = "From: zoldos <zoldos@email.com>"

Thanks!