SpeedBird Posted October 26, 2006 Share Posted October 26, 2006 Probably a very newbie question, but is there any way to add host (mail exchanger) information to an outgoing message when using mail()? I have a script that sends an order confirmation to customers, but some email providers and ISP's seem to drop the email. We get inundated with calls from people worried because they never received an order confirmation. I placed a couple of dummy orders to see if I would receive the confirmation. I received it on my company account but I never receive confirmations on my Hotmail account, they don't even make it to the 'junk mail' folder. After a bit of Googling I found out that if you generate emails with a script it should include the host, but I couldn't find a way to add host information in the PHP documentation at php.net and found nothing useful Googling.Just FYI we are using a fairly old version of X-Cart. Because of modifications we have asked them to do and modifications I have made myself it is going to be quite expensive to upgrade. That said we have another website using the current version of X-Cart and that suffers from the same problem. Because of this I can't (or rather, lack the competence to) integrate a third-party mailer like PHPMailer. What I really need to know is how to include the host in a mail() type function (I already know the hostname and IP address).I am running PHP 5.1.4 on Windows 2003 Server Web Edition. Link to comment https://forums.phpfreaks.com/topic/25164-add-host-information-to-mail/ Share on other sites More sharing options...
php_joe Posted October 26, 2006 Share Posted October 26, 2006 What are you sending as your headers?You don't need to use an old program, you can use this script:[code]<?php$to = '[email protected]';$subject = 'the subject';$message = 'hello';$headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion();mail($to, $subject, $message, $headers);?> [/code]or this to send html mail:[code]<?php$to = '[email protected]';$subject = 'the subject';$message = 'hello';$headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'Content-type: text/html; charset=iso-8859-1' . "\r\n" . 'X-Mailer: PHP/' . phpversion();mail($to, $subject, $message, $headers);?> [/code]Joe Link to comment https://forums.phpfreaks.com/topic/25164-add-host-information-to-mail/#findComment-114824 Share on other sites More sharing options...
SpeedBird Posted October 26, 2006 Author Share Posted October 26, 2006 The headers aren't the problem:[code=php]<?php## Send mail abstract function# $from - from/reply-to address#function func_send_mail($to, $subject_template, $body_template, $from, $to_admin, $crypted=false) { global $mail_smarty, $sql_tbl; global $config, $customer_language, $admin_language; global $current_language, $store_language; if ($to_admin or !$customer_language) { if ($current_language) $charset = array_pop(func_query_first ("SELECT charset FROM $sql_tbl[countries] WHERE code='$current_language'")); else $charset = array_pop(func_query_first ("SELECT charset FROM $sql_tbl[countries] WHERE code='".$config["default_admin_language"]."'")); $mail_smarty->assign ("lng", $admin_language); } else { $charset = array_pop(func_query_first ("SELECT charset FROM $sql_tbl[countries] WHERE code='$store_language'")); $mail_smarty->assign ("lng", $customer_language); } $mail_smarty->assign ("config", $config); $mail_message = $mail_smarty->fetch("$body_template"); $mail_subject = chop($mail_smarty->fetch("$subject_template")); if (($config["PGP"]["enable_pgp"]=="Y") and ($crypted)) { $mail_message = func_pgp_encrypt ($mail_message); } if (stristr(PHP_OS, "win")) { $mail_message=str_replace("\n","\r\n",$mail_message); $lend = "\r\n"; } else $lend = "\n"; $headers = "From: $from".$lend."Reply-to: $from".$lend."X-Mailer: PHP/".phpversion().$lend."MIME-Version: 1.0".$lend; if ($config["Email"]["html_mail"] == "Y") $headers .= "Content-Type: text/html; charset: ".$charset.$lend; else $headers .= "Content-Type: text/plain; charset: ".$charset.$lend; if (preg_match('/([^ @,;<>]+@[^ @,;<>]+)/S', $from, $m)) mail($to,$mail_subject,$mail_message,$headers, "-f".$m[1]); else mail($to,$mail_subject,$mail_message,$headers);}function func_send_simple_mail($to, $subject, $body, $from) { global $config; global $current_language; if (stristr(PHP_OS, "win")) { $body=str_replace("\n","\r\n",$body); $lend = "\r\n"; } else $lend = "\n"; if (!empty($current_language)) $charset = array_pop(func_query_first ("SELECT charset FROM $sql_tbl[countries] WHERE code='$current_language'")); if (empty($charset)) $charset = array_pop(func_query_first ("SELECT charset FROM $sql_tbl[countries] WHERE code='".$config["default_admin_language"]."'")); $headers = "From: $from".$lend."Reply-to: $from".$lend."X-Mailer: PHP/".phpversion().$lend; if ($config["Email"]["html_mail"] == "Y") $headers .= "Content-Type: text/html; charset: ".$charset.$lend; else $headers .= "Content-Type: text/plain; charset: ".$charset.$lend; if (preg_match('/([^ @,;<>]+@[^ @,;<>]+)/S', $from, $m)) mail($to,$subject,$body,$headers, "-f".$m[1]); else mail($to,$subject,$body,$headers);}?>[/code]I need to send the host information. It would be something like the [i]fromhost[/i] function in Xpertmailer. Link to comment https://forums.phpfreaks.com/topic/25164-add-host-information-to-mail/#findComment-114841 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.