Page 1 of 1
EASY email script question - how to specify mail server?
Posted: Sun Apr 03, 2005 11:48 am
by forzato
Hello:
I'm a newbie using a very simple script (half dozen lines of code) on my web site server to handle a form. A user's 'name' and 'email' are sent to the script, then script sends email to user... like an autoresponder.
The script uses the php 'mail' function.
My script works great EXCEPT if 'email' is out of my web site domain... then it doesn't work at all.
My server host tells me to "change the script so that the mail server is either localhost or 2k3mail.siteprotect.com" They tell me that my script is currently using smtp.mydomain.com as mail server...
I have not explicitly stated the mail server in my script.
I don't know how to do this with php... do you?
PS: It's a windows server with php installed and I have the php info file and php code if needed.
Thank you for any ideas...
Posted: Sun Apr 03, 2005 12:33 pm
by SystemWisdom
You could try:
Code: Select all
ini_set( 'SMTP','localhost' );
// or
ini_set( 'SMTP','2k3mail.siteprotect.com' );
Posted: Sun Apr 03, 2005 2:14 pm
by forzato
SystemWisdom,
You're name is underestimating your skill... You're advise worked!
I'm so happy I can't tell you!
PS: I don't know if it matters... I had to first use mail, then use your ini_set then use mail again. If I don't use the second mail after the ini_set then it won't mail my Bcc to an email in my domain. (?)
ie: mail(abc)
ini_set (xyz)
mail (abc)
NOT
ini_set (xyz)
mail (abc)
PPS: This is a shared serevr if it matters (?)
Posted: Sun Apr 03, 2005 2:45 pm
by SystemWisdom
Hmm, sounds strange, are you using localhost??
Maybe post your Mail Header string?
I am on a shared host as well, but I dont recall ever having that problem..
Posted: Sun Apr 03, 2005 3:01 pm
by forzato
Thanks for staying with me...
SystemWisdom wrote:Hmm, sounds strange, are you using localhost??
Code: Select all
ini_set( 'SMTP','2k3mail.siteprotect.com' );
works, but...
does not (if that's your quesion)
Here's the modified code (the variables 'email' and 'name' are sent to this script via POST from a Flash swf):
Code: Select all
<?php
$myredirect = "http://www.corporatecar.com/";
$email = $_POST["email"];
$myname = "Corporate Car";
$mymail = "CustomerService@CorporateCar.com";
$subject = "***** Yada Yada ******";
$body = $_POST["name"] . ", here is yada yada...
Thanks for the help... much appreciated";
$headers = "Content-Type: text/plain; charset=us-ascii\nFrom: $myname <$mymail>\nBcc:<$mymail>\nReply-To: <$mymail>\nReturn-Path: <$mymail>\nX-Mailer: PHP";
ini_set( 'SMTP','2k3mail.siteprotect.com' );
mail($email,$subject,$body,$headers);
?>
PS: It's not that important, but for diagnostic purposes... With our fix in place I get an 'undeliverable' notice from Postfix, even though the mails deliver as expected.
Posted: Sun Apr 03, 2005 3:16 pm
by forzato
forzato wrote:
I had to first use mail, then use your ini_set then use mail again. If I don't use the second mail after the ini_set then it won't mail my Bcc to an email in my domain. (?)
ie: mail(abc)
ini_set (xyz)
mail (abc)
NOT
ini_set (xyz)
mail (abc)
...is from my lack of complete testing and an error on my part - sorry about that.
Posted: Sun Apr 03, 2005 5:51 pm
by SystemWisdom
Sorry, makes no sense to me, if the mail routine can send one mail, then there should be no reason for it failing on the second one (in ur bcc).
I hope you figure it out!