Jump to content

Prevent PHP mail( ) from appending hostname to from address


jrw4

Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!";

  }

?>

Link to comment
Share on other sites

<?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!";

  }

?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.