View Full Version : Send email (Apache/PHP)
09-09-2011, 10:06 PM
I need to be able to send mail with PHP. However, the php mail() function doesn't send to Yahoo (or better put, the email never arrives in Yahoo mail boxes) and isn't very capable of mass sending. So how can I go about setting up a working, reliable mail system that can mass send and be received by Yahoo mailboxes? A link to a tutorial would be great.
09-09-2011, 10:22 PM
The reason it doesn't end up in yahoo boxes is because yahoo is very strict and throws a lot of stuff into the spam folder.
Secondly what is your setup? Is it a windows Apache and PHP setup or linux? - If windows, do you have a SMTP client such as fakesendmail or msmtp? - PHP will need this to actually send the email (PHP itself doesn't send anything - the mail function calls an externally configured program to send it).
mail() when used in conjunction with a smtp client and a smtp server such as gmail works pretty well most of the time but you can never guarantee to get your email past strict spam filters like yahoo use.
09-09-2011, 10:39 PM
Right now I'm running Apache on windows while I develop my site but when I put it live it will probably be off a Linux/Apache server (either through GoDaddy or HostMonster). As for an SMTP client, unless it came preinstalled with anything, I don't have one.
And I'm not talking about it being marked as span. When I send something to my Yahoo email address it never arrives at all.
09-09-2011, 11:26 PM
Probably because you have no smtp client running then.
Did you use something like xampp or uniserver? - both of those come setup out of the box.
Also, mail() returns a boolean to indicate whether or not it successfully communicated with the external sendmail program. If it succeeds it returns true. If it doesn't: False.
You should test for this in your code (which you've not shown) like so:
09-09-2011, 11:32 PM
Well I was looking for an alternative to mail(), thus why I haven't posted any code. In the past what I used was something like:
$to = 'firstname.lastname@example.org';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: email@example.com' . "\r\n" .
'Reply-To: firstname.lastname@example.org' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
Currently I'm hosting off my own computer (the not sending to Yahoo problem was back from hosting with 000webhost and GoDaddy), so I'll work on setting up a mail server and post back later.
09-09-2011, 11:49 PM
You don't need a mail server. You need a mail client or more specifically a smtp client such as 'fakesendmail'.
Also as advised, you really should put mail() into an if conditional. Expanding on my previous example:
print 'mail sent';
print 'mail NOT sent';
As I'm sure you can see, putting it into an if conditional has a major advantage.
As for an alternative to using mail() you could use PHPMailer but thats only as good as the SMTP client you're using (or in your case not using).
My personal recommendation is that you download xampp or uniformserver. Both come with everything preconfigured ready to run.
09-10-2011, 12:18 AM
As for an alternative to using mail() you could use PHPMailer but thats only as good as the SMTP client you're using
PHPMailer has an SMTP client. You don't need any additional configuration or binaries from PHP. Another alternative would be SwiftMailer. Both will allow you to connect to and send mail through an SMTP email account. djh101, something to keep in mind, since you mentioned mass mail, is sending is going to be pretty slow if it has to connect to an external SMTP server as opposed to using the local mail queue.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.