Solved

php mail fails

Posted on 2011-02-11
7
309 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
[X]
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
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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 dynamically set the form action using jQuery.

749 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