Solved

php mail fails

Posted on 2011-02-11
7
304 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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 38

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Router for PHP reqeusts 12 33
XML Data Missing in PHP SimpleXML 8 24
Help cleaning out CSS 2 32
Change password through link 1 13
Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

744 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now