Page 1 of 2

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

Posted: Fri Jul 27, 2007 10:07 am
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?

Posted: Fri Jul 27, 2007 10:19 am
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?

Posted: Fri Jul 27, 2007 10:23 am
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

Posted: Fri Jul 27, 2007 10:26 am
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?

Posted: Fri Jul 27, 2007 10:29 am
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.

Posted: Fri Jul 27, 2007 10:30 am
by miro_igov
How about header From: ?

Posted: Fri Jul 27, 2007 10:40 am
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.

Posted: Fri Jul 27, 2007 10:44 am
by miro_igov
How masked email differs from email sent by SMTP account?

Posted: Fri Jul 27, 2007 10:57 am
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.

Posted: Fri Jul 27, 2007 11:11 am
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.

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

Posted: Fri Jul 27, 2007 11:20 am
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");

Posted: Fri Jul 27, 2007 11:43 am
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)

Posted: Fri Jul 27, 2007 11:45 am
by miro_igov
I personally don't see difference in the mail headers of messages sent by authenticated SMTP user and mail().

Posted: Fri Jul 27, 2007 12:01 pm
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.

Posted: Fri Jul 27, 2007 12:15 pm
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)