Make php custom mail form show an email NOT the host servers

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

jramaro
Forum Commoner
Posts: 58
Joined: Tue Jun 26, 2007 7:46 am

Make php custom mail form show an email NOT the host servers

Post by jramaro »

Hi,
I have a custom email form i made in php and that works the way it should.
The problem is that its sending with my Host servers email
example : username@Hostservername.com

I have emails set up on the Host, like the cliche' = contact@domain.com , orders@domain.com
I made the php script with the $from to be the one i want. but its defaulting to the server email .

i send the mail with

Code: Select all

$to      = $_POST['user_email'] ; 
$from    = 'contact@mydomain' ;     <-- (i use a real domain here)
$subject = 'Thank You for your Inquiry' ;    <-- (or whatever i will put as subject)
$message = $message_response;

// Send the message 
$ok3 = @mail($to, $from, $subject, $message); 
?>


The mail goes through and the To: field is correct.
the From: field doesnt say 'contact@mydomain.com' it says 'myusername@Host/servername.com.
the subject says = 'contact@mydomain.com' instead of the $subject string.
the message goes through correct.

and the $subject line ..ends up at the bottom of the message like a footer.

odd , very odd ..it smells fishy , someone may be trying to access the main terminal Scotty.

any suggestions?
Last edited by jramaro on Fri Jul 27, 2007 10:24 am, edited 1 time in total.
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

WTH do you read any manuals?

php.net/manual/en/function.mail.php

And did your mom not teach you to close the single quotes?
jramaro
Forum Commoner
Posts: 58
Joined: Tue Jun 26, 2007 7:46 am

Post by jramaro »

is that guy for real?

I didnt learn much from my momma, because i spent all my time with yours?

come on now. you dont want to go there :D
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

And did you not read what contains the link i posted? It is the mail() reference.

The most interesting thing is the arguments mail($to,$subject,$body,$headers), does it explain why you see the subject in the body and $from in the subject?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Please, let's not be so hostile. The single quotes is likely from him removing a portion of the code for security reasons.

Second, PHP's mail() function is dependent on the server it is running on, and will be sent from the email address specified by the server. If you want control over the email account being used to send out your mail, use an SMTP connection in Swiftmailer.
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

How about header From: ?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

miro_igov wrote:How about header From: ?
That would be masking, which would render it pointless for him to already have those email accounts unless he uses the Reply-To header as well, which is still just masking. When it comes to your emails being considered spam or not, I wouldn't recommend it.
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

How masked email differs from email sent by SMTP account?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

miro_igov wrote:How masked email differs from email sent by SMTP account?
An SMTP connection requires an authenticated username and password combination.
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

For sure, but that is the building of the email process, i asked what is the difference at the end point when you receive 2 emails - 1 sent via SMTP session other with mail() with From header.
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Re: Make php custom mail form show an email NOT the host ser

Post by nickvd »

jramaro wrote:

Code: Select all

$ok3 = @mail($to, $from, $subject, $message);
The problem is that you're not using the mail function the way it is intended... there is no 'FROM' parameter in the mail function

bool mail ( string $to, string $subject, string $message [, string $additional_headers [, string $additional_parameters]] )

Code: Select all

mail("me@example.com", 'Join my Forums!', "here an email body", "From: you@yourdomain.com");
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

miro_igov wrote:For sure, but that is the building of the email process, i asked what is the difference at the end point when you receive 2 emails - 1 sent via SMTP session other with mail() with From header.
The likelihood of your email being sent to the Junk Email folder, or being blocked by a spam filter altogether. I do believe that spam detection systems can determine if emails were sent from a genuine connection or not.

How to (legitimately) minimize being seen as spam (From the Swiftmailer docs)
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

I personally don't see difference in the mail headers of messages sent by authenticated SMTP user and mail().
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

miro_igov wrote:I personally don't see difference in the mail headers of messages sent by authenticated SMTP user and mail().
Well, you may be correct, but I'd opt to wait for d11 to clear this one up.
jramaro
Forum Commoner
Posts: 58
Joined: Tue Jun 26, 2007 7:46 am

Post by jramaro »

thanks for the SMTP heads up.

and the no 'from' in the email .

I will have to keep the message as $message because its all all plotted out above that in php
and it works so it falls into that 'aint broke dont fix it' rule

masking is putting in over the name in the header.
wow look at all the interestin stuff you can learn when some get in their heated debate.
They say thats the best wya to learn , kinda sit and pick out the info thats flyin back and forth.
very good, we should have php Colesium tournaments , then we'll al lbe smart from watching all the examples and code fly around.

yay.. more MORE! (single person standing in seats clapping with a ambient arena echo)
Post Reply