Join The Toronto PHP Meetup Group

You'll get invited to our Meetups as soon as they're scheduled!

The Toronto PHP Meetup Group Message Board › How can I sent an email from a PHP script?

How can I sent an email from a PHP script?

Mihai Popescu
Posted Aug 19, 2008 8:40 AM
user 7779106
Bucuresci, RO
Post #: 3
Send an Email Post a Greeting
I've tried with mail() function. I think that the mail() parameters I used were corect, as I read the PHP documentation. I'm using Windows so I made the necessary settings in php.ini. When I call the function I don't receive any error but the message does not arrive at destination. Does somebody have any ideea why?
Joe Taiabjee
Posted Aug 19, 2008 10:35 AM
JoeTaiabjee
Toronto, ON
Post #: 2
Send an Email Post a Greeting
I've tried with mail() function. I think that the mail() parameters I used were corect, as I read the PHP documentation. I'm using Windows so I made the necessary settings in php.ini. When I call the function I don't receive any error but the message does not arrive at destination. Does somebody have any ideea why?

The mail function does pretty much nothing except relying on underlying system. It does not do any authentication. This also means that your hosting provider must have the sendmail function in php activated; it is possible that they closed that. Another possibility is that your isp blocks mails from domains where e-mail has a different domain, to prevent spam.

Are you on a dedicated server, or a shared host?
Paul Rochford
Posted Aug 20, 2008 9:21 AM
prochford
Group Organizer
Mahone Bay, NS
Post #: 144
Send an Email Post a Greeting
Put the following code in a file, save it as a PHP file and run it on the server.

<?php

phpinfo();

?>

The above will let you know if you have the proper sendmail function available to you in PHP.

Good luck.

Paul Rochford
Organizer
Mihai Popescu
Posted Aug 21, 2008 8:55 AM
user 7779106
Bucuresci, RO
Post #: 4
Send an Email Post a Greeting
It runs ok, displaying the settings of php. At the section smtp it is only one row : Version...............0.2.0-dev.
In php.ini I've used, at sendmail_from, the address for my email client. If the email transmision is blocked for mail() function why it is not when I sent an email from my email client to the same address.
A former member
Posted Aug 24, 2008 2:01 PM
Post #: 6
What email client? (Just checking that it is indeed using your local mail system)
Paul Rochford
Posted Aug 25, 2008 9:30 AM
prochford
Group Organizer
Mahone Bay, NS
Post #: 145
Send an Email Post a Greeting
When you send an email from your email client installed on your desktop at home, the SMTP Server used is usually that of your ISP's, which should have no problem sending email.

When you send email from a Linux Web server for example, the message will use sendmail() or the SMTP server you set up for that Web server to send email from.

Using Windows with IIS requires a proper SMTP server set up. Works a whole lot better in this case than sendmail().

Having said that, is this a server with a proper hosting company, or is this a server you've set up behind your Rogers or Sympatico account at home?

If you've set up a server at home, the server should be able to send email but only if you use your ISP's SMTP server. However, you won't be able to send email to an account set up on your Web server to accounts within the domain or IP you've set it up under. Rogers and Sympatico do not forward POP3 email packets to an unknown email server within their realm.

First things first. Where does the box live? At home, or within the data center of a hosting provider?

Paul Rochford
Organizer
Powered by mvnForum