I'm developing a Lumen API (on a VirtualBox) which will occasionally send out emails. However, on my dev server, I don't want to send mails; rather, I'd like the server to fake sending the mail and just return true. In the past, I've done conditionals that check if I'm on the dev server, if so, skip the entire sending mail process, but this feels like the wrong way to do it.
So what I'm trying to get to is: can I somehow get the server to not try sending the email and just move on? Am I thinking about this wrong, and should I try to get mail working on my VB or is a conditional the right way to go after all? I'd love advice on this.
If you are sending emails using illumenate/mail (Lumen 5.3 send email) you can set up the mail driver to log in your .env file for your dev environment. https://laravel.com/docs/5.2/mail.
If you are using your own functions for sending emails you should still get smtp server from .env, so you can set it to a server that will not send out any emails
Related
So I developed an application with laravel and everything is running fine. I had mail as my mail driver but my server was misconfigured, or let's say, postfix was not installed. So the mail a user sent via contact form in my laravel app never got sent. Laravel never complained so I didn't even see any errors in the logs.
My question is: Did laravel or my server save the mail it tried to send anywhere so I could see what the user tried to send me?
Unless you've somehow manually added mail logging, this won't be logged for you to send later.
Laravel's Mail functionality does include a Log driver, so that mail writes to a log- but this does not work in tandem with the other drivers, so you likely have zero logs currently.
http://laravel.com/docs/5.1/mail#mail-and-local-development
There are also several results in google on how to implement global logging for all mail sent, maybe check out this or look into laravel events.
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.
The project that I'm currently working on, is large scale. I'm using email activation method for user registration system: Sending activation code via my shared hostings smtp server to users email address after successful signup.
During tests, I have noticed that, it sends emails to famous mail services like gmail, live without any problem and receiver gets message directly but when I tried to send email to well known email server (rambler.ru), the swiftmailer script (that I'm using to send emails) returned success message. BUT another side didn't received any message. That's big problem for me.
At first I thought maybe that's scripts problem. Tried phpmailer too. No success. Then tried to send from Outlook to that server for testing purposes. The user on rambler.ru received message with very big delay. I'm using shared hosting on Hostgator. There might be users that using rambler.ru server, and I dunno if that's one and only server that occurs such problem.
How to deal with that problem? I know that, I can send from live or gmail servers with "fake" from name. But another problem, is there will be probably daily limit or something like that. Any suggestions?
Check your SMTP server's logs to see what happened to the email. Getting TRUE from mail() or swiftmailer just means that they've successfully handed the email off to your smtp server. It does NOT mean that the email was delivered to the receiving host. That comes later, AFTER your php script has exited.
I'm coding in PHP w/ CodeIgniter and I'd like to test some of the features in my app that send emails.
For some reason, I couldn't send emails through my email account in my local server (XAMPP), and I also don't want some SPAM filter to think I'm spamming while I'm testing.
So is there any email service that I can use for testing purposes? preferably one that doesn't enforce SSL, since I have problems getting that to work on my local server.
Appreciate your help.
As long as you're not sending out dozens or hundreds of test E-Mails, use whatever your everyday E-Mail provider is (e.g. GMail). Set the SMTP server of your mailing function to point to Google's. (I think SSL is optional with GMail, but I may be wrong.)
If your mailing library doesn't support using an external SMTP server, switch to a different one. But I think CodeIgniter has you covered there.
If you just want to test the application functionality, check out Papercut. This utility simulates the sending of email without having to set up a mail server, works great!
edit: had wrong link.
I like to set up a test SMTP service on my development machine and just send to that. There are several good options listed under this question.
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.