unplugged_web Posted April 1, 2008 Share Posted April 1, 2008 I have an online community website that is on a testing server at the moment, but I've noticed a problem with it. If somebody registers a email is sent. If the person enters a hotmail or yahoo email address then they will get the email. If their email address is anything else then they just won't get the email.I don't know where the problem is and have included the code of the php file if that helpsThanks <?php$area = "public";include("./_include/core/main_start.php");class CIndex extends CHtmlBlock{ var $message = ""; function action() { global $g; global $l; $cmd = get_param("cmd", ""); if ($cmd == "please_login") { $this->message = $l['join.php']['please_login'] . "<br>"; } if ($cmd == "sent") { $this->message = $l['join.php']['was_sent'] . "<br>"; } elseif ($cmd == "login") { $name = get_param("user", ""); $password = get_param("password", ""); $this->message = ""; $id = DB::result("SELECT user_id FROM user WHERE name=" . to_sql($name, "Text") . " and (password=" . to_sql($password, "Text") . " OR password=" . to_sql(md5($password), "Text") . ");"); if ($id == 0) { $this->message .= $l['join.php']['incorrect_username'] . "<br>"; } if ($this->message == "") { set_session("user_id", $id); set_session("user_id_verify", $id); #print_r($_SESSION); if (get_param("remember", "") != "") { set_cookie("c_user", $name, -1); set_cookie("c_password", $password, -1); } else { set_cookie("c_user", "", -1); set_cookie("c_password", "", -1); } DB::execute("UPDATE user SET last_ip=" . to_sql($_SERVER['REMOTE_ADDR'], "Text") . " WHERE user_id=" . $id . ""); redirect("home.php"); } } elseif (get_cookie("c_user") != "" and get_cookie("c_password") != "") { if (get_session("user_id") != "") { redirect("home.php"); } $name = get_cookie("c_user"); $password = get_cookie("c_password"); $this->message = ""; $id = DB::result("SELECT user_id FROM user WHERE name=" . to_sql($name, "Text") . " and (password=" . to_sql($password, "Text") . " OR password=" . to_sql(md5($password), "Text") . ");"); if ($id == "") { $this->message .= $l['join.php']['incorrect_username'] . "<br>"; } if ($this->message == "") { set_session("user_id", $id); set_session("user_id_verify", $id); DB::execute("UPDATE user SET last_ip='" . $_SERVER['REMOTE_ADDR'] . "' WHERE user_id=" . $id . ""); redirect("home.php"); } } if (get_session("user_id") != "") { redirect("home.php"); } global $m; $m = $this->message; } function parseBlock(&$html) { global $g_info; foreach ($g_info as $k => $v) $html->setvar($k, $v); $html->setvar("login_message", $this->message); parent::parseBlock($html); }}class CJoinForm extends CHtmlBlock{ var $message = ""; var $login = ""; function init() { global $g; global $l; global $gc; $name = get_param("join_handle", ""); $pass = get_param("join_password", ""); $pass2 = get_param("verify_password", ""); $mail = get_param("email", ""); $mail2 = get_param("verify_email", ""); $this->message = ""; if (strlen($name) < 4 or strlen($name) > 20 or strpos($name, "'") !== false) { $this->message .= $l['join.php']['another_username'] . "<br>"; } if ($mail != $mail2 or strlen($mail) > 100 or !preg_match("/^[a-zA-Z-_\.0-9]{1,100}@[a-zA-Z-_\.0-9]{1,100}\.[a-zA-Z-_\.0-9]{1,100}$/", $mail)) { $this->message .= $l['join.php']['incorrect_email'] . "<br>"; } if ($pass != $pass2 or strlen($pass) > 15 or strlen($pass) < 6 or strpos($pass, "'") !== false) { $this->message .= $l['join.php']['incorrect_password'] . "<br>"; } if (DB::result("SELECT user_id FROM user WHERE name=" . to_sql($name, "Text") . ";") != "") { $this->message .= $l['join.php']['exists_username'] . "<br>"; } if (DB::result("SELECT user_id FROM user WHERE mail=" . to_sql($mail, "Text") . ";") != "") { $this->message .= $l['join.php']['exists_email'] . "<br>"; } $month = (int) get_param("month", 1); $day = (int) get_param("day", 1); $year = (int) get_param("year", 1980); if ($month < 1 or $month > 12 or $day < 1 or $day > 31 or $year < 1906 or $year > date("Y") - $g['options']['users_age'] + 1) { $this->message .= $l['join.php']['incorrect_date'] . "<br>"; } if ($this->message == "") { set_session("j_name", $name); set_session("j_password", $pass); set_session("j_mail", $mail); set_session("j_month", $month); set_session("j_day", $day); set_session("j_year", $year); set_session("j_country", get_param("country", 1)); set_session("j_orientation", get_param("orientation", 1)); if ($g['options']['fast_join'] == "N" and isset($gc) and $gc) redirect("join_space.php"); elseif ($g['options']['fast_join'] == "N") redirect("join2.php"); else { $this->add_user(); #echo get_session("user_id"); redirect("home.php"); } } } function add_user() { $partner = (int) get_session("partner"); global $g; DB::execute(" UPDATE partner SET account=(account+" . to_sql($g['options']['partner_price_user'], "Number") . "), summary=(summary+" . to_sql($g['options']['partner_price_user'], "Number") . "), count_users=(count_users+1) WHERE partner_id=" . $partner . " "); $p_partner = DB::result("SELECT p_partner FROM partner WHERE partner_id=" . $partner . ""); $plus = ($g['options']['partner_percent_ref'] / 100) * $g['options']['partner_price_user']; DB::execute(" UPDATE partner SET account=(account+" . $plus . "), summary=(summary+" . $plus . ") WHERE partner_id='" . $p_partner . "' "); $country = DB::result("SELECT country_title FROM geo_country WHERE country_id=" . to_sql(get_session("j_country"), "Number") . ""); DB::execute("INSERT INTO email SET mail=" . to_sql(get_session("j_mail"), "Text") . ""); DB::execute(" INSERT INTO user SET partner=" . $partner . ", gold_days=0, name=" . to_sql(get_session("j_name"), "Text") . ", orientation=" . to_sql(get_session("j_orientation"), "Number") . ", p_orientation=" . to_sql(DB::result("SELECT search FROM const_orientation WHERE id=" . to_sql(get_session("j_orientation"), "Number")), "Number") . ", gender=" . to_sql(DB::result("SELECT gender FROM const_orientation WHERE id=" . to_sql(get_session("j_orientation"), "Number")), "Text") . ", mail=" . to_sql(get_session("j_mail"), "Text") . ", password=" . to_sql($g['options']['md5'] == "Y" ? md5(get_session("j_password")) : get_session("j_password"), "Text") . ", country_id=" . to_sql(get_session("j_country"), "Number") . ", country=" . to_sql($country, "Text") . ", birth=" . to_sql(get_session("j_year") . "-" . get_session("j_month") . "-" . get_session("j_day"), "Text") . ", horoscope=" . to_sql(zodiac(get_session("j_year") . "-" . get_session("j_month") . "-" . get_session("j_day")), "Number") . ", p_horoscope=0, active='Y', active_code='', hide_time='0', register='" . date('Y-m-d H:i:s') . "', last_visit='" . date('Y-m-d H:i:s') . "', last_ip='', set_email_mail='2', set_email_interest='2' "); global $user_id; $user_id = DB::insert_id(); DB::execute(" INSERT INTO userinfo SET user_id=" . $user_id . " "); DB::execute(" INSERT INTO userpartner SET user_id=" . $user_id . " "); DB::execute("DELETE FROM zforum_users WHERE id=".$user_id.";"); DB::execute(" INSERT INTO zforum_users (id,username, group_id, password, email, email_setting, save_pass, registered) VALUES(". $user_id.",". to_sql(get_session("j_name"), "Text"). ", 4, ". to_sql(get_session("j_password"), "Text"). ", ". to_sql(get_session("j_mail"), "Text"). ", 1 , 1 ,1". ");" ); $subject = DB::result("SELECT subject FROM email_auto WHERE note='join'"); $text = DB::result("SELECT text FROM email_auto WHERE note='join'"); $subject = str_replace("{title}", $g['main']['title'], $subject); $text = str_replace("{title}", $g['main']['title'], $text); $text = str_replace("{name}", get_session("j_name"), $text); $text = str_replace("{password}", get_session("j_password"), $text); send_mail( get_session("j_mail"), $g['main']['info_mail'], $subject, $text ); #session_unset(); set_session("user_id", $user_id); set_session("user_id_verify", $user_id); } function parseBlock(&$html) { global $g; global $g_info; global $l; foreach ($g_info as $k => $v) $html->setvar($k, $v); $name = get_param("join_handle", ""); $pass = get_param("join_password", ""); $pass2 = get_param("verify_password", ""); $mail = get_param("email", ""); $mail2 = get_param("verify_email", ""); $html->setvar("join_handle", $name); $html->setvar("join_password", $pass); $html->setvar("verify_password", $pass2); $html->setvar("email", $mail); $html->setvar("verify_email", $mail2); if ($name != "") $html->setvar("join_message", $this->message); $m = array( 1 => isset($l['all']['january']) ? $l['all']['january'] : 'January', 2 => isset($l['all']['february']) ? $l['all']['february'] : 'February', 3 => isset($l['all']['march']) ? $l['all']['march'] : 'March', 4 => isset($l['all']['april']) ? $l['all']['april'] : 'April', 5 => isset($l['all']['may']) ? $l['all']['may'] : 'May', 6 => isset($l['all']['june']) ? $l['all']['june'] : 'June', 7 => isset($l['all']['july']) ? $l['all']['july'] : 'July', 8 => isset($l['all']['august']) ? $l['all']['august'] : 'August', 9 => isset($l['all']['september']) ? $l['all']['september'] : 'September', 10 => isset($l['all']['october']) ? $l['all']['october'] : 'October', 11 => isset($l['all']['november']) ? $l['all']['november'] : 'November', 12 => isset($l['all']['december']) ? $l['all']['december'] : 'December', ); $html->setvar("month_options", h_options($m, get_param("month", 1))); $html->setvar("day_options", n_options(1, 31, get_param("day", 1))); $html->setvar("year_options", n_options(date("Y") - $g['options']['users_age_max'], date("Y") - $g['options']['users_age'] + 1, get_param("year", date("Y") - $g['options']['users_age_max']))); $html->setvar("country_options", DB::db_options("SELECT country_id, country_title FROM geo_country WHERE country_id in (1,2,3)" , 3) . DB::db_options("SELECT country_id, country_title FROM geo_country ORDER BY country_title" , "")); $html->setvar("orientation_options", DB::db_options("SELECT id, title FROM const_orientation", get_param("orientation", ""))); parent::parseBlock($html); }}$page = new CIndex("", $g['tmpl']['dir_tmpl_main'] . "join.html");$header = new CHeader("header", $g['tmpl']['dir_tmpl_main'] . "_header.html");$page->add($header);$footer = new CFooter("footer", $g['tmpl']['dir_tmpl_main'] . "_footer.html");$page->add($footer);$register = new CJoinForm("join", null);$page->add($register);include("./_include/core/main_close.php");?> Link to comment Share on other sites More sharing options...
justsomeguy Posted April 1, 2008 Share Posted April 1, 2008 What is the code for the send_mail function? Add statements in it to print out all of the variables that go to the PHP mail function. Also make sure that the messages aren't just ending up in the junk folder. Link to comment Share on other sites More sharing options...
unplugged_web Posted April 1, 2008 Author Share Posted April 1, 2008 What is the code for the send_mail function? Add statements in it to print out all of the variables that go to the PHP mail function. Also make sure that the messages aren't just ending up in the junk folder.Sorry I didn't get what you meant about 'send_mail function' Also I've tried around 30 different email address and have made sure that all of them have the spam filter switched off, I've also checked the junk folders.Thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted April 1, 2008 Share Posted April 1, 2008 send_mail( get_session("j_mail"), $g['main']['info_mail'], $subject, $text ); It's executing a function called send_mail. That function is doing all the work. Link to comment Share on other sites More sharing options...
unplugged_web Posted April 1, 2008 Author Share Posted April 1, 2008 send_mail( get_session("j_mail"), $g['main']['info_mail'], $subject, $text ); It's executing a function called send_mail. That function is doing all the work. Okay I see that. I guess that's taking the information from the database to send out the email? Can I change it so that emails will be sent to every type of email account - regardless of whether it's a hotmail or not.At the moment the site is on a Linux server, but when it goes live it'll be a windows server. I don't know if that makes a difference, but though it was worth mentioning Link to comment Share on other sites More sharing options...
justsomeguy Posted April 1, 2008 Share Posted April 1, 2008 I guess that's taking the information from the database to send out the email?I don't know, I have no idea what it's doing, that's why the code is handy. You need to add print statements inside the send_mail function to have it print everything that it is sending to the PHP mail function (I'm assuming it's using the mail function to send the mail). You need to get down to the lowest level and work backwards to find the problem, the lowest level is probably the mail function. So step 1 is to figure out what arguments the mail function is being sent. The send_mail function will tell you that. Link to comment Share on other sites More sharing options...
unplugged_web Posted April 2, 2008 Author Share Posted April 2, 2008 I don't know, I have no idea what it's doing, that's why the code is handy. You need to add print statements inside the send_mail function to have it print everything that it is sending to the PHP mail function (I'm assuming it's using the mail function to send the mail). You need to get down to the lowest level and work backwards to find the problem, the lowest level is probably the mail function. So step 1 is to figure out what arguments the mail function is being sent. The send_mail function will tell you that.Sorry to be so dumb, but I don't get it. Where do I put the print function? I've created a test script:<?php$message = "{$_POST['company']}\n{$_POST['address']}\n{$_POST['number']}\n{$_POST['email']}\n{$_POST['message']}\n-fuser@somewhere.com";ini_set("sendmail_from", 'info@somewhere.com');mail("info@somewhere.com","contact via website","$message");?> and built a basic form to send the results. That all worked perfectly.The problem I'm certain is with: $subject = DB::result("SELECT subject FROM email_auto WHERE note='join'"); $text = DB::result("SELECT text FROM email_auto WHERE note='join'"); $subject = str_replace("{title}", $g['main']['title'], $subject); $text = str_replace("{title}", $g['main']['title'], $text); $text = str_replace("{name}", get_session("j_name"), $text); $text = str_replace("{password}", get_session("j_password"), $text); send_mail( get_session("j_mail"), $g['main']['info_mail'], $subject, $text ); I guess this is defining the parameters that are being sent $month = (int) get_param("month", 1); $day = (int) get_param("day", 1); $year = (int) get_param("year", 1980); if ($month < 1 or $month > 12 or $day < 1 or $day > 31 or $year < 1906 or $year > date("Y") - $g['options']['users_age'] + 1) { $this->message .= $l['join.php']['incorrect_date'] . "<br>"; } if ($this->message == "") { set_session("j_name", $name); set_session("j_password", $pass); set_session("j_mail", $mail); set_session("j_month", $month); set_session("j_day", $day); set_session("j_year", $year); set_session("j_country", get_param("country", 1)); set_session("j_orientation", get_param("orientation", 1)); The form that is collecting the information is: <form name="JoinForm" method="post" action="{url_main}join.php" onsubmit="return validateJoinForm();"> <div class="header_big" style="padding-top: 15px; padding-right: 14px; text-align: right; background-image: url({url_tmpl_main}images/join_top.jpg); background-repeat: no-repeat;">Sign up for free! </div> <div id="join" style="padding-bottom: 10px; padding-top: 5px; background-image: url({url_tmpl_main}images/join_content.jpg);"> <div style="color: #FF0000; font-weight: bold; font-size: 11px; padding-right: 10px;">{join_message}</div><br /> <label for="username">{l_username}:</label><input type="text" id="username" name="join_handle" value="{join_handle}" /><br /> <label for="create-password">{l_create_password}:</label><input type="password" id="create-password" name="join_password" value="{join_password}" /><br /> <label for="re-password">{l_reenter_password}:</label><input type="password" id="re-password" name="verify_password" value="{join_password}" /><br /> <label for="email">{l_email}:</label><input type="text" id="email" name="email" value="{email}" /><br /> <label for="re-email">{l_reemail}:</label><input type="text" id="re-email" name="verify_email" value="{email}" /><br /> <label for="iam">{l_i_am}:</label> <select name="orientation" id="iam"> {orientation_options} </select> <br /> <label for="from">{l_from}:</label> <select name="country" id="from"> <option value="-1" selected="selected">{l_country_select}</option> {country_options} </select> <br /> <label for="month">{l_born_on}:</label> <select name="month" id="month" onchange="updateDay('month','JoinForm','year','month','day')"> {month_options} </select> <select name="day" id="day"> {day_options} </select> <select name="year" id="year" onchange="updateDay('year','JoinForm','year','month','day')"> {year_options} </select> <br /> </div> <div id="terms" style="padding-right: 10px; width: 352px; background-image: url({url_tmpl_main}images/join_content.jpg);"><input name="privacy_policy" type="checkbox" value="true" id="agree" checked> <label for="agree"> {l_i_agree} <a href="java script:winpop('{url_tmpl_main}popup/term_cond.html','960','600','yes');">{l_terms_and_conditions}</a> and <a href="java script:winpop('{url_tmpl_main}popup/priv_policy.html','960','600','yes');">{l_privacy_policy}</a> <br /></label></div><div id="terms" style="padding-right: 10px; height: 50px; width: 352px; background-image: url({url_tmpl_main}images/join_bottom.jpg); background-repeat: no-repeat;"><input type="button" value="" onclick="submitJoinForm();" class="button-join" style=" margin-right: 13px; margin-top: 5px; cursor: pointer; cursor: hand;" /> </form> I've checked the from email address and it's definitely not blacklisted, the thing that I just don't get is how come it works with hotmail email addresses, but not any others Link to comment Share on other sites More sharing options...
unplugged_web Posted April 2, 2008 Author Share Posted April 2, 2008 Somebody suggested that the code was written for php 4 and that I needed to add ini_set("sendmail_from", " email@mydomain.com ") so I changed the code to: $subject = DB::result("SELECT subject FROM email_auto WHERE note='join'"); $text = DB::result("SELECT text FROM email_auto WHERE note='join'"); $subject = str_replace("{title}", $g['main']['title'], $subject); $text = str_replace("{title}", $g['main']['title'], $text); $text = str_replace("{name}", get_session("j_name"), $text); $text = str_replace("{password}", get_session("j_password"), $text);send_mail( ini_set("sendmail_from", " email@mydomain.com "), get_session("j_mail"), $g['main']['info_mail'], $subject, $text ); but it still didn't work. I don't know if put the ini_set function in the wrong place or not Link to comment Share on other sites More sharing options...
justsomeguy Posted April 2, 2008 Share Posted April 2, 2008 No, that's not in the right place, but that code doesn't even matter. That code gets results out of the database and sends them to a function called send_mail. That's fine. We are only interested in the code for the send_mail function, that function is defined in one of your files somewhere, I don't know where. But you are including some file that defines send_mail, we need to see what the definition of that function is. That is the important part. If you can't find it, download a text editor like ConTEXT and use it to open all of your files and search all of them at once for "send_mail", one of the results should start with "function send_mail (".. , that is the part we need. We need to figure out what send_mail is doing with all of the data that it's being sent. I assume the data is fine, we need to figure out what it's doing with it. Link to comment Share on other sites More sharing options...
unplugged_web Posted April 2, 2008 Author Share Posted April 2, 2008 No, that's not in the right place, but that code doesn't even matter. That code gets results out of the database and sends them to a function called send_mail. That's fine. We are only interested in the code for the send_mail function, that function is defined in one of your files somewhere, I don't know where. But you are including some file that defines send_mail, we need to see what the definition of that function is. That is the important part. If you can't find it, download a text editor like ConTEXT and use it to open all of your files and search all of them at once for "send_mail", one of the results should start with "function send_mail (".. , that is the part we need. We need to figure out what send_mail is doing with all of the data that it's being sent. I assume the data is fine, we need to figure out what it's doing with it.Sorry I misunderstood. I found a mail.php files that contains the function send_mail. The contents of the file are:<?phpfunction send_mail($to, $from, $subject, $message){ global $g; if (isset($g['options']['mail_html']) and $g['options']['mail_html'] == "Y") $ct = "text/html"; else $ct = "text/plain"; if (isset($g['options']['mail_utf8']) and $g['options']['mail_utf8'] == "Y") { $headers = "From: " . $from . "\n"; $headers .= "Content-Type: " . $ct . "; charset=utf-8;\n"; $headers .= "Reply-To: " . $from . ";\n"; $headers .= "Return-Path: " . $from . ";\n"; } else { $headers = "From: " . $from . "\n"; $headers .= "Content-Type: " . $ct . ";\n"; $headers .= "Reply-To: " . $from . ";\n"; $headers .= "Return-Path: " . $from . ";\n"; } if (isset($g['options']['mail_utf8_subject']) and $g['options']['mail_utf8_subject'] == "Y") $subject = '=?UTF-8?B?'.base64_encode(trim(preg_replace('#[\n\r]+#s', '', $subject)))."?=\n"; mail($to, $subject, $message, $headers);} Link to comment Share on other sites More sharing options...
justsomeguy Posted April 2, 2008 Share Posted April 2, 2008 So before this line:mail($to, $subject, $message, $headers);Print out those 4 variables to see what they are. Link to comment Share on other sites More sharing options...
unplugged_web Posted April 2, 2008 Author Share Posted April 2, 2008 So before this line:mail($to, $subject, $message, $headers);Print out those 4 variables to see what they are.How do I do that? Link to comment Share on other sites More sharing options...
justsomeguy Posted April 2, 2008 Share Posted April 2, 2008 echo $to . "<br>" . $subject . "<br>" . $message . "<br>" . $headers; Link to comment Share on other sites More sharing options...
kv79 Posted April 2, 2008 Share Posted April 2, 2008 Maybe you do not know ,but you also have a www.createforum.comIt is useful for me . Link to comment Share on other sites More sharing options...
unplugged_web Posted April 3, 2008 Author Share Posted April 3, 2008 echo $to . "<br>" . $subject . "<br>" . $message . "<br>" . $headers;I tried that, just got a totally blank page. I know I put it in the right place because when I changed echo $to . "<br>" . $subject . "<br>" . $message . "<br>" . $headers; to echo "hello"; it displayed hello Link to comment Share on other sites More sharing options...
kv79 Posted April 3, 2008 Share Posted April 3, 2008 Can you tell me ,what browser did you use when you doing that ? Link to comment Share on other sites More sharing options...
Synook Posted April 3, 2008 Share Posted April 3, 2008 Maybe you do not know ,but you also have awww.createforum.comIt is useful for me . what is your first language, kv79?I tried that, just got a totally blank page. I know I put it in the right place because when I changed echo $to . "<br>" . $subject . "<br>" . $message . "<br>" . $headers; to echo "hello"; it displayed helloErrr that's weird, try printing out $text from before where you call the function. Link to comment Share on other sites More sharing options...
kv79 Posted April 3, 2008 Share Posted April 3, 2008 -> Synook what is your first language, kv79?C Link to comment Share on other sites More sharing options...
unplugged_web Posted April 3, 2008 Author Share Posted April 3, 2008 Errr that's weird, try printing out $text from before where you call the function.Nope still nothing Link to comment Share on other sites More sharing options...
Synook Posted April 3, 2008 Share Posted April 3, 2008 That is echoing from before the function call? Well in that case either there is something wrong with the DB::result class, you are using it inappropriately, or your query is not returning anything. What does that class look like? Link to comment Share on other sites More sharing options...
unplugged_web Posted April 3, 2008 Author Share Posted April 3, 2008 That is echoing from before the function call? Well in that case either there is something wrong with the DB::result class, you are using it inappropriately, or your query is not returning anything. What does that class look like?This is what I did<?phpecho $to . "<br>" . $subject . "<br>" . $message . "<br>" . $headers;function send_mail($to, $from, $subject, $message){ global $g; if (isset($g['options']['mail_html']) and $g['options']['mail_html'] == "Y") $ct = "text/html"; else $ct = "text/plain"; if (isset($g['options']['mail_utf8']) and $g['options']['mail_utf8'] == "Y") { $headers = "From: " . $from . "\n"; $headers .= "Content-Type: " . $ct . "; charset=utf-8;\n"; $headers .= "Reply-To: " . $from . ";\n"; $headers .= "Return-Path: " . $from . ";\n"; } else { $headers = "From: " . $from . "\n"; $headers .= "Content-Type: " . $ct . ";\n"; $headers .= "Reply-To: " . $from . ";\n"; $headers .= "Return-Path: " . $from . ";\n"; } if (isset($g['options']['mail_utf8_subject']) and $g['options']['mail_utf8_subject'] == "Y") $subject = '=?UTF-8?B?'.base64_encode(trim(preg_replace('#[\n\r]+#s', '', $subject)))."?=\n"; mail($to, $subject, $message, $headers); }?> Link to comment Share on other sites More sharing options...
Synook Posted April 3, 2008 Share Posted April 3, 2008 not quite - we want to catch the variables that are being sent to the function, so<?phpfunction send_mail($to, $from, $subject, $message){ echo $to . "<br>" . $subject . "<br>" . $message . "<br>" . $headers; global $g; if (isset($g['options']['mail_html']) and $g['options']['mail_html'] == "Y") $ct = "text/html"; else $ct = "text/plain"; if (isset($g['options']['mail_utf8']) and $g['options']['mail_utf8'] == "Y") { $headers = "From: " . $from . "\n"; $headers .= "Content-Type: " . $ct . "; charset=utf-8;\n"; $headers .= "Reply-To: " . $from . ";\n"; $headers .= "Return-Path: " . $from . ";\n"; } else { $headers = "From: " . $from . "\n"; $headers .= "Content-Type: " . $ct . ";\n"; $headers .= "Reply-To: " . $from . ";\n"; $headers .= "Return-Path: " . $from . ";\n"; } if (isset($g['options']['mail_utf8_subject']) and $g['options']['mail_utf8_subject'] == "Y") $subject = '=?UTF-8?B?'.base64_encode(trim(preg_replace('#[\n\r]+#s', '', $subject)))."?=\n"; mail($to, $subject, $message, $headers); }?> Link to comment Share on other sites More sharing options...
unplugged_web Posted April 3, 2008 Author Share Posted April 3, 2008 not quite - we want to catch the variables that are being sent to the function, so<?phpfunction send_mail($to, $from, $subject, $message){ echo $to . "<br>" . $subject . "<br>" . $message . "<br>" . $headers; global $g; if (isset($g['options']['mail_html']) and $g['options']['mail_html'] == "Y") $ct = "text/html"; else $ct = "text/plain"; if (isset($g['options']['mail_utf8']) and $g['options']['mail_utf8'] == "Y") { $headers = "From: " . $from . "\n"; $headers .= "Content-Type: " . $ct . "; charset=utf-8;\n"; $headers .= "Reply-To: " . $from . ";\n"; $headers .= "Return-Path: " . $from . ";\n"; } else { $headers = "From: " . $from . "\n"; $headers .= "Content-Type: " . $ct . ";\n"; $headers .= "Reply-To: " . $from . ";\n"; $headers .= "Return-Path: " . $from . ";\n"; } if (isset($g['options']['mail_utf8_subject']) and $g['options']['mail_utf8_subject'] == "Y") $subject = '=?UTF-8?B?'.base64_encode(trim(preg_replace('#[\n\r]+#s', '', $subject)))."?=\n"; mail($to, $subject, $message, $headers); }?> Still blank Link to comment Share on other sites More sharing options...
Synook Posted April 3, 2008 Share Posted April 3, 2008 Did you try echoing $text just before you call send_mail? echo $text;send_mail(... Link to comment Share on other sites More sharing options...
unplugged_web Posted April 3, 2008 Author Share Posted April 3, 2008 Did you try echoing $text just before you call send_mail?echo $text;send_mail(... Ooh no I didn't, but I movedini_set("sendmail_from", " email@mydomain.com "), to ini_set("sendmail_from", " email@mydomain.com "), $subject = DB::result("SELECT subject FROM email_auto WHERE note='join'"); $text = DB::result("SELECT text FROM email_auto WHERE note='join'"); $subject = str_replace("{title}", $g['main']['title'], $subject); $text = str_replace("{title}", $g['main']['title'], $text); $text = str_replace("{name}", get_session("j_name"), $text); $text = str_replace("{password}", get_session("j_password"), $text);send_mail( get_session("j_mail"), $g['main']['info_mail'], $subject, $text ); and I just got an email from the site!! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.