DeveloperSide.NET Forums
December 09, 2019, 12:44:25 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Setting up PHP to send out mail...  (Read 38663 times)
0 Members and 2 Guests are viewing this topic.
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« 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
Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« Reply #1 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.
Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« Reply #2 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
Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« Reply #3 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.
Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
DeliriumServers
Customer, Basic Support
Jr. Member
*****
Posts: 61

delirium.martin@gmail.com a5m0deu5
View Profile WWW
« Reply #4 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?
Logged

es, i'm crazy
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« Reply #5 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);
?
« Last Edit: July 25, 2007, 10:13:03 PM by admin » Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« Reply #6 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.
Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
night2dark2
Jr. Member
**
Posts: 98


Yeah Dont really ask.

mfaiotto@msn.com
View Profile WWW
« Reply #7 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.
Logged

Revolution Gamers Host.
Master of all Gunz Server Hosting Needs.
Revolution Gamers International Gaming Commmunity
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« Reply #8 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 to proxy the request; or if you are not dependent on the PHP mail() function then use a PHP script like phpMailer.

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.
« Last Edit: February 15, 2008, 09:23:06 PM by admin » Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!