Jump to content

Connect to email server from the web server


mikemedia

Recommended Posts

I want to send PHP form data via an email server NOT the web server.

 

I have written a function and saved it as a php.ini within my website’s root directory which is the same as is the location of the PHP file.

 

Here is exactly what is written as php.ini.  Only the names have been changed.

 

1 [mail]

2 SMTP = theCompany.email.server.com

3 SMTP_PORT = 25

4 SENDMAIL_FROM = [email protected]

 

Here is exactly what is written as contactMe.php.  Only the names have been changed.

 

1 <?php

2 include("/siteRoot/php.ini");

3 $sendTo = " [email protected] ";

4 $subject = "Subject: $_POST[senderSubject] \r\n";

5 $headers = "From: $_POST[senderName] \r\n";

6 $headers = "Reply-To: $_POST[senderEmail] \r\n";

7 $message = "Name:  ".$_POST["senderName"] . "\r\n" ."Email:  ".$_POST["senderEmail"] ."\n" ."Comments:  ".$_POST["senderComments"] ;

8 mail($headers, $sendTo, $subject, $message);

9 ?>

 

I have removed any references to “MIME”

 

I have tried using ini_set() included within lines 3 and 4 of contactMe.php.

For example:

 

//$mail_ini=ini_set('SMTP', " theCompany.email.server.com ");

//$mail_ini=ini_set('smtp_port',25);

 

Still, the “connection” is being sought on the web server instead of the email server.

 

I  suspect I my syntax of line 8 mail() is somehow wrong.

 

[mail] SMTP = theCompany.email.server.com SENDMAIL_FROM = [email protected]

Warning: mail() [function.mail]: Failed to connect to mailserver at "exchange.thestupidWebserver.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in \webmaster.php on line 8

 

Specific help (showing script) is appreciated

 

Let me try this again...

 

Web server: Windows 2003

Email server: Windows 2000

 

I am getting an error that says that my function failed to connect to the 'mailserver' on the the 'web server'.  That's because there is no mailserver on my web server.

 

The error message goes on to suggest that I verify my SMTP and SMTP Port setting in php.ini or use ini_set() embeded within my *.php file

 

I have verified that SMTP and Port are correct.

 

I am unsure if my syntax is correct.

 

I have been reading a lot of instructions re: PHP and SMTP.

 

I have even cut and pasted scripts modifying only those things that apply to me, e.g.

 

SMTP = theCompany.email.server.com

SMTP_PORT = 25

SENDMAIL_FROM = [email protected]

 

What, if anything, is wrong with my script? (please see original post)

 

Thank you for your time.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.