Forum Moderators: coopster

Message Too Old, No Replies

E-A-S-Y question

php server syntax email same-domain problem

         

forzato

6:40 am on Mar 21, 2005 (gmt 0)

10+ Year Member



The following script is on my server and works great as long as the variable 'email' is an email address on the server domain... script does not work for other email addresses. The variable 'email' is sent to the php script on server from a website flash swf. Then the script sends a simple email to the address defined in 'email'

Host support said the following...

Please try using "localhost" or "2k3mail.example.com" as the mailserver instead of using "smtp.example2.com" or "mail.example2.com". You will have to change it where the mail action is generated from. When the email is set to send out, you must use either of those two mail servers. So make the changes necessary to your PHP mail action

Anybody know how to do this to my code? Thanks for the help. (I am an utter php neophyte as you probably can tell)

<?php

$sendTo = $_POST["email"];

$subject = "*** Corporate Car Pricing ***";

$headers = "From: CustomerService@example.com" . ">\r\n";

$headers .= "Reply-To: CustomerService@example.com" . "\n";

$headers .= "Return-path: CustomerService@example.com";

$message = "Congratulations ". $_POST["name"] . "! Pending final CCP Membership confirmation"; mail
($sendTo, $subject, $message, $headers);

?>

[edited by: ergophobe at 7:11 am (utc) on Mar. 21, 2005]
[edit reason] URLs exemplified as per Terms of Service [/edit]

dreamcatcher

8:33 am on Mar 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld forzato :)

Can you not just use the standard PHP mail function?

You can use explode to get the domain part of an e-mail address, so you split it and check if its the same as your domain.

$allowed = "yourdomain.com";
$email = "your@yourdomain.com";

$get_email = explode("@", $email);

if ($get_email[1]!= $allowed)
{
sorry, not valid
}

Something like that?

Or am I still half asleep?

dc

forzato

9:16 am on Mar 21, 2005 (gmt 0)

10+ Year Member



Thanks DC for responding!

I know nothing about php... so if you suggest it I'm gonna try it.

Just so it's clear... the email addresses sent to this script will always be from outside the domain. I tried an email address inside the domain for diagnostic purposes only.

That said... what lines or code should I remove from my script (and replace with yours) ...or do I change to 'localhost' or '2k3mail.example.com' as advised by the site host? ..if so what code in my script do I change?

Thanks again - I owe you one!

forzato

1:00 am on Mar 22, 2005 (gmt 0)

10+ Year Member



Nobody has any thoughts?