This is probably a stupid question but I can't seem to find an answer anywhere. I have made a PHP mail script on localhost and I need to test it, all the emails are being forwarded to the 'xampp/mailoutput' file and I can view them as .txt files. Does this mean that my script is working fine? Or do I need to set up a tool such as 'TestMailServerTool' to test properly.
Yup If you're getting mail output that means php is sending emails successfully.
If you want to get proper email functionality you have to setup an SMTP server in your Windows System. You can also use other SMTP servers like gmail, yahoo or use one which is provided to you by your ISP or your Web Hosting providers.
Related
I am using php and Codeigniter, I need to implement the following schema
for list of emails I need to send emails for them, and if they reply to this email, I need to know if the reply and what the content of this reply and view it using my php project.
Also I need to send them a multiple choice question and they have to chose one option as answer, and then check this answer from my php project.
I can send email from my gmail, but can't send it from the wamp server itself.
Any help?
I'm not exactly familiar with CodeIgniter, but if you want to send an email, and it doesn't work, especially on Windows the common problem is that there is no SMTP server configured.
Most *nix distros have some form or another of a SMTP server running by default, Windows doesn't. When unconfigured PHP assumes localhost to be an SMTP server.
This SMTP server is what PHP needs to be able to send emails, so you'll either have to configure one or find one you can use that's provided by someone else.
For using PHP's native mail() function and any library that relies on it the configuration entries you're looking for are SMTP and smtp_port. (Have a look at: http://php.net/manual/en/function.mail.php)
It might very well be that your ISP provides a SMTP server. Otherwise you can always set up a gmail/hotmail/whatever account and use their SMTP settings. This is usually far easier than setting up your own server.
If you choose to set one up yourself, you'll want to look into SPF, so your messages don't get marked as spam by default.
This is an issue I've encountered several time and haven't yet found a decent solution for:
Sending an e-mail from a webserver on e.g. "domain.com", to info#domain.com which is hosted on an external mail server e.g. Google Mail
In my case I always send from PHP over Apache and often on shared hosting, but I can imagine this is the same case on other frameworks.
These e-mails always seem to be delivered to the local mail server, even if I set the MX records on that server to point to the right external mail server.
A solution for this is to use an external SMTP server, but this isn't always easy when you're working with clients that either need to set-up a new e-mail account on their server and provide the SMTP details or sign-up for a third-party SMTP server.
What is the solution for this? Is there no way around SMTP?
Most emai/MTA server "autoconfigure" themselves. They guess list of local email domains (doimans with locally hosted mailboxes).
In sendmail case you can turn it off adding the following line in sendmail.mc:
define(`confDONT_PROBE_INTERFACES', `True')
Documentation : cf/README - confDONT_PROBE_INTERFACES
I have had the same issue many many times (in my case using PHP on a LAMP stack).
Try/check the following.
If you are using cPanel or similar, set the MX records to the external mailserver (Google apps etc).
Set up an SPF record to allow your hosting website to send email (this way no need to configure SMTP).
This may not be applicable but if you are using something like phpmailer. Set the property $mail->isMail(); so it tries to use your SPF allowed local mail() function to send the email. Sorry for going off into very specific advice, but might help in your particular situation.
Worth checking there are not similarly named local mailboxes on your hosting box.
Hope this helps!
So I downloaded the Free Edition of MAMP free, and found out that it doesn't initially allow sending mail through PHP.
My question is very simple. What is the best and easiest way to enable it?
Thanks in advance.
This is probably not really the answer you are looking for, but if you're set on sending emails try a program like https://github.com/PHPMailer/PHPMailer
it will enable you to send emails through an SMTP server (like gmail). It will make sure your emails get delivered while working on localhost. When going live you could tell it to use PHP mail in the config (which is actually never recommended because of the spam factor and limited functionality).
That being said, while on localhost it shouldn't be necessary to send emails. Being that localhost usually implies a staging/development surrounding. What I like to do is output the to be sent email to my error log.
http://us3.php.net/manual/en/function.error-log.php
You can instantly tell how it looks and you get confirmation that your script has run that part.
It is not possible for you to send email from local server like WAMP,XAMP.
Hi I am running MAMP on my mac to locally host a website. I want to send an email using php scripts. The stuff i looked online tells me about php scripts for emails but i am unable to send emails. I am guessing this has to do with MAMP settings or maybe i have to make changes to php.ini file but i cant find information regarding that. Can i send emails to my clients using my gmail address running php scripts. I am creating a signup page where once you signup successfully, the site sents you a welcome email. Can some body please guide me how to do this. I have used code from here:
http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm
but this doesnt work.
i have used following settings:
$host = "ssl://smtp.gmail.com";
$port = "465";
MAMP is just Apache, MySQL and PHP and doesn't include a mail server. You could use postfix or, as you said, an external SMTP server.
If using Gmail make sure your account is setup to allow SMTP connections (it's off by default). This can be found somewhere in Settings in the web client. I'd recommend you test it with Mail or another mail client on your local machine to make sure Gmail is working as expected.
Finally (once the above is set up) SwiftMailer or PHPMailer are good mail libraries which can connect to remote SMTP servers. It'll save you a lot of headaches writing your own code, especially when it comes to file attachments and such.
I have some problems with the email system for CodeIgniter:
First, the emails I send out (registration, confirmations) are getting caught in standard spam filters in gmail and other mail clients. How do I get around this? How do companies like Facebook get their emails through consistently?
Second, the mailer is working locally but once we deploy it it no longer runs (doesn't send emails) but all the other forms run just fine. Anyone ever run into a problem like this?
Thanks for all the help!
I can't really answer your first question - it's not specific to CodeIgniter. You just need to make sure your email doesn't look like spam. In short - there's no way of guaranteeing your e-mail will not end up in a spam filter.
As for the second question, I expect your production server needs to be configured properly for email. You probably need to configure CodeIgniter to send email properly. I would suggest setting up an SMTP server (or using an existing one) rather than using the standard PHP mail which I think CodeIgniter uses by default.
Regarding spam, most organisations are very secretive about how they prevent spam (not wanting to publish information which helps the spammers) and in some cases they don't actually know - an obvious examlpe of this is bayesian filtering - but, for example, hotmail use a completely unaccountable army of volunteers to manually classify emails.
Do and get a copy of spamassassin and try to reverse engineer how the standard rules work. Obvious things to check are:
1) AVOIDING LOTS OF CAPITALS
2) don't mention the 'V' word
3) make sure you've got a current and restrictive SPF 1.0 policy published
4) make sure your sending from an address which has A and PTR DNS records
5) Do provide a reply-to and from email address which use your domain in the address
the mailer is working locally but once we deploy it it no longer runs
doesn't send emails
Which? These are 2 totally seperate things. If the code is falling over (if so why have you not provided the error details) then its likely a PHP version issue or a problem with the connection to the MTA (or the PHP mail config).
The latter is a problem with the MTA itself.
99.9% of problems reported as PHP mail failures have nothing to do with PHP and are problems with the MTA.
Enabled detailled error reporting for your MTA and see where it is failing.
C.
You may have to configure the email on your server differently than your local development environment. I've had to in the past.
There are two basic ways that PHP can send mail:
Via a UNIX program called "sendmail" (only on non-Windows servers and only if it is installed - check with your hosting provider)
Via a SMTP server.
If you've configured CodeIgniter to use SENDMAIL, check to ensure that the Sendmail path is correct. Your hosting provider usually provides this somewhere in their online documentation.
If you're using SMTP, you need to make sure that your server can contact the SMTP server. You can do this by logging into the server via SSH and typing "telnet your.smtpserver.com 25". If you get an error message about not being able to connect, you know you have a problem with your hosting provider connecting to your mail server.
I've been able to diagnose this problem by enabling logging on my production server (http://bit.ly/4pprd6) and adding log_message('error', $this->email->print_debugger()) right after I attempt to send a message.