473,387 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

PHP Mail Not Working?

chunk1978
224 100+
hi there...

i wrote this super simple PHP script to send an email to myself... but it's not sending the email... i am using Apache on my Mac (and it's installed just fine)... when i execute the script, it displays the echo message fine, but never an email... what am i doing wrong?

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>Send PHP Mail</title>
  4. </head>
  5. <body>
  6. <?php
  7. $to = "blablabla@gmail.com";
  8. $subject = "PHP Is Great";
  9. $body = "PHP is one of the best scripting languages around";
  10. $headers = "From: webmaster@gowansnet.com\n";
  11. mail($to,$subject,$body,$headers);
  12. echo "Mail sent to $to";
  13. ?>
  14. </body>
  15. </html>
  16.  
"blablabla@gmail.com" isn't really my email address, but it's a gmail address... i just don't understand this...

any ideas?

thanks
Feb 22 '07 #1
9 4147
Works fine for me when I upload it to a server, change the email address to me and run the script.

Sorry I can't help more, but I reckon it's your environment and NOT your coding :-)
Feb 22 '07 #2
Mostly the problem comes from your email provider you use microsoft came the the genius idea to make a senders id which cant be get if you send emails via the php mail function

this should prevent you from spaming so check your junk box ;)

it can be fixed by good headering you need to give the servers address that the dns request works and your mail wont be spam
Feb 22 '07 #3
chunk1978
224 100+
thanks for the replies...

unfortunately nothing landed in my junk mail... :-/

how would i code a header to give the server's address that a dns requests?
Feb 22 '07 #4
cassbiz
202 100+
Take a look at the error logs. There is a lot of information there.

If your php is not outputting any error logs (default) you need to find this line in your php.ini and uncomment it or turn it on

Expand|Select|Wrap|Line Numbers
  1. log_errors = On
  2.  
and then tell it where to store the logs

Expand|Select|Wrap|Line Numbers
  1. error_log = /var/log/php/error_log
  2.  
to view the logs in real time the command from bash is

Expand|Select|Wrap|Line Numbers
  1. cd /var/log/php/error_log
  2. tail -f error_log
  3.  
Good luck. BTW my guess it has something to do with sendmail not getting out.
Feb 22 '07 #5
chunk1978
224 100+
thanks for the advice cassbiz... i'll defiantly look into that...
Feb 23 '07 #6
chunk1978
224 100+
this is what my PHP.ini file looks like concerning the mail function... shouldn't that work with the code i've first written in this discussion's first post?

any help will be greatly appreciated

Expand|Select|Wrap|Line Numbers
  1. [mail function]
  2. ; For Win32 only.
  3. SMTP = localhost
  4. smtp_port = 25
  5.  
  6. ; For Win32 only.
  7. ;sendmail_from = me@example.com
  8.  
  9. ; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
  10. ;sendmail_path =
  11.  
  12. ; Force the addition of the specified parameters to be passed as extra parameters
  13. ; to the sendmail binary. These parameters will always replace the value of
  14. ; the 5th parameter to mail(), even in safe mode.
  15. ;mail.force_extra_parameters =
  16.  
  17.  
Feb 26 '07 #7
Nert
64
this is what my PHP.ini file looks like concerning the mail function... shouldn't that work with the code i've first written in this discussion's first post?

any help will be greatly appreciated

[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 =

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
hi chunk,

i guess you're missing something in your php.ini configuration for mail function..,
did you made any changes to this part? I think these are the default value right?

Expand|Select|Wrap|Line Numbers
  1. mail function]
  2. ; For Win32 only.
  3. SMTP = localhost
  4. smtp_port = 25
  5.  
  6. ; For Win32 only.
  7. ;sendmail_from = me@example.com
try to change the value of the following into something like these.

SMTP = (your SMTP server for example mail.smtp.com)
sendmail_from = (uncomment it first then put a value for example your email address me@smtp.com)
Feb 27 '07 #8
chunk1978
224 100+
hi chunk,

