Link to home
Start Free TrialLog in
Avatar of Richard Korts
Richard KortsFlag for United States of America

asked on

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
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

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.  ??
Avatar of Richard Korts

ASKER

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
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
Make another version that uses "richardkorts@gmail.com" as the only 'To:' address and see what happens.
SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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.
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
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?
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
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
I would expect that #1 is the only one that even could work.  #3 with no 'From:' email is definitely a sign of spam.
DaveBaldwin

OK, so what is wrong with # 1?

Thanks
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
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.
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
Well, I'm glad you got it working.  But I would ask him about moving anyway.