im kinda stuck, i have read some threads where they use google smtp to send mails from localhost.
Im using xampp right now and im trying to use google smtp but it doesn't work what have i done wrong ?
Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\page.php on line 48
My Code in php.ini:
sendmail_from = T***#gmail.com
Gmail SMTP server address: smtp.gmail.com
Gmail SMTP user name: T***#gmail.com
Gmail SMTP password: ****
Gmail SMTP port: 465
Gmail SMTP TLS/SSL required: yes
You have to set the SMTP-Server, Port and authentication credentials in your php.ini.
But for this it's much easier to use the wonderful PHPMailer class.
It's very easy to implement and to use.
You can easily send complex emails (HTML, Attachments) and it has a good support for external SMTP server, including e.g. encryption.
Just take a look at the examples in the "examples" folder or scroll down at the linked page where is an example using SMTP auth in the first code-block.
Related
I want to use Google's SMTP relay service as a SMTP server in PHP.
The IP address is whitelisted for the SMTP relay service, and I am using the SwiftMailer as a PHP library to send emails.
I configured the SMTP service to use TLS encryption, and set the following parameters for the SwiftMailer:
transport: smtp
host: smtp-relay.gmail.com
port: 587
encryption: tls
auth_mode: login
I was able to send emails via telnet, but when I try to send emails with SwiftMailer with the above configuration, I receive the following error:
[CLOSED] IMAP connection broken (server response) (errflg=2)
How can I configure the SwiftMailer to use Google SMTP relay service as its SMTP server? Is it ever possible?
had similar issue, when I provided the sender_address (that I'm checking on google relay server), it worked.
(I'm not using auth mode though, just IP source defined in google gsuite)
swiftmailer:
transport: smtp
host: smtp-relay.gmail.com
port: 587
encryption: tls
sender_address: support#example.com
Since this seems to be not that well documented here is what worked for me after reading through different sources. Gmail itself wrote that it's important to send the HELO- or EHLO command, which can be done by setting the local domain (supported since swiftmailer-bundle 2.4.0). Otherwise you might run into DoS issues. See the official Google documentation for more details.
transport: smtp
host: smtp-relay.gmail.com
port: 587
encryption: tls
auth_mode: login
username: contact#yourdomain.com
password: 'yourpassword'
local_domain: yourdomain.com
Additionally I did add the IPv4 and the IPv6 address of my server within the Google Admin Console within the SMTP-Relay settings and activated TLS + SMTP-authentication, since I definitely want to have an encrypted connection between my server and gmail.
I am struggle for 2 days with this problem.
I am going to send email from my localhost using WordPress.
I am using wp_mail() function so I decided to use WP Mail SMTP plugin.
But I have a problem while configuring it.
This is screen shot of my configuration.
When I try to send test email, it fails.
Anyone please help me
From the plugins list, I've noticed you are using Postman SMTP plugin, which causes conflict with the WP Mail SMTP plugin. If you disable that plugin, it will work correctly.
Try with following SMTP setting for gmail to configure on localhost with your plugin :
HOST : smtp.gmail.com
PORT : 587
USERNAME : Your_gmail_ID
PASSWORD : Your_gamil_Password
Encryption : TLS
NOTE : Make sure your gmail account must be Allow less secure apps: ON. You can turn on less secure apps for your account using THIS URL
UPDATE
As discussed please use following setting in your plugin :
WP Mail SMTP Settings
From Email : Your_gmail_EmailID
From Name : Your_name
Mailer : Send all WordPress emails via SMTP.
Return Path : checked
After that Click on Save Changes
Now under SMTP Options
SMTP Host : smtp.gmail.com
SMTP Port : 587
Encryption : Use TLS encryption.
Authentication : Yes: Use SMTP authentication.
Username : Your_gmail_EmailID
Password : Your_gamil_EmailPassword
After that Click on Save Changes
install plugin wp mail smtp
then in general settings
From Email:your email
mailer: other smtp
SMTP Host:smtp.gmail.com
Encryption:ssl
port:456
SMTP Username: your gmail address
SMTP Password: your gmail password
save settings
after that test email by sending one to
Send To: email that you want to receive email on
and make sure your SMTP Username(your gmail) account has turn on less secure apps
hope i helped.
This image above shows the error: SMTP ERROR: Failed to connect to server: (0)
But my GMail SMTP settings are correct and working. How is this possible?
Gmail SMTP (smtp.gmail.com) use the port 587 and need a secured connection.
Otherwise it seems Google SMTP has restricted its use to Google G Suite subscriber.
You have these information and a test tool at https://www.smtper.net
I have tested myself with my G Suite mail, the test tool works great.
I am trying to send email in my local using PHP mail function but email are not send. Also it shows a warning message as below.
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost"
port 25, verify your "SMTP" and "smtp_port" setting in php.ini
Basically you cant send mail from your localhost, if you haven't configured SMTP. So for configuration you can do it as following:
If you open the php.ini file, you will find these two lines:
smtp_server
smtp_port
Add the server and port number for your host (you may need to contact them for details)
So you will need to add them to be able to send mail from a server that requires authentication. So an example may be:
smtp_server = mail.example.com or any IP address(where SMTP is configured)
smtp_port = 25
And if required, then add the following two lines don't exist:
auth_username = username
auth_password = pw
Think it will help.
Sounds like you don't have a SMTP server running on your machine, see if you can telnet to port 25 on your local machine to see if it is running or not. Or perhaps your mailserver is configured to listen on another port and PHP is configured to try the default port of 25.
Looks like your server doesn't have a smtp mailserver running. You could use these functions to set a different smtp server:
ini_set('SMTP', "server.com");
ini_set('smtp_port', "25");
ini_set('sendmail_from', "email#domain.com");
You're probably not running an SMTP server on your localhost.
if you only need an SMTP server for development purposes, and you're running Windows, install smtp4dev, which can be found here: http://smtp4dev.codeplex.com/
The error message is self-explained. The mail() function cannot connect to your mail server. Check your mail server settings.
Try to telnet to port 25 to see whether you can connect to mail server.
Use PHPMailer Instead. It has good support for all mailing problems.
Here you can find dozens of Examples
I am sending email from my localhost There occurs a server error
Failed to connect to mailserver at "smtp.bizmail.yahoo.com" port 465, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()
when i host my project to the server my function works
Now i need a solution such that the mail functionality must work in my localhost too
Download miniRelay smtp server from here. Use localhost or 127.0.0.1 as smtp server and port 25 to connect to smtp server and send emails.
Try setting smtp to "127.0.0.1" and smtp_port to 25. That's assuming your localhost is running sendmail or something similar.