Dummy Mail() headers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
m_m
Forum Newbie
Posts: 9
Joined: Fri Jun 04, 2004 5:54 pm

Dummy Mail() headers

Post by m_m »

Im using the PHP mail() fn to send txt msgs. A txt msg is nothing more than an email to a cell phone. No big deal. Problem is, when the cell phone recieves the msg, the actual server address is used as the reply address. Its the first thing displayed on the cell phone. I tried changing all of the headers by including them in the mail() line, but it still doesnt work.

How do I get it to say whatever return address i like?
Do i have to change something in php.ini or does my hosting provider have to turn something on.off??

thanks
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

I'm not exactly sure what you meant by "tried changing the headers", but try this code:

Code: Select all

<?php
mail ("yourcellphone@someaddr.com", "My Subject", "This is just a test message", 
"FROM EvilMonkey\r\n".
"REPLY-TO: evilmonkey@{$_SERVER[SERVER_NAME]}");
?>
Might just waork. Taken straight from the PHP manual. http://ca2.php.net/manual/en/function.mail.php

Good luck!
m_m
Forum Newbie
Posts: 9
Joined: Fri Jun 04, 2004 5:54 pm

Post by m_m »

Sorry, thats what i ment. Changing Reply-To: as you did will work when in the email, but i need to change the return-path. Im sending txt msgs. it doesnt display the from or reply to addreess, but the return path for some odd reason. What is to be displayed is set in php.ini, but my host doesnt seem to want to help (godaddy). I tried overwriting the send_from setting in the .ini wih ini_set() and even creating an .htaccess file, but neither work.

I cant figure out why. Any ideas?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Last I saw, the case and syntax of the headers was extremely important:

Code: Select all

mail(
"to_whoever@some_domain.com",
"subject line",
"message",
"From: from_me@mydomain.com\r\n".
"Reply-To: from_someone@elses_domain.com\r\n". // it may be Reply-to, but all the email I quickly checked was 'T'
"Return-Path: yet_another@address.com\r\n" // again, could be Return-path, I couldn't find an example in my email though..
);
hypercooljake
Forum Newbie
Posts: 6
Joined: Sat Nov 01, 2003 12:48 pm
Location: Appleton, Wi
Contact:

Post by hypercooljake »

feyd wrote:Last I saw, the case and syntax of the headers was extremely important:

Code: Select all

mail(
"to_whoever@some_domain.com",
"subject line",
"message",
"From: from_me@mydomain.com\r\n".
"Reply-To: from_someone@elses_domain.com\r\n". // it may be Reply-to, but all the email I quickly checked was 'T'
"Return-Path: yet_another@address.com\r\n" // again, could be Return-path, I couldn't find an example in my email though..
);
It is Reply-To: and Return-Path:, not to or path.
m_m
Forum Newbie
Posts: 9
Joined: Fri Jun 04, 2004 5:54 pm

Post by m_m »

Yeah, I had Return-Path: exactly as you did. Apparently, you can NOT change return-path in the headers, just reply-to. I know the var i have to change is send_from in php.ini, but it doesnt work. I cant figure out why
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

There is the additional problem of the fact that even if you did manage to hide/mangle this value - there are a significant number or mail servers out there that wouldn't even accept the mail for delivery because of the malformed headers, let alone try to send it.
m_m
Forum Newbie
Posts: 9
Joined: Fri Jun 04, 2004 5:54 pm

Post by m_m »

Listen, I know it can be changed. My Question is, is there any reason i would not be able to change the send_from value in the ini file with ini_set()? I figured if it didnt work in .htaccess files it was because they were not allowed.
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

Because there is no such value? It's sendmail_from, not send_from - and you can set it from anything (script, htaccess, php.ini).
m_m
Forum Newbie
Posts: 9
Joined: Fri Jun 04, 2004 5:54 pm

Post by m_m »

Ah, sorry thats what i ment. Either way, doesnt work. =/
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

To be honest the name "sendmail_from" implies it might be only related to sendmail.. which not all ISPs use (I know mine doesn't). Just a guess though. m_m - suggest you try asking this on the php.general mailing list.
Post Reply