DeveloperSide.NET Forums

DeveloperSide.NET => Web.Developer Server Suite Community Edition,
Public Support Forum => Topic started by: admin on November 05, 2004, 07:09:03 AM



Title: Setting up PHP to send out mail...
Post by: admin on November 05, 2004, 07:09:03 AM
Edit file php.ini located under your %SYSTEMROOT% (Win2000 -> C:\WINNT, WinXP -> C:\Windows) directory.

Edit section...
Quote

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =


To...
Quote

[mail function]
; For Win32 only.
SMTP = your-ISP's.SMTP/POP.mail-server.address
smtp_port = 25

; For Win32 only.
sendmail_from = you@your-email.address

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =


(make sure to uncomment -- remove the ";" character -- the "sendmail_from" line)
Save file, restart Apache or reboot system.

Now you should be able to use PHP's mail function...
http://www.php.net/mail

Notes:

Your ISP's SMTP mail server address is the same server address you use to receive (and in some cases also send) your e-mail, via your Internet Service Provider.

Some ISPs have two addresses for mail servers (we are only concerned with the "outgoing" mail server)...
Quote

Incoming Mail: POP3 - port 110
Outgoing Mail: SMTP - port 25


Some ISPs mail servers will require for a username and password to be specified in order to login.  That user/password combo can be specified under the mail server's address as...
Quote

user:password@your-ISP's.SMTP/POP.mail-server.address


Title: Setting up PHP to send out mail...
Post by: admin on January 01, 2005, 09:22:20 PM
Note that some Anti-Virus (McAfee) and Firewall programs will be blocking the SMTP port 25.  You will need to re-configure that software (or hardware) to unblock that port.


Title: Setting up PHP to send out mail...
Post by: admin on June 18, 2006, 11:45:06 AM
Here is how to test your ISP's SMTP Server manually...
Run cmd.exe
> telnet

If using Win2k...
> set local_echo
If using WinXP...
> set localecho

> open smtp.myisp.tld 25
(at this point you should see your smtp server's info)

> helo me
(you should see "250 OK")

At this point you can continue by searching google for 'smtp telnet test' but I would say it is fair to assume that at least you can get through to your smtp server...
http://www.google.com/search?q=telnet+smtp+server


Title: Setting up PHP to send out mail...
Post by: admin on June 18, 2006, 11:55:37 AM
If you are having problems sending out mail, check \www\Apache2\logs\error.log for error messages -- they can be very helpful.


Title: default
Post by: DeliriumServers on July 25, 2006, 06:07:30 AM
so will php applications wtill be able to send out with different sender information? ie. will hosted accounts all send mail from admin@deliriumservers.com?


Title: Setting up PHP to send out mail...
Post by: admin on July 25, 2006, 12:01:20 PM
The 'sendmail_from' field under php.ini is just a 'default' value used when no 'From:' header is specified under the php 'mail()' function -- set it to anything you want. It is not used to gain access to your ISP's mail servers.

You can also set it under httpd.conf with...
Quote
ini_set ("sendmail_from","your@yourcompany.com");

As far as the from address displayed when using the php 'mail()' function, that depends on how you are using it...

Code:
<?php
$to      
'nobody@example.com';
$subject 'the subject';
$message 'hello';
$headers 'From: webmaster@example.com' "\r\n" .
   
'Reply-To: webmaster@example.com' "\r\n" .
   
'X-Mailer: PHP/' phpversion();

mail($to$subject$message$headers);
?


Title: Re: Setting up PHP to send out mail...
Post by: admin on September 01, 2007, 06:44:13 PM
As a note, you cannot use an alias, such as 'localhost', under the SMTP string. It must be either a domain or an IP address.


Title: Re: Setting up PHP to send out mail...
Post by: night2dark2 on November 02, 2007, 01:27:16 PM
for those using comcast you might want to use

smtp.comcast.com port 25 or anyone as a matter of fact. Its free , their mail gets on time , And people don't have to bitch about stuff.


Title: Re: Setting up PHP to send out mail...
Post by: admin on February 15, 2008, 09:17:29 PM
I'd like to add ONE BIG NOTE:

The PHP mail() function has no authentication ability... Meaning if your SMTP server requires a username/password combo -- using the mail() function will *probably* not work.

I have no idea where I got that you can use 'SMTP = username:password@smtp-server'... It might work, it might not work, or it might break something. I think this might be a hack/workaround that *some* servers can handle/read, while at the same time confusing others.

If you need to use PHP to send out mail via an SMTP server that requires authentication, I suggest you use a local mail server like hMailServer (http://www.hmailserver.com/) to proxy the request; or if you are not dependent on the PHP mail() function then use a PHP script like phpMailer (http://phpmailer.codeworxtech.com/).

If your SMTP server requires encryption, you will also need to uncomment line ';extension=php_openssl.dll' under php.ini

I hope this helps and clarifies the issue. I've been getting a lot of mail about this.