Solved

php mail

Posted on 2013-10-30
18
358 Views
Last Modified: 2013-10-31
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
Comment
Question by:Richard Korts
  • 8
  • 8
  • 2
18 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39612789
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
 

Author Comment

by:Richard Korts
ID: 39612847
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
 

Author Comment

by:Richard Korts
ID: 39612857
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
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39612873
Make another version that uses "richardkorts@gmail.com" as the only 'To:' address and see what happens.
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 150 total points
ID: 39612888
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
 

Author Comment

by:Richard Korts
ID: 39613027
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
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39613050
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
 

Author Comment

by:Richard Korts
ID: 39613076
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
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39613092
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39613123
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
 

Author Comment

by:Richard Korts
ID: 39614415
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
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39614567
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
 

Author Comment

by:Richard Korts
ID: 39614587
DaveBaldwin

OK, so what is wrong with # 1?

Thanks
0
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 350 total points
ID: 39614624
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
 

Author Comment

by:Richard Korts
ID: 39614677
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
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39614718
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
 

Author Comment

by:Richard Korts
ID: 39614732
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
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39614902
Well, I'm glad you got it working.  But I would ask him about moving anyway.
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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

758 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

22 Experts available now in Live!

Get 1:1 Help Now