/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Problems with mail()

Ok so I spent a short time making this survey, and setting up a form to handle sending invites for the survey out to people (to be used in house). During production it was working fine, now the emails are not showing up in our in-boxes. The mail function is still returning true, so I’m unsure of why its not showing up. None of the code has changed, and our development environment is on the exact same server as our production environment, so ini settings are all the same as well. Below is a snippet of the code, and attached is the entire file.

[code=php]
// Constant email settings.
$sub = ‘— Satisfaction Survey Invite’;
$headers = ‘MIME-Version: 1.0’. PHP_EOL;
$headers .= ‘Content-type: text/html; charset=iso-8859-1’. PHP_EOL;
$headers .= ‘FROM: —@—.com’. PHP_EOL;

// Base SQL for multiple insert
$sql = ‘INSERT INTO survey_invites (id_invite,invite_email,invite_token) VALUES ‘;

foreach( $emails as $info ) {
$token = saltyhash($info[’email’]);

// Send mail message to each recipient
$to = $info[’email’];
$msg = buildmsg($info[‘name’],$token,$info[‘type’]);
if( mail($to,$sub,$msg,$headers) )
$content .= ‘Message to ‘. $info[‘name’] .’ sent successfully.<br />’;
else
$content .= ‘Message to ‘. $info[‘name’] .’ failed to send.<br />’;

// Build SQL to insert email/token for validation later.
$sql .= ‘(NULL,”. $info[’email’] .”,”. $token .”),’;
}
$sql = substr($sql,0,-1);
if( $db->query($sql) )
$content .= ‘Emails and tokens successfully stored in the database.’;
[/code]

As I said, it was working perfectly while I was testing it, now its like the emails aren’t sending, or for some reason just aren’t making it to our inbox (yes we’ve checked our spam box as well)

*Note: I have removed identifying information.

[upl-file uuid=df931553-44d5-413b-b8f9-f3c51d619637 size=5kB]temp.txt[/upl-file]

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@ZABIJun 15.2011 — i too got the same problem few months ago... it was on a hosting server which did not support From header so when i removed From header it worked as expected.

Maybe helpful to you...
Copy linkTweet thisAlerts:
@NogDogJun 15.2011 — Is the "from" email address a valid email on the host where the script is running? (Many hosts are configured to only allow that so as to prevent spammers from using the host to relay email.) If this is the case, set the "From:' header to a valid email address for that host, and then add a "Reply-To:" header with the desired email.

It probably does not matter, but the "FROM:" header should be "From:".
Copy linkTweet thisAlerts:
@NoasITauthorJun 16.2011 — Well according to php.net headers shouldn't be case sensitive, but I'll give it a try. And like I said it was working in the development sub-folder which would be domain.com/dev/survey instead of domain.com/survey so the fact that it did work is what bothers me.

Anyway it seems to be working but on a delay of some sort (takes 1-2 hours to show up in the mailbox). Luckily, as long as it works its good to go for now. I wish my server supported pear::mail_mime ?
Copy linkTweet thisAlerts:
@NogDogJun 16.2011 — ... I wish my server supported pear::mail_mime ?[/QUOTE]

You might consider using the PHPMailer class, which provides a lot control and flexibility to sending emails. Also, it is possible to install PEAR packages yourself within your site's web directories without the full PEAR installation, it's just a lot more fiddly, as you have to make sure all dependencies are uploaded and the include_path is adjusted as needed (making PHPMailer look like a better deal ? ).
Copy linkTweet thisAlerts:
@NoasITauthorJun 18.2011 — Thanks, I'll have a look at it Monday when I'm back in the office. For now sending invites with an hour or two delay isn't that big of a deal, but will definitely check it out as installing pear in a web accessible folder doesn't seem "ideal" to me.
×

Success!

Help @NoasIT spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...