So I want the from
field when an email is opened to be something like
\"Jack Sparrow Via somesite\"
as opposed to an explicit email address
If you use PHP Mailer from GitHub, then you do it by:
$mail->SetFrom("info@mibckerala.org", "MIBC");
just use like this
$headers .= 'From: [Name of the person]'.'<'. $this->from .'>'. "\n";
in Header Section.
You can accomplish this by using basic headers.
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: Jack Sparrow <jsparrow@blackpearl.com>' . PHP_EOL .
'Reply-To: Jack Sparrow <jsparrow@blackpearl.com>' . PHP_EOL .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
I am not sure exactly what you mean, but as you can see on PHP.net mail function.
To add the name to the from section you need to send this in the headers.
From:Name<email@example.com>
You have to set your headers:
$to = "Someone@email.com";
$header = "FROM: Jack Sparrow <some@site.com>\r\n";
$message = "Your message here.";
$subject = "Your subject";
mail($to,$subject,$message,$header) or die();
$to = "Someone@email.com";
$message = "Your message here.";
$subject = "Your subject";
mail($to,$subject,$message,$header, '-f some@site.com -F "Jack Sparrow"') or die();
Just add the -f parameter to provide the sender's email and -F parameter to provide the sender's name to the mail(), all as a string.
Note: double quotes around "Jack Sparrow"
Assuming that you are using sendmail on a Linux machine:
You can find more detailed information by typing "man sendmail" in your shell.