I've been using Swiftmailer to handle my app's email communication through to Gmail for some time now.
In the last 24 hours, a whole bunch of errors about the username and password not being accepted has popped up on the server log files.
From what I can understand, my options are to set up 2-step verification, or have an app specific password. Which is the right one for this type of scenario?
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 587, 'tls')
->setUsername($username)
->setPassword($password)
;
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance();
$message->setSubject($subject);
$message->setFrom(array($from));
$message->setTo(array($to));
if(isset($cc) && $cc!="") $message->setCc(array($cc));
if(isset($bcc) && $bcc!="") $message->setBcc($bcc);
Thanks for your time and help.
Related
I want to use Gmail to send emails through Laravel.
When I apply through localhost, the email is sent correctly.
But it gives the following error on the server and the email is not sent.
local.ERROR: Swift_TransportException: Connection could not be established with host smtp.gmail.com $:stream_socket_client(): unable to connect to tcp://smtp.gmail.com:587 (Connection timed out)
Hello I had the same problem probably your solution is like that, because this helps me to resolved my issue
Create a custom app in you Gmail security settings.
Log-in into Gmail with your account
Navigate to https://security.google.com/settings/security/apppasswords
In 'select app' choose 'custom', give it an arbitrary name and press generate
It will give you 16 chars token.`
Use the token as password in combination with your full Gmail account and two factor authentication will not be required.
Note: The link in step 2 will work only if you have 2-factor-authentication enabled.
For Refference: link
use mail trap for testing
link https://mailtrap.io/ where you get your all smtp credential and put in .env file
I am developing an app.App login is through phone number and is will show password reset only if the phone is verified in client side and after than reset password request occur.So in simple i want to reset password of user without any verification in backend
so i can safely assume phone number verification is done by OTP? like when they request for password change the server will send a sms to the registered users phone number to verify that it is the actual phone number holder who is requesting for password change.
but you still have to verify that the OTP number provided by the user matches with the one generate from backend and then only change the user password.
EXAMPLE
$user = User::where('contact', $request->contact)
if($request->otp == $user->reset_otp)
{
$user->password = bcrypt($request->password);
$user->save();
}
I am using authlogic for authentication through API
I want to implement if user forgot his password then api send an autogenerated password to user's email account , I don't want to send instructions for password resetting to user email
I am not getting how to update password in database for that user record.
I have tried to reset password this way
#user.password = Params[:password]
#user.password_confirmation = params[:password_confirmation]
I searched alot not getting what exactly it needs to set password this way and I search in authlogic documentation but not getting whether these will be helpful for me.
thanks
I am using PHPMailer (via SMTP) to send out emails via my websites. I am using a windows 2012 server as my mail server which is using Hmailserver. I am using Mailgun to relay my emails.
Things I have done:
I have setup and validated my mailgun settings.
I have tested sending and receiving emails via the server without the relay (works fine).
My dilemma:
At one stage I am going to have to state the relay information, such as the authentication or hostname. So far, i see two place where i can declare this - see below:
1) Specify via PHPMailer script:
$mail->IsSMTP();
$mail->host = "smtp.mailgun.org";
$mail->Username = "username";
$mail->Password = "password";
2) Specify in hmailserver admin (on the server):
http://puu.sh/cJLpk/c3d548981c.png
Which way do I do this if I want to relay all my emails?
Using your local mail server (hmailserver) as a relay will be faster (at least for your client scripts) and much more reliable. It should be configured to point at mailgun, as in your screen shot. Mailgun should provide you with credentials that you can use for authenticating the relay.
When you send with PHPMailer, you should configure it to point at localhost, like this:
$mail->IsSMTP();
$mail->Host = 'localhost';
$mail->Username = "username";
$mail->Password = "password";
(You may not need username and password for your local server). Though it may sound odd, using SMTP to localhost is often faster than calling a local sendmail binary (or using PHP's mail() function).
In your original code you had host instead of Host - PHP is case-senetive for property names, so that would have been failing if that was your real code.
That should be all there is to it.
The only other complication is if hmailserver is also sending messages that are not supposed to go through mailgun, in which case you will need to get further into your hmailserver config.
I try to send verification emails after user's register in laravel 4 , and the user is saved on the database but the email is not send , the file email.php is configured !
Some tells me that there is a problem in Windows 7 ( smtp is not include on Windows 7 ) What do u think ??
You must configure a valid smtp server in app/config/mail.php and make sure the pretend key is false. ('pretend' => true will only log emails, not sending them)
Windows 7 has no smtp server included. Check this answer to fix that.