i guess you're missing something in your php.ini configuration for mail function..,
did you made any changes to this part? I think these are the default value right?

Expand|Select|Wrap|Line Numbers
  1. mail function]
  2. ; For Win32 only.
  3. SMTP = localhost
  4. smtp_port = 25
  5.  
  6. ; For Win32 only.
  7. ;sendmail_from = me@example.com
try to change the value of the following into something like these.

SMTP = (your SMTP server for example mail.smtp.com)
sendmail_from = (uncomment it first then put a value for example your email address me@smtp.com)
hey Nert, thanks for the reply...

i've changed my PHP.ini file to this:

Expand|Select|Wrap|Line Numbers
  1. [mail function]
  2. ; For Win32 only.
  3. SMTP = smtphm.sympatico.ca
  4. smtp_port = 25
  5.  
  6. ; For Win32 only.
  7. sendmail_from = jmattie@sympatico.ca
  8.  
but still nothing... there's nothing in my junk mail either... this is totally confusing me...

i'm not sure if it matters, but i'm using Apache 1.3 and Safari 2.0, with Mac OS X 10.4.8, on an Intel Core 2 Duo iMac...
Feb 27 '07 #9
chunk1978
224 100+
ok...so i've realized that i'm on a UNIX machine (i'm dumb :-p) and therefore i'm suppose to specify the sendmail_path... but it's still not working :-(

here in my PHP.ini file config for the Mail Function:
Expand|Select|Wrap|Line Numbers
  1. [mail function]
  2. ; For Win32 only.
  3. SMTP = localhost
  4. smtp_port = 25
  5.  
  6. ; For Win32 only.
  7. sendmail_from = me@example.com
  8.  
  9. ; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
  10. sendmail_path = /usr/sbin/sendmail
  11.  
Feb 27 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Bruce W...1 | last post by:
In my effort to learn PHP I'm playing with some simple email scripts. They worked a few days ago but they stopped working. The only thing I've done to this Windows 2000 PC in this time was a...
4
by: Data Goob | last post by:
This one has me stumped. How did SuSE disable the mail() function in their RPM'd version of PHP? ( This is their install-version of PHP with RPMs not what you download from PHP.net ) I have...
4
by: Tom Petersen | last post by:
Ok, I'm 99.9999999999999999999% sure there haven't been any code changes, since the date stamps of the code are older than any email 'failures' The email piece quit working using the mail.send. ...
6
by: DigitalRick | last post by:
I have been running CDONTS in my ASPpages to send emails to me sent from my guestbook. It had been working fine untill I upgraded to Server 2003 (I am also running Exchange 2003) all locally. I...
6
by: Dushyant | last post by:
Hi everyone, I am working on an application, where I need to mail some xml files as attachments. I tried to use System.Diagnostic.Process class but it does not provide any help for attaching a...
9
by: shror | last post by:
hi every body, i have a problem which is when i was checking my mail() form it work fine but the problem is that the form configuration is not set correctly, in details: the from var is not...
10
by: Frank | last post by:
Hi, I am hoping to find out the differences between the System.Net.Mail and System.Web.Mail. Can some nice folks post the differences; or some urls which show the differences? Great Thanks...
6
by: nextpulse | last post by:
On Fedora, using php5. The mail() function returns a success - but the mail itself is not actually sent. How do I go about debugging this? Do I need to do this at the linux command level to ensure...
7
by: undbund | last post by:
Hi I am creating a newsletter system. The software should run from desktop computer (localhost) but be able to send email to anyone on the internet. Can you guys give me some ideas on how to...
5
by: sui | last post by:
this is my code import sys, os, glob, datetime, time import smtplib ## Parameters for SMTP session port=587 SMTPserver= 'smtp.gmail.com' SMTPuser= '...@gmail.com' pw= 'fill in here'...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.