Jump to content

Mail () works with Gmail, not with Yahoo & others...


supertrucker

Recommended Posts

So the mail function works fine in my scripts, and sends the email as it should to Gmail users, and others. For some reason, users with an @yahoo.com can't receive my emails. I even tested my own yahoo address and they were right. It doesn't go into spam, it just never arrives, but the mail() function returned "1" (true) as a successful send.Don't know if this is an actual PHP problem or what, doesn't make sense why gmail users can receive my email but not yahoo??ST

Link to comment
Share on other sites

The mail function return value doesn't indicate whether or not the mail was successfully sent, it only indicates whether the outgoing mail server accepted the mail for delivery. There's no way to guarantee that the mail successfully made it from the outgoing server to the destination server though, at least not with PHP. It's probably an issue with headers. Make sure that the from header is a valid address and matches the domain that the mail is coming from and make sure the mime-type and other headers are valid. You might also want to contact Yahoo and see what restrictions they have on incoming mail.

Link to comment
Share on other sites

Here's my test script, everything looks fine, the addresses=domain as you stated, and Yahoos guidelines are pretty straightforward, with no mention of how to organize or what to include in the headers. This code is pretty much a cut and paste from php.net

<?phpini_set ("sendmail_from","webmaster@mysite.com");$to	  = 'Andy <someaddress@yahoo.com>';$subject = 'A Test Subject';$message = 'hello, this is a test.';$headers = 'From: webmaster@mysite.com' . "\r\n" .	'Reply-To: webmaster@mysite.com' . "\r\n" .	'X-Mailer: PHP/' . phpversion()."\n\n";$m=mail($to, $subject, $message, $headers);if ($m) { echo "Mail sent successfully!"; }else { echo "Mail was not sent!"; }?>

Obviously "mysite.com" is my actual site address :)The only thing that confused me in Yahoo's guidelines, were a statement that postmasters should use DomainKeys. Is that something simple to setup? I clicked on a link to the DomainKeys web site, got scared and left!Thanks,ST

Link to comment
Share on other sites

<?php$to = 'Andy <someaddress@yahoo.com>';$subject = 'A Test Subject';$message = 'hello, this is a test.';$headers = 'From: [email="webmaster@mysite.com"]webmaster@mysite.com'[/email];mail($to, $subject, $message, $headers);print "You have sucessfully sent the email!";?>

you can't see if the server at the other end has accepted the email,try this this works for me i tested to yahoo, hotmail, gmail, and more they all send to servers!scott

Link to comment
Share on other sites

<?php$to = 'Andy <someaddress@yahoo.com>';$subject = 'A Test Subject';$message = 'hello, this is a test.';$headers = 'From: [email="webmaster@mysite.com"]webmaster@mysite.com'[/email];mail($to, $subject, $message, $headers);print "You have sucessfully sent the email!";?>

you can't see if the server at the other end has accepted the email,try this this works for me i tested to yahoo, hotmail, gmail, and more they all send to servers!scott

... I tried this and it did absolutely nothing. It would be nice if I could see my sendmail logs, but StartLogic won't grant me access to them, or even let me see a snippet of it because it's a shared mail server (argh!). Any other ideas? I'm at wits end here, with lots of confused people who are trying to register with my service and never get their verification email!ST
Link to comment
Share on other sites

have u checked ur php.ini if you have access to it and are you sure you got a mialing service?i know there simple but u might just no thought of them!if you have post the whole script maybe we could source out the problem!

Link to comment
Share on other sites

This might have something to do with domainkeys. You might want to contact your host to see about support for domainkeys. To set that up yourself you need to be able to compile and install a filter for sendmail (I assume PHP is using sendmail on your server) and edit the DNS records to add your public key to the DNS records. You might be able to avoid the compile and install step if your host has already done that.

Link to comment
Share on other sites

@scott - That code snippet I posted up above is the entire script, it does work when I change the address to an @gmail.com address, just not @yahoo (and presumably not @hotmail as well).@justsomeguy - Yes, php is using sendmail, and no :) I don't have access to compile it, but I DO have access to put in custom DNS records. Where would I get a public key?Thanks!ST

Link to comment
Share on other sites

You could try using SMTP instead of mail() and see if that makes any difference. (You'd have to make sure your server is properly configured though).http://email.about.com/od/emailprogramming...qt/et073006.htm
That worked! According to that article, I have a whole slew of mail tools and others, something called PEAR. What is PEAR, and what else can it do? There is also something else available to me called Python, what's that? This should be stickied for all StartLogic users!ST
Link to comment
Share on other sites

Pear is a library for PHP that includes a set of new packages and classes to use. It has packages to work with mail, databases, sockets and connections, all kinds of utility things. It's easier to send an email with an attachment using the Pear mail package then it is to look up the RFC email specs and figure out how to format a multi-part email to include an attachment. Python is another scripting language altogether.

Link to comment
Share on other sites

  • 4 weeks later...

Can you retrieve mail using PEAR, or is there a better method? I'm working on a method where a user can text a photo to an email account, i.e., photos@mysite.com and it will upload it to their profile or whatever. So I would need to be able to check the email for a specific user access key using POP3 (user number or something) and move the attachment to the proper directory. So I guess my question is, what's the best method for this?

Link to comment
Share on other sites

I feel that I should specify that my server is a hosted one. There are no POP3 PEAR modules included, and I don't have rights to add more. I did notice that there are some PERL POP modules, but have no idea how I could incorporate them into my project...

Link to comment
Share on other sites

Nevermind, redwall answered that above, and I answered this myself here: http://w3schools.invisionzone.com/index.ph...amp;hl=pop3+php

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...