Sending email in WordPress - php

my wordpress site email goes to Spam with php function,some site offer me using wp-mail-smtp plugin will repair my problem, but it doesn't help me!
when I use php mail() function my emails goes to spam
and when i use SMTP, i have an error like this: SMTP -> ERROR: Failed to connect to server: Connection timed out (110)
i use this settings for smtp (in wp-mail-smtp plugin):
From Email: noreply#mydoamin.com
SMTP host: smtp.gmail.com
SMTP port: 465
Encryption: Use SSL encryption
Authentication: Yes: Use SMTP authentication
Username: myEmail#gmail.com
Password: mypassword
this settings give me an error!
note: i use captcha code and my server tell me port 465 is Open!
how can I send email in my wordpress site ?

A connection timed out means that the connection isn't going through. This could be your host, since I just checked your settings - they look OK!
I would look into contacting your host with this. For all I know, that's all you can do, unless you are going to use a 3rd party mail API.

A connection timeout means your host is dropping your outbound request to Gmail. You'll need to send your Gmail out on the HTTPS port using a WordPress plugin called Postman SMTP.

Related

Eden mail php imap connection failure

I try to get the Gmail inbox emails using Eden mail PHP from my localhost (XAMPP Apache server). But it throws a fatal error:
Fatal error: Uncaught Eden\Mail\Exception: Problem connecting to
ssl://imap.gmail.com:993. Check server, port or ssl settings for your
email server.
in C:\xampp\htdocs\edenMail\vendor\eden\mail\src\Imap.php:357
Stack trace:
0 C:\xampp\htdocs\edenMail\vendor\eden\mail\src\Imap.php(170): Eden\Core\Exception::i()
1 C:\xampp\htdocs\edenMail\vendor\eden\mail\src\Imap.php(357): Eden\Mail\Imap->connect()
2 C:\xampp\htdocs\edenMail\index.php(36): Eden\Mail\Imap->getMailboxes()
3 {main}
thrown in C:\xampp\htdocs\edenMail\vendor\eden\mail\src\Imap.php on line 357
I have used below code in Eden mail's index.php file with my own credentials.
$imap = eden('mail')->imap(
'imap.gmail.com',
'myEmailId',
'myPassword',
993,
true);
In addition to that, I have enabled IMAP/POP3 and turned on less secure apps as well in my Gmail settings.
I have encountered this error only when I try to connect from my localhost (Windows-Xampp-Apache server). But there is no error if test code in my web server working in Linux environment.
Could anyone please help me to connect the google imap.gmail.com to retrieve inbox emails?
I have followed the instructions given in the below link and got the issue resolved. I am sharing it as if may help anyone with the same issue.
https://www.hesk.com/knowledgebase/?article=72
Having problems getting Gmail to work with HESK? Try these settings.
» Email sending
To send emails using Gmail server enter these details:
SMTP Host: smtp.gmail.com
SMTP Port: 587
SSL Protocol: OFF
TLS Protocol: ON
SMTP Username: (your Gmail username)
SMTP Password: (your Gmail password)
Also make sure your "From email address" in HESK settings is set to your Gmail email address!
Still no luck? Check with your host if they have port 587 blocked in firewall.
» POP3 fetching
To fetch mail from Gmail server enter these details:
POP3 Host: pop.gmail.com
POP3 Port: 995
TLS Protocol: ON
POP3 Username: (your Gmail username)
POP3 Password: (your Gmail password)
Important: make 100% sure that "POP3 download" in your Gmail settings
is set to "Enable POP for mail that arrives from now on". If not,
Gmail will send all existing (even read) messages to HESK when it
first connects.
» IMAP fetching
To fetch mail using IMAP from Gmail server enter these details:
POP3 Host: imap.gmail.com
POP3 Port: 993
Encryption: SSL
POP3 Username: (your Gmail username)
POP3 Password: (your Gmail password)
» Error messages
Connection timed out
Required ports are probably blocked on your server's firewall. Ask your host to configure the firewall to allow TCP connections on ports 587, 995 and/or 993.
Some hosting companies will not do that due to their policies. In that case you will need to, in order to integrate Gmail with HESK, find another host or try the HESK cloud.
Permission denied
Try logging with your google account here to unlock it for application access.
Click the "Continue" button to Allow access to your Google account.
Password error: [AUTH] Username and password not accepted. Too many
login failures
Your username and/or password is not correct, double-check them ad remember passwords are CaSe SeNSiTiVe!
Password error: [AUTH] Web login required
See this article
Error: 0 could not connect to the host "pop.gmail.com"
This could mean that:
required ports are blocked on your server's firewall. Ask your host to unblock TCP connections on ports 587, 995 and/or 993
- OR -
SSL certificate verification fails on your server. Try this:
download this file
save it somewhere to your server, for example to C:\wamp\ssl\cacert.pem
open your php.ini file
find the line
;openssl.cafile=
and change it to the location of the cacert.pem file while also removing the starting ;
openssl.cafile=C:\wamp\ssl\cacert.pem
save and restart the server
test again

