jrw4 Posted December 21, 2009 Share Posted December 21, 2009 Hey guys, I want to be able to send texts to phones via email (since each phone has their own address), and for specifying the from, I want to specify my own number, is there a way to do this? For example: $from = '7785555555'; if(mail($to, $subject, $message, "From: $from")) echo "Mail sent"; If I do this, the From in the email will be 7785555555@hostname.com. Is there any way I can send it so that it doesn't auto append the host name? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/185861-prevent-php-mail-from-appending-hostname-to-from-address/ Share on other sites More sharing options...
canadabeeau Posted December 21, 2009 Share Posted December 21, 2009 so you can add your own hostname?? Quote Link to comment https://forums.phpfreaks.com/topic/185861-prevent-php-mail-from-appending-hostname-to-from-address/#findComment-981426 Share on other sites More sharing options...
Adam Posted December 21, 2009 Share Posted December 21, 2009 I don't think so. Being as this is email, it's expected to be received from another email address. You could try this though: $from = '7785555555 <noreply@example.com>'; Quote Link to comment https://forums.phpfreaks.com/topic/185861-prevent-php-mail-from-appending-hostname-to-from-address/#findComment-981427 Share on other sites More sharing options...
jrw4 Posted December 21, 2009 Author Share Posted December 21, 2009 so you can add your own hostname?? No, I don't want any hostname. I want the user to be able to see on the sms that it is just from "7785555555". Quote Link to comment https://forums.phpfreaks.com/topic/185861-prevent-php-mail-from-appending-hostname-to-from-address/#findComment-981429 Share on other sites More sharing options...
oni-kun Posted December 21, 2009 Share Posted December 21, 2009 so you can add your own hostname?? No, I don't want any hostname. I want the user to be able to see on the sms that it is just from "7785555555". So now you expect an e-mail being able to be recieved, from a host that does not exist. The host will drop the e-mail like it's a virus, won't land even in your spam box, I doubt it Quote Link to comment https://forums.phpfreaks.com/topic/185861-prevent-php-mail-from-appending-hostname-to-from-address/#findComment-981446 Share on other sites More sharing options...
jrw4 Posted December 23, 2009 Author Share Posted December 23, 2009 So now you expect an e-mail being able to be recieved, from a host that does not exist. The host will drop the e-mail like it's a virus, won't land even in your spam box, I doubt it Whether or not I expect an email to be received from a non-existant host is beside the question. I am asking if it is possible to prevent PHP from adding its hostname to the "from address" when sending a message with the mail() function. Quote Link to comment https://forums.phpfreaks.com/topic/185861-prevent-php-mail-from-appending-hostname-to-from-address/#findComment-982800 Share on other sites More sharing options...
archonis Posted December 23, 2009 Share Posted December 23, 2009 You edit the headers. I do it all the time so it does not show my server name in the e-mail. <?php $to = "yourplace@somewhere.com"; $subject = "My email test."; $message = "Hello, how are you?"; $headers = "From: myplace@here.com\r\n"; $headers .= "Reply-To: myplace2@here.com\r\n"; $headers .= "Return-Path: myplace@here.com\r\n"; $headers .= "CC: sombodyelse@noplace.com\r\n"; $headers .= "BCC: hidden@special.com\r\n"; if ( mail($to,$subject,$message,$headers) ) { echo "The email has been sent!"; } else { echo "The email has failed!"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/185861-prevent-php-mail-from-appending-hostname-to-from-address/#findComment-982802 Share on other sites More sharing options...
archonis Posted December 23, 2009 Share Posted December 23, 2009 <?php $to = "5555555555@vtext.com"; $subject = "My sms test."; $message = "Hello, how are you?"; $headers = "From: 9996663333@here.com\r\n"; $headers .= "Reply-To: 9996663333@here.com\r\n"; $headers .= "Return-Path: 9996663333@here.com\r\n"; if ( mail($to,$subject,$message,$headers) ) { echo "The SMS has been sent!"; } else { echo "The SMS has failed!"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/185861-prevent-php-mail-from-appending-hostname-to-from-address/#findComment-982803 Share on other sites More sharing options...
jrw4 Posted December 23, 2009 Author Share Posted December 23, 2009 If I try setting the headers to "$headers = "From: 9996663333@here.com\r\n";" then the user will see "9996663333here.com" on their cell phone when they receive the text message. All I want them to see is "9996663333" on their cell phone. Quote Link to comment https://forums.phpfreaks.com/topic/185861-prevent-php-mail-from-appending-hostname-to-from-address/#findComment-982822 Share on other sites More sharing options...
archonis Posted December 23, 2009 Share Posted December 23, 2009 Dont add the @here.com Quote Link to comment https://forums.phpfreaks.com/topic/185861-prevent-php-mail-from-appending-hostname-to-from-address/#findComment-982824 Share on other sites More sharing options...
archonis Posted December 23, 2009 Share Posted December 23, 2009 Oh, I forgot to tell you. You can make that say anything you want. "$headers = "From:YOUR BOSS NAME" becomes a nice joke. Quote Link to comment https://forums.phpfreaks.com/topic/185861-prevent-php-mail-from-appending-hostname-to-from-address/#findComment-982825 Share on other sites More sharing options...
jrw4 Posted December 24, 2009 Author Share Posted December 24, 2009 Dont add the @here.com But that is what I said already... if I try $header = "From: 9996663333"; Then PHP appends the host name to the from field (see thread topic). So the phone will then see that the SMS is from 9996663333@host. I do not want this, I am asking how to stop PHP from appending the hostname on the from field of an email. Quote Link to comment https://forums.phpfreaks.com/topic/185861-prevent-php-mail-from-appending-hostname-to-from-address/#findComment-983400 Share on other sites More sharing options...
oni-kun Posted December 24, 2009 Share Posted December 24, 2009 Dont add the @here.com But that is what I said already... if I try $header = "From: 9996663333"; Then PHP appends the host name to the from field (see thread topic). So the phone will then see that the SMS is from 9996663333@host. I do not want this, I am asking how to stop PHP from appending the hostname on the from field of an email. Grow up. Can you send data from a machine without an IP address? The recipient physically has to have the connection from their SMTP server to yours to recieve the message. If the host does not recieve a HOSTNAME, than it will drop it in error. Further, if you're sending it to a mobile host, than obviously it'll need its host to be 'vtext.com' and not blank, nor yours. EDIT: What on earth does PHP have to do with an SMTP wrapper class? PHP isn't appending anything. Quote Link to comment https://forums.phpfreaks.com/topic/185861-prevent-php-mail-from-appending-hostname-to-from-address/#findComment-983403 Share on other sites More sharing options...
archonis Posted December 24, 2009 Share Posted December 24, 2009 There is some error in your statment about IPs but i'm not here to disprove anyone. As long as the to email has the @something.com it does not matter about the from. This is how spammers work. You should be able to make the from header anything you want. That is nothing more then a cover up. In the stmp or imap or pop 3 the real host name is still there but is only osed as a trace. The from is just so the end user will have a reply back. Quote Link to comment https://forums.phpfreaks.com/topic/185861-prevent-php-mail-from-appending-hostname-to-from-address/#findComment-983416 Share on other sites More sharing options...
jrw4 Posted December 24, 2009 Author Share Posted December 24, 2009 Grow up. Can you send data from a machine without an IP address? ... EDIT: What on earth does PHP have to do with an SMTP wrapper class? PHP isn't appending anything. Holy random attack batman. Can you send data from a machine sans IP? I dunno, I know little about networks but I would assume you can. What does PHP have to do with the SMTP wrapper? I have no idea, again I do not study networks. @archonis I am trying to be able to send SMS texts to a phone as you already know so I want the "from" to be a phone number so if the user replies they will be replying to a phone. I have no idea of another way to send SMS to a phone with PHP (or any other web language) except for the technique I am currently using which is sending emails. I want the SMS to appear as an SMS and not an email which is why I don't want the @host to be appended. Quote Link to comment https://forums.phpfreaks.com/topic/185861-prevent-php-mail-from-appending-hostname-to-from-address/#findComment-983432 Share on other sites More sharing options...
jon182 Posted December 24, 2009 Share Posted December 24, 2009 since your sending it from a computer i believe that you must send it from an email. I could be wrong but i don't think so. Quote Link to comment https://forums.phpfreaks.com/topic/185861-prevent-php-mail-from-appending-hostname-to-from-address/#findComment-983434 Share on other sites More sharing options...
premiso Posted December 24, 2009 Share Posted December 24, 2009 To do what you want I believe you will have to have an SMS gateway device and software setup on the server. As EMails always have to be from a host (the @ host) as that is just their nature and it is not a valid email without it. http://www.ozekisms.com/php-sms-api-asp-sms-api/index_p_php_q_ow_page_number_e_327opt.html Is a link to some software / hardware that you can do what you want to with. Not sure of the cost etc, but yea. I believe that is what you want and to try this with email is just wasting your time. (I could be wrong but I do not think so.) Alternatively, if you know the provider the sender's phone number is, you can look up the SMS email for their number and use that for the hose so for tmobile it would be something like: 10digitnumer@tmomail etc. which would allow you to do what you want, if that does not work for you then yea, the gateway would be the other way. EDIT: A list of the providers email address hosts http://www.accutracking.com/sms-email.html Quote Link to comment https://forums.phpfreaks.com/topic/185861-prevent-php-mail-from-appending-hostname-to-from-address/#findComment-983440 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.