Link to home
Start Free TrialLog in
Avatar of Richard Korts
Richard KortsFlag for United States of America

asked on

php mail fails

See attached, a fairly simple php script to send an email. Nothing is sent.

I put echo's into the code to show what's going on. The result is in the image file.

Note that "ret" is the return value from the mail function, there is no value, so I assume it's failing.

You can try it at www.whasocal.org/send_message.php

What's wrong?
msg-send.php
msg-send-echos.jpg
ASKER CERTIFIED SOLUTION
Avatar of requeue
requeue

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
First off, try
var_dump($ret);

Open in new window

instead of
echo $ret;

Open in new window

so you don't need to assume.

Even better:
var_dump($tostr);
var_dump($subj);
var_dump($msg);
var_dump($headers);
var_dump($ret);

Open in new window

It appears that @requeue hit the nail on the head.

If I don't put myself in Carbon Copy, the mail is delivered to the mailing subsytem (a final "1" is printed).

Still, that does not ensure the mail is actually delivered to recipient(s). See mail function.

Also, your mailing configuration can use SMTP or sendmail, depending on your hosting. I suggest you put up a script with the following single line:
<?php phpinfo(); ?>

Open in new window


And see what you have.
Avatar of wwwdeveloper2
wwwdeveloper2

If you don't have access to the php.ini file on the server, you might be able to do ini_sets to specify your own smtp and other settings needed by the mail()

For example:

ini_set ( sendmail_from, "my_email@my_server.com" );
ini_set( SMTP, "smtphm.sympatico.ca" );
ini_set( smtp_port, 25 );

If your smtp server requires authentication to relay - the PHP mail() is not very flexible.  You might be able to take advantage of the php pear add-on.  Here is a really easy tutorial:

http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm

I hope you get it working.
Avatar of Aaron Tomosky
Phpmailer is your friend
Avatar of Richard Korts

ASKER

Apparently, the Cc semicolons.
To all,

The server is php email configured; I am sending other emails from this site in several other places.

It seems that the semicolon in header causes failure (as per requeue). I am successfully using ; in the mail "to" string, I guess it's in the header that it causes the issue.

Thanks all!