how to configure my gmail id godaddy outbound setting?

I need to configure my gmail id in my application it can be hosted in GODADDY hosting porvider.
it is showing below error
Error:SMTP connect() failed.
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Some persons are Discourage Others. They are thinking about Genius.
The Answer is
SMTP config
Host : localhost
port : 25
Authentication : false

SMTP configuration not working in production

I'm trying to send an email when a form is submitted. I'm using PHPMailer to send the mail using the below configuration.
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'mail.example.in';
$mail->Port = 25;
$mail->SMTPAuth = true;
$mail->Username = 'user#example.in';
$mail->Password = 'password';
$mail->setFrom("user#example.in" , "User");
$mail->addAddress('receiver#example.in', 'Receiver');
$mail->addBCC('anotheruser#somedomain.com', 'Another user');
$mail->AddReplyTo('user#example.in', 'User');
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $message;
if($mail->send())
echo "Your request has been received. We will soon contact you.";
else echo "Unable to send your request. Please try again";
This works fine in localhost. But, when I deploy it to my server (example.in) I get the below exception.
SMTP ERROR: Failed to connect to server: Connection timed out (110)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
--EDIT--
I tried connecting to the SMTP server using telnet command, but I'm unable to add the recipient. I get the below error?
Last login: Fri Sep 16 11:08:06 on ttys000
admin:~ admin$ telnet mail.example.in 25
Trying 111.91.153.112...
Connected to mail.example.in.
Escape character is '^]'.
220 fbs-ho-mailserver.example.in ESMTP Service (Lotus Domino Release 8.5.3FP3) ready at Fri, 16 Sep 2016 11:36:01 +0530
HELO example.in
250 fbs-ho-mailserver.example.in Hello example.in ([111.91.127.222]), pleased to meet you
MAIL from: marketing#example.in
250 marketing#example.in... Sender OK
RCPT to: john.hh#gmail.com
554 Relay rejected for policy reasons.
-- EDIT --
I was able to setup this account in outlook. I'm really confused what's happening.
Your error says:
SMTP ERROR: Failed to connect to server: Connection timed out (110)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
So let's look at https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting :
"SMTP Error: Could not connect to SMTP host."
This may also appear as SMTP connect() failed or Called Mail() without
being connected in debug output. This is often reported as a PHPMailer
problem, but it's almost always down to local DNS failure, firewall
blocking (for example as GoDaddy does) or other issue on your local
network. It means that PHPMailer is unable to contact the SMTP server
you have specified in the Host property, but doesn't say exactly why.
It can also be caused by not having the openssl extension loaded (See
encryption notes below).
Some techniques to diagnose the source of this error are discussed
below.
GoDaddy
Popular US hosting provider GoDaddy imposes very strict (to the point
of becoming almost useless) constraints on sending email. They block
outbound SMTP to ports 25, 465 and 587 to all servers except their
own. This problem is the subject of many frustrating questions on
Stack Overflow. If you find your script works on your local machine,
but not when you upload it to GoDaddy, this will be what's happening
to you. The solution is extremely poorly documented by GoDaddy: you
must send through their servers, and also disable all security
features, username and password (great, huh?!), giving you this config
for PHPMailer:
$mail->isSMTP();
$mail->Host = 'relay-hosting.secureserver.net';
$mail->Port = 25;
$mail->SMTPAuth = false;
$mail->SMTPSecure = false;
GoDaddy also refuses to send with a From address belonging to any aol,
gmail, yahoo, hotmail, live, aim, or msn domain (see their docs). This
is because all those domains deploy SPF and DKIM anti-forgery
measures, and faking your from address is forgery.
You may find it easier to switch to a more enlightened hosting
provider.
The problem - rather the two unrelated problems - that you're experiencing are quite straightforward:
SMTP ERROR: Failed to connect to server: Connection timed out (110)
SMTP connect() failed.
and you have verified that the server is indeed accepting connections:
I tried connecting to the SMTP server using telnet command
Last login: Fri Sep 16 11:08:06 on ttys000
admin:~ admin$ telnet mail.example.in 25
Trying 111.91.153.112...
Connected to mail.example.in.
Your script cannot connect to the SMTP server when run from its production server.
The likely cause is that the production server has a firewall that, to avoid abuse, prevents any connection to the outside. The server can serve Web requests, but no more.
If your test had verified that port 25 was not responding, then (after checking that the host address was correct) you could have tried telnet mail.example.in 587 instead. If that worked, it could have meant that the server is not accepting insecure connections (port 25) but is accepting secure connections. With PHPMailer you could then have tried activating secure connection:
$mail->SMTPSecure = 'tls';
or
$mail->SMTPSecure = 'ssl';
If that does not work, you might still have a firewall issue; or you might need to look at phpinfo() and verify you do have OpenSSL support available in PHP.
What you need to do
ask the IT people that maintain the production server to open the firewall;
more promisingly, ask them how to send emails from that server. Chances are that you need to use the mail() function, or use localhost or 127.0.0.1 as SMTP server. Then the emails will go out through your production server's service network.
They might tell you that port 25 is not allowed, but port (say) 465 or 567 would be allowed. You will have to update your configuration and/or add TLS/SSL accordingly (see above).
or you might be allowed to connect to a third party SMTP server of which you will have to supply the IP address, to allow the IT guys to open a suitable firewall window. Then the emails will go out through the third party server.
The second problem (possibly NOT a problem)
250 marketing#example.in... Sender OK
RCPT to: john.hh#gmail.com
554 Relay rejected for policy reasons
Also to avoid abuse, SMTP Servers will not let everyone connect and send emails, but only their own customers. I see that in the PHPMailer configuration you specified an user and a password. In the telnet session you did not. So it might well be that PHPmailer could send, but not connect, while your telnet can connect, but not send.
Once you solve the connection problem, your authentication problem will either be solved or will have gone away (because you'll be using a different server supplied to you by the IT guys, for example localhost).
The third problem (might never arise)
A third way of abusing services is over-use - sending too many emails to too many people. Verify with the IT guys what the acceptable policies are for sending emails.
Problems, problems
Other things to look into are the credibility of the source (you might want to send emails on behalf of some domain which has not designated your SMTP server of choice as permitted sender), and the confidentiality of the data (even with TLS/SSL connections, if you are given localhost as the SMTP server, your IT guys will have complete, unfettered, undetectable access to any email you send. You might, or might not, be okay with that).
1st quote (from ibm community):
john.hh#gmail.com was a member of a group (Reject) that was listed in
gmail.com's "Deny messages intended for the following internet
addresses" field (in the destination server's Domino Configuration
document's Router/SMTP, Restrictions and Controls, SMTP Inbound
Controls tab's "Inbound Intended Recipient's Controls" section).
Removing Mary's hierarchical name (Mary Jones/ABC) from the members
list in the Reject (group) document allows Mary to receive messages
from the Internet.
2nd quote:
Most mail servers, to prevent them being used as anonymous spam
relays, are configured only to relay mail from certain hosts.
It's a bad idea to use your own SMTP.
Depending of what you have to do with it, you have some great chances to have your emails blocked in some ways or marked as SPAM. And you will have to spend some times to keep your server up to date.
Use online services that are white-listed for every provider and that expose API to send your transactionnal mails :
https://www.mailjet.com/
http://mailchimp.com/
...
They often propose a free account for small volume (under 2000 emails per days).
Using the API is quite trivial and can be put in place in some minutes (ex : https://dev.mailjet.com/)
Ask to your hosting provider if smtp is enabled on not on that server.I had same issue before for smtp and curl both.Contact hosting provider.
What's the phpmailer version?
You might forget to add this line
$mail->IsSMTP(); // use SMTP
after you initiate $mail.
Have a try.
So you have a GoDaddy server and you want to send email through your newly acquired SMTP Relay. Well “you can’t” is probably what you are going to find if you do some poking around Google.
If you poke around a little more you will probably find GoDaddy’s official solution is to use their internal mail relay. This is not ideal, because of arbitrary barriers they have set, such as this one:
Our dedicated servers have an outbound email limit of 1000 per day. If
you need to send more than 1000 emails per day, please call Customer
Support or open a support ticket to request a higher limit.
Quick and Working Solution: Get SMTP Relay that supports sending emails using HTTP API.
My Suggestion: (A simple and effective working solution, I am using personally)
Signup for an account in Sendgrid. Sendgrid provides free 12k emails per month, and I think that should suffice any basic needs.
First Step: Sendgrid will ask you to add few DNS records to authenticate you for sending emails on behalf of that host. So do it.
Second Step Step: Configure White Lables https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html (This is not important, but it will give professional look to the emails you are sending)
Third Step: Generate API keys
You can manage your API Keys from the SendGrid Customer Portal. Additionally, you can manage your API keys via the API itself.
Forth Step: Go ahead and write our codes.
Sending mails using PHP on sendgrid using this library available on github is easy:
// using SendGrid's PHP Library
// https://github.com/sendgrid/sendgrid-php
require 'vendor/autoload.php';
$sendgrid = new SendGrid("SENDGRID_APIKEY");
$email = new SendGrid\Email();
$email->addTo("test#sendgrid.com")
->setFrom("you#youremail.com")
->setSubject("Sending with SendGrid is Fun")
->setHtml("and easy to do anywhere, even with PHP");
$sendgrid->send($email);
How this works
GoDaddy blocks port 25, 2525, 587 and 485 which are ideal ports for SMTP. So we are using the port 80/443 and requesting the sengrid's API to send the email on our behalf behalf using port 80, and yes, we fooled GoDaddy.
I think within a few steps we can get this working properly.
In your Godaddy/Hostgator Cpanel > Select MX records > Select Domain in question > Select "Remote Mail Exchanger"
You can test mail delivery at this time, issue may be resolved.
I am sure it is set up right but trust me when it comes to good ole Cpanel, PhpMailer and Godaddy/Hostgator. It's a place where common sense makes no sense.
replace:
$mail->Host = 'mail.example.in';
with:
$mail->Host = 'localhost';
I believe this should resolve any issues assuming things like login credentials are valid.
I faced similar timeout issue , the reason was my hosting provider (Linode) .
TLDR; SMTP restrictions are in place by default for Linode on accounts created after November 5th 2019. You'll need to configure rDNS for your instance and open a Support ticket confirming CAN-SPAM compliance, and Support should lift the restrictions pretty quickly. I guess many people face this issue because of smtp restrictions
Timeout error is typical of packets dropped, so could be firewall issues between web server and SMTP server.
If you got ssh access to your server, you can try to connect to smtp using:
telnet <smtp server> 25
On timeout error even with telnet, you're quite sure that the problem is on network/firewall side.
You need to change some setting in your php.ini :
upload_max_filesize = 2M
;or whatever size you want
max_execution_time = 60
; also, higher if you must - sets the maximum time in seconds.
Were your PHP.ini is depends on your enviroment, more information:
reference
OR
Place this at the top of your PHP script and let your script loose
ini_set('max_execution_time', 600); //600 seconds = 10 minutes or set your time
I got your point. Same issue happen with me , I have just add one line and its working for me. please use ,
$mail->SMTPSecure = 'ssl';
and configure your setting according to ssl . Also properly check mail configure at your serve end.

'No Relay Access Allowed' in Swift Mailer

I recently transferred my server to VPS & now email function doesn't work for external emails.
Following are the settings I'm using:
$transport = Swift_SmtpTransport::newInstance('ns1.example.com', 465, 'ssl')
->setUsername('testing#example.com')
->setPassword('password');
$mailer = Swift_Mailer::newInstance($transport);
And the error that I'm getting is this:
SMTP error from remote mail server after initial connection:
host dedrelay.where.example.net [XX.XXX.XXX.XX]: 554
m1plded02-01.prod.mesa1.example.net : DED :
gWqF1p02c0cB4sG01 : DED : ESMTP
No Relay Access Allowed From XXX.XXX.XXX
I've tried telnet & response is ok. I've tried following:
telnet ns1.example.com 465
Response was:
connected to xx.xxx.xxx.xx
I'm also not able to configure my desktop email client. Can anyone tell a solution? Any help will be appreciated.
EDIT
I'm not even able to send an email through server's webmail. Same error.
You tried telnet ns1.example.com 465 and it connected. This shows the SMTP server is up and running and your computer can reach it. But this is not all you need.
The error message No Relay Access Allowed From 123.123.123.123 means the SMTP server is configured to not accept emails from this IP address for relay, i.e. emails that needs to be passed to another server for delivery.
This is an anti-abuse measure and it means the SMTP server is configured correctly.
There is nothing wrong with your SwiftMailer configuration. Any email client (including the desktop client, as you said) you use, the answer is the same.
You need to contact the system administrator of the SMTP server and ask them to allow your IP address to use their SMTP server as relay. If they are your ISP it's also possible that the server allows relay only after authentication: you have an username/password pair (that you use to read the emails, f.e.) and you need to use it in order to send emails through their SMTP server. But this is only a supposition (this is how it usually works); you have to ask them to know for sure.

Swiftmailer at 1and1 hosting

I have troubleshooting with sending emails at 1and1 hosting.
I use swift mailer lib message I receive is stream_socket_client(): unable to connect to mrvnet.kundenserver.de:0 http://mrvnet.kundenserver.de:0 (Connection timed out).
Does anyone have similar troubles? Any solution?
PS. At my localhost everything is OK.
I fix SMTP after contact with their support team.
SMTP parameters:
HOST: mrvnet.kundenserver.de
PORT: 25
AUTH: without auth
Contacted support, they asked me do not use encryption (neither ssl nor tls, both not acceptable), so my options are:
host: smtp.1and1.com
port: 25
login: somemail#somedomain.com
passwd: somestrongpassword=)
as you may mention i use 1and1's mail (same settings for gmail would not work)

Categories