Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

php mail fails

Posted on 2011-02-11
7
308 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:Richard Korts
7 Comments
 
LVL 2

Accepted Solution

by:
requeue earned 500 total points
ID: 34876548
First, is the server configured to send email ?
The setting is normally done in php.ini file. The smtp server is specified by hosting company.

Second, CC should be separated by comma. not by semi-colon.
0
 
LVL 7

Expert Comment

by:lexlythius
ID: 34876655
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

0
 
LVL 7

Expert Comment

by:lexlythius
ID: 34876695
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.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 3

Expert Comment

by:wwwdeveloper2
ID: 34876717
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.
0
 
LVL 39

Expert Comment

by:Aaron Tomosky
ID: 34876921
Phpmailer is your friend
0
 

Author Closing Comment

by:Richard Korts
ID: 34879054
Apparently, the Cc semicolons.
0
 

Author Comment

by:Richard Korts
ID: 34879061
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!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question