Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Specify SMTP Server

Status
Not open for further replies.

leeym

IS-IT--Management
Aug 20, 2004
338
US
In this simple PHP sendmail script, it works fine but no e-mails get sent out. Do I need to specify an SMTP address? If so, how and where? (FYI, my web host says I can use 'localhost'). Thanks

<?
$company = $_REQUEST['company'] ;
$employees = $_REQUEST['employees'] ;
$first_name = $_REQUEST['first_name'] ;
$last_name = $_REQUEST['last_name'] ;
$address1 = $_REQUEST['address1'] ;
$address2 = $_REQUEST['address2'] ;
$city = $_REQUEST['city'] ;
$state = $_REQUEST['state'] ;
$zip = $_REQUEST['zip'] ;
$phone1 = $_REQUEST['phone1'] ;
$phone2 = $_REQUEST['phone2'] ;
$phone3 = $_REQUEST['phone3'] ;
$email = $_REQUEST['email'] ;
$description = $_REQUEST['description'] ;

mail( "info@domain.com", "General Web Site Inquiry (Contact Form)",
$description, "From: $email" );
header( "Location: );
?>
 
On a windows server, the SMTP server is set in the php.ini file. On a unix system, php just uses whatever mail transfer agent (MTA) is installed, which will either send directly to the reciepient's mail server, or to another SMTP server, depending on how it's configured.
So your best bet may be to check with your web host and see how they've set things up.

If you really need to override the SMTP setting, you can add a fifth parameter to the mail() function which passes command line arguments to the MTA. A sendmail compatable MTA will accept the -Pprotocol:host argument - eg -PSMTP:mail.foo.bar - so this may work. Again though, this is something you should check with your Web Host
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top