Solved

php mail fails

Posted on 2011-02-11
7
312 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
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
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

Industry Leaders: 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!

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to implement server side field validation and display customized error messages to the client.
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 a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

724 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