I have a problem when sending an email with PHP The problem is my email title and from variable is blank
Screenshot of my email:
I use my work email address to send an email. My script is like this
public static function header($from, $cc = false, $replyTO = null) {
$headers = "From: " . $from . "
";
if ($replyTO) {
$headers .= "Reply-to: ". $replyTO ."
"; }
if ($cc) {
$headers .= "CC: ". $cc ."
"; }
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type: text/html; charset=ISO-8859-1
";
return $headers;
}
public static function top() {
return file_get_contents('email/top.php');
}
public static function footer() {
return file_get_contents('email/bottom.php');;
}
public static function output( $url ) {
$message = self::top();
$message .= $url;
$message .= self::footer();
return $message;
}
public static function send($from, $to, $subject, $content) {
if ( mail($to, $subject, $content, self::header($from)) ) {
return true;
}
return false;
}
Any solution ? thank you in advance
For From name:
Try the following:
public static function header($from,$sender_name='', $cc = false, $replyTO = null) {
$headers = "From: ".$sender_name."<" . $from . ">
";
if ($replyTO) {
$headers .= "Reply-to: ". $replyTO ."
"; }
if ($cc) {
$headers .= "CC: ". $cc ."
"; }
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type: text/html; charset=ISO-8859-1
";
return $headers;
}
for the name example
$headers .= 'From: Steven Koelsche <info@koeltech.net>' . "
";
$headers .= 'From: '.$fullname.' <'.$emailaddress.'>' . "
";
i assume image is tied with google+ account, your can registered your current email with them then just add your images and vala