Hi there, I have a sms script (e-mail to sms), but each time I send a message it displays my server name: as sender, can I change this to the name of my site Greetz Smetten
Depends on the script. But look on php.net for the mail() function, you can set the headers, including both the FROM and RETURN address.
This is the script i use, can you tell me what I should add, I found lots of stuff on php.net about the mail() function but I can´t seem to get it working on my script... Thx in advance Greetz Smetten <? echo ' '; include 'config.php'; echo ' '; if (strtoupper ($code) == substr (strtoupper (md5 ('Mytext' . $sessioncode)), 0, 6)) { } else { } echo ' '; $day = date ('mdy'); $ip = gethostbyname ($REMOTE_ADDR); $checkuses = mysql_num_rows (mysql_query ('' . 'select * from users where ip=\'' . $ip . '\' and day=\'' . $day . '\'')); if ($alloweduses <= $checkuses) { echo '<DIV class=front id=content><H1 align=center>This was your last Free Message for today.<br><br>'; exit(''); } else { $query = '' . 'INSERT INTO users VALUES (\'' . $ip . '\',\'' . $number . '\',\'' . $day . '\')'; if (!($result = mysql_query ($query))) { exit ('Unable to Add IP Entry'); ; } } echo ' '; $sql = '' . 'SELECT * FROM carriers WHERE id = \'' . $carrier . '\''; $result = mysql_query ($sql); $row = mysql_fetch_array ($result); $email = $row['email']; $to = $number . $email; $headers = 'MIME-Version: 1.0 ' . 'Content-type: text/html; charset=iso-8859-1 ' . 'To: "Client" <' . $to . '> ' . 'Date: ' . date ('r') . ' ' . 'Subject: ' . $subject . ' '; mail ($to, $subject, $message); echo ' '; echo '<DIV class=front id=content><H1 align=center>Message sent!</H1><br><p>'; echo '<b>TO:</b> ' . $to . '<br><br>'; echo '<b>SUBJECT:</b> ' . $subject . '<br><br>'; echo '<b>MESSAGE:</b> ' . $message . '<br><br><br><br><br>'; echo ' <p align=center><font size=3><a href=sms.php><span class=navigation1>Send Another Message</span></font></a>'; echo ' '; ?> PHP:
Sorry mate, But I'm a newbie at this whole php stuff, I´ve tried adding the from code to the header part, but each time I tried i get a parsing error. Can you show me what I should add to the code posted in one of my previeous posts on this thread?. Thx in advance. Smetten
Without seeing the error message and the code you are attempting, it's a bit hard to help. There's not many people who will just write it for you from scratch. It's better to show what you have and we'll fix where you went wrong. Better for learning as well.
This is the code (form) where people enter the phone number, message and carrier they want to sent too <form action="mail.php" method="post"> Mobile Number (to):<br> <input name="number" size="30" maxlength="30" type="text" class="styled"> <br><br> Subject:<br> <input type="text" name="subject" size="30" class="styled"> <br><br> Select Carrier:<br> <select name="carrier" class="styled"> <? $sql = "SELECT * FROM carriers"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { ?> <option value="<? echo $row["id"]; ?>"><? echo $row["name"]; ?></option> <? } ?> </select> <br><br> Enter Message:<br> <textarea type="text" name="message" rows="4" cols="30" class="styled"></textarea> <br> <br> <input type="submit" name="Submit" value="send your message"> </form> PHP: This is the code that makes sure the e-mails are sent out. <? session_start (); session_register ('sessioncode'); echo ' '; include 'config.php'; echo ' '; include 'header.php'; echo ' '; if (strtoupper ($code) == substr (strtoupper (md5 ('Mytext' . $sessioncode)), 0, 6)) { } else { } echo ' '; $day = date ('mdy'); $ip = gethostbyname ($REMOTE_ADDR); $checkuses = mysql_num_rows (mysql_query ('' . 'select * from users where ip=\'' . $ip . '\' and day=\'' . $day . '\'')); if ($alloweduses <= $checkuses) { echo '<DIV class=front id=content><H1>Sorry, you have used all of your free messages for today. Come back tomorrow.</H1></div>'; include 'footer.php'; exit (); } else { $query = '' . 'INSERT INTO users VALUES (\'' . $ip . '\',\'' . $number . '\',\'' . $day . '\')'; if (!($result = mysql_query ($query))) { exit ('Unable to Add IP Entry'); ; } } echo ' '; $sql = '' . 'SELECT * FROM carriers WHERE id = \'' . $carrier . '\''; $result = mysql_query ($sql); $row = mysql_fetch_array ($result); $email = $row['email']; $to = $number . $email; $headers = 'MIME-Version: 1.0 ' . 'Content-type: text/html; charset=iso-8859-1 ' . 'To: "Client" <' . $to . '> ' . 'Date: ' . date ('r') . ' ' . 'Subject: ' . $subject . ' '; mail ($to, $subject, $message); echo ' '; echo '<DIV class=front id=content><H1>Message sent!</H1><br><p>'; echo 'TO: ' . $to . '<br>'; echo 'SUBJECT: ' . $subject . '<br>'; echo 'MESSAGE: ' . $message . '<br><br>'; echo 'HEADERS: ' . $headers . '<br><br>'; echo 'Click <a href="sms.php">here</a> to go back and send another message.</p></div>'; echo ' '; include 'footer.php'; ?> PHP: I know want the sender to be Xorak.com instead of my sever name. How can I do this plz? Can you now show me were i should make the changes? Greetz Smetten
A lot of SMS scripts don;t allow you to change the FROM. But just try and get a from in the header as per php's mail() function.
Parse error: parse error, unexpected '@' in /home/content/s/m/e/smetten/html/mail.php on line 347 This is the error i get when i added your suggestion
It should be: ' . 'From: webmaster@example.com ' . 'Date: ' . date ('r') . ' ' . 'Subject: ' . $subject . ' '; PHP:
now i don´t get a parsing error but the sender is still my server name, guess it just doesn´t work... sadly enough
This is the form where users can enter there msg, the carrier and the phone number www.xorak.com/sms.php I´ve send one to my hotmail account and this is how it looks like: from: <smetten@linhost191.prod.mesa1.secureserver.net> send: vrijdag 6 oktober 2006 17:10:33 too: subject: test This is a test
Try adding 'reply to' as well: 'From: 'Reply-To: Hotmail and other big ISPs are known to take the sendfrom value from the php.ini file though. If you really want to change it, yuo might want to hack up that file as well to be sure.
nah didn´t work either, www.xorak.com/sms.php if your carrier is in the list can you check what you get as sender? Or if your from the US or Canada try the second script on that page. I cant try it as i'm from Belgium and our carriers don´t support this method... Greetz