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 = mickeymouse@server.com

 

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

 

1 <?php

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

3 $sendTo = " mickeymouse@server.com ";

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 = mickeymouse@server.com

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

 

Link to comment
Share on other sites

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 = mickeymouse@server.com

 

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

 

Thank you for your time.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.