Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

php mail

Posted on 2013-10-30
18
Medium Priority
?
369 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 8
  • 2
18 Comments
 
LVL 84

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 84

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 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 600 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 84

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 111

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
 
LVL 84

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 84

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 84

Accepted Solution

by:
Dave Baldwin earned 1400 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 84

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 84

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

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

670 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