Connecting Tech Pros Worldwide Help | Site Map

Problems with "mail" function

  #1  
Old August 23rd, 2007, 06:05 PM
laredotornado@zipmail.com
Guest
 
Posts: n/a
Hi,

I cannot seem to send emails. What does it mean when the return value
from the "mail" function is an empty string? I'm using php 4.3.11 on
a Yahoo! hosting environment. Here is the code:

$p_from = "dalvarado@mydomain.com";
$headers = "MIME-Version: 1.0\n"
. "Content-type: text/plain;
charset=iso-8859-1\n"
. "Content-Transfer-Encoding: 7bit\n"
. "From: $p_from\n"
. "X-Mailer: PHP " . phpversion() .
"\n"
. "Reply-to: $p_from";

$retVal = mail("myseconddomain@gmail.com", "Test", "Hello",
$headers);
print "retVal: $retVal<BR>\n";

Any help is appreciated. Here is the configure command from
phpinfo():

'./configure' '--prefix=/usr' '--enable-fastcgi' '--with-config-file-
path=/usr/lib/php' '--enable-memory-limit' '--enable-bcmath' '--enable-
calendar' '--enable-exif' '--enable-mbstring=all' '--enable-mbregex'
'--with-curl' '--with-dom' '--with-dom-xslt' '--with-gdbm' '--with-
gettext' '--with-iconv' '--with-gd' '--with-jpeg-dir' '--with-png-dir'
'--with-tiff-dir' '--with-xpm-dir=/usr/X11R6' '--with-zlib-dir' '--
with-ttf' '--with-freetype-dir' '--with-t1lib' '--enable-gd-native-
ttf' '--with-mcrypt' '--with-mhash' '--with-mime-magic' '--with-ming'
'--with-openssl' '--with-pspell' '--with-regex' '--enable-wddx' '--
with-xmlrpc' '--enable-xslt' '--with-xslt-sablot' '--with-zip' '--
disable-posix'

Thanks, - Dave

  #2  
Old August 23rd, 2007, 10:45 PM
=?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?=
Guest
 
Posts: n/a

re: Problems with "mail" function


laredotornado@zipmail.com escribió:
Quote:
I cannot seem to send emails. What does it mean when the return value
from the "mail" function is an empty string?
I suggest you var_dump() the return value rather than using echo.

Quote:
$headers = "MIME-Version: 1.0\n"
. "Content-type: text/plain;
charset=iso-8859-1\n"
. "Content-Transfer-Encoding: 7bit\n"
. "From: $p_from\n"
. "X-Mailer: PHP " . phpversion() .
"\n"
. "Reply-to: $p_from";
I suggest you examine the actual value of $headers.

Anyway, if there aren't any obvious errors in your code, you host may
have some requirements about the emails it'll accept, such us using a
specific e-mail address as sender. Start debugging with the simplest
test script you can write. You'll have time later to add complex headers
and attachments.



--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor austrohúngaro: http://www.demogracia.com
--
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with the function "mail" of PHP. Kurda Yon answers 6 November 27th, 2006 03:05 AM
I need help with "Inheritance" and "Polymorphism" Fao answers 13 May 2nd, 2006 01:05 AM
"Failure Sending Mail" when using System.Net.Mail and ASP.Net 2.0 HoustonComputerGuy@gmail.com answers 3 December 6th, 2005 09:15 AM
Problems with form elements that are hidden with <div style="display:none"> Dan R Brown answers 13 July 20th, 2005 10:30 AM