Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 371
  • Last Modified:

php mail

See attached. I run this script & email is received by the 2nd & 3rd email addresses in $mailto (but NOT the first) and NOT the Cc (which is my personal email).

The echos produce this:

mail result: 1
mailto: lawnsprinklerservice@hotmail.com, sales@lawnsprinklerservices.com, kneff@lawnsprinklerservices.com
header: MIME-Version: 1.0 Content-type: text/html; charset=iso-8859-1 From: donotreply@lawnsprinklerservices.com Cc: richardkorts@gmail.com

If I manually send an email to lawnsprinklerservice@hotmail.com, it works.

The email address donotreply@lawnsprinklerservices.com exists.

I'm thinking not receiving the Cc MIGHT be because I did not end it with a ."\r\n".

Can someone see the issue?

Thanks
email-test.php
0
Richard Korts
Asked:
Richard Korts
  • 8
  • 8
  • 2
2 Solutions
 
Dave BaldwinFixer of ProblemsCommented:
Every line in an email header Must end with "\r\n".  And you're probably not receiving it at Hotmail because you're sending from "donotreply@lawnsprinklerservices.com" which probably is not a real email address that the Hotmail servers can check.  I thought we already covered this.  ??
0
 
Richard KortsAuthor Commented:
As I said in my posting, donotreply@lawnsprinklerservices.com IS a real email address; I created it today.

What we covered was similar; this is a different variation.

I will add the "\r\n" to the Cc & try again.

Thanks
0
 
Richard KortsAuthor Commented:
DaveBaldwin

I put the "\r\n" after the Cc (in the header). See attached.

I ran it; no email received at richardkorts@gmail.com.

Thanks
email-test.php
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Dave BaldwinFixer of ProblemsCommented:
Make another version that uses "richardkorts@gmail.com" as the only 'To:' address and see what happens.
0
 
Ray PaseurCommented:
Probably both Hotmail and Gmail have already determined that the return address was bogus and they have it in their filters.   You may never get through with that return address.  I would change it to something else, since messages from "donotreply" are kind of a thumb in the eye of the recipient.  Like if I can't reply why are you poking me?

Really, automated email with PHP mail() is just too hard to get right.  You might do better to use ConstantContact or consider the phpMailer class (check on Github).
0
 
Richard KortsAuthor Commented:
DaveBaldwin,

I changed it as you suggested; also based on Ray's comment, I used a different (existing) from email, service@lawnsprinklerservices.com.

I ran it, received nothing.

See attached.

Thanks
email-test1.php
0
 
Dave BaldwinFixer of ProblemsCommented:
I took your code, put my own email addresses in there, and it worked fine to send to my Gmail account.  Are the 'lawnsprinklerservices.com' addresses part of your web hosting account?  I ask because some mail servers dump messages that come from IPs that do not match the email address domains.  That's what SPF was created for.
0
 
Richard KortsAuthor Commented:
Are the 'lawnsprinklerservices.com' addresses part of your web hosting account?

Yes.

FYI, I downloaded the phpMailer class Ray talked about, put a VERY simple example in & ran it, GOT NO EMAIL.

This is driving me nuts!!

See attached (for code using that class).
phpmailer-test1.php
0
 
Ray PaseurCommented:
This is sort of a rhetorical question... but it would be worth an answer, if only to illustrate how hard it is to get automated email right.  How did you test to see if phpMailer did its job?
0
 
Dave BaldwinFixer of ProblemsCommented:
I used your PHPmailer code with my email addresses and it worked except I got an error on line 16.  And by the way, your version of PHPMailer is very old.  Current version here: https://code.google.com/a/apache-extras.org/p/phpmailer/downloads/list
0
 
Richard KortsAuthor Commented:
I downloaded the Feb 2013 version of PHPMailer (per Dave Baldwin). I tried 3 variations of my test program(attached). The first one uses the "real" customer from email. The 2nd uses my old email (which still exists) as the from email. The 3rd one uses NO from email.

I ran all 3. NONE sent me an email.

Thanks
phpmailer-test1.php
phpmailer-test2.php
phpmailer-test3.php
0
 
Dave BaldwinFixer of ProblemsCommented:
I would expect that #1 is the only one that even could work.  #3 with no 'From:' email is definitely a sign of spam.
0
 
Richard KortsAuthor Commented:
DaveBaldwin

OK, so what is wrong with # 1?

Thanks
0
 
Dave BaldwinFixer of ProblemsCommented:
Except for this eregi_replace() warning, nothing as far as I can tell.  When I run it, it does send the email to my Gmail account.

Deprecated: Function eregi_replace() is deprecated in /home/content/26/11643126/html/rkortsPHPMailer.php on line 16
0
 
Richard KortsAuthor Commented:
To all,

I removed the eregi_replace. I ftp'd the test (phpmailer_test1) & the phpmailer class to one of my hosting accounts.

I ran it, it worked, I got the email.

It's got something to do with 1 & 1 (the current host).

The hosting is sitting on a so called "cloud server" at 1 & 1; customer support is kind of surly & "they can't debug php code" (I didn't ask about this case; just from prior experience).

Any suggestions?

I suppose I could reprogram things & put the email part at my host, or maybe I could ajax to it from the 1 & 1 account, just for this?
0
 
Dave BaldwinFixer of ProblemsCommented:
I thought you were on Godaddy.  The only suggestion I have if you are on 1and1 is to Move.  I refuse to use 1and1 for anything.  I don't even take jobs from clients that use 1and1.
0
 
Richard KortsAuthor Commented:
To all,

I was wrong. I had NOT used the version with eregi_replace removed at 1 & 1.

I ran that, it worked.

FINALLY!

I agree, Dave, about 1 & 1. The customer has a bunch of sites there, etc., I cannot ask him to move.

But now that it works..........................

Thanks
0
 
Dave BaldwinFixer of ProblemsCommented:
Well, I'm glad you got it working.  But I would ask him about moving anyway.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 8
  • 8
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now