NYCPHP Meetup

NYPHP.org

[nycphp-talk] Emailing from a PHP script

Brent Baisley brenttech at gmail.com
Sun Sep 16 01:39:16 EDT 2007


I think there are a few possible problems, the first is that you may  
be running windows. The mail() function really looks for sendmail  
installed under Unix, which is a pretty safe assumption since  
sendmail or postfix (which emulates sendmail) comes with just about  
all unix systems. But you need to have it configure in order for it  
to work, meaning your local machine has to be setup to be allowed to  
send email unauthenticated (i.e. an open relay). If your email server  
isn't set to "trust" the box you are on, you're not going to be able  
to send email.

I would recommend downloading either swiftmail or phpmailer (I prefer  
swiftmail), which will allow you to point your script at any mail  
server, login and send an email.

On Sep 14, 2007, at 9:09 AM, PaulCheung wrote:

> Can anybody see what I am doing wrong??
>
> I have set php.ini (as per the manual) to my email settings
> ======================================
> [mail function]
> ; For Win32 only.
> SMTP = smtp.tiscali.co.uk
> smtp_port = 25
>
> ; For Win32 only.
> sendmail_from = paulcheung at tiscali.co.uk
> ========================================================
> I run the script and the following message appears
>
> Warning: mail() [function.mail]: Failed to connect to mailserver at  
> "localhost" port 25, verify your "SMTP" and "smtp_port" setting in  
> php.ini or use ini_set() in C:\xampp\htdocs\tp_access.php on line 61
> ========================================================
> script line 61   mail(to, subject, message, "From:  
> paulcheung at tiscali.co.uk");
>
> Following the textbook example it should work - why am I directed  
> to localhost?? _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php




More information about the talk mailing list