phpmailer is working on localhost but not in my windows server(plesk onyx) - phpmailer

phpmailer is working on my localhost(wamp server) but not in my windows server(plesk onyx).
Could not instantiate mail function.
i got this error on my windows server.
i need to change my php.ini file?
anyone can help me please😞

There is no need to specify sendmail_path on Windows Server.
To send mail using PHP script, you should allow mail relay for localhost. It can be done by adding localhost addresses via Plesk in Tools & Settings > Mail Server Settings > White List:
127.0.0.1
::1
Or directly to mail server software. For MailEnable, open MailEnable management console, follow the path MailEnable Managment > Servers > localhost > Services and Connectors (or Connectors) > right click on SMTP > Properties > Relay, make sure that Allow Mail Relay, Allow relay for authenticated senders and Allow relay for privileged IP ranges boxes are checked, and add 127.0.0.1 to Privileged IPs....

Related

Can't set up port forwarding

So recently I started making a raspberry pi web server with apache and php, and so far I could change the html file in the default debian site and make my server go online, the only problem is that I don't how to make it public.I set up port forwarding but I'm not sure that which IP should my domain name point to (my local, or my public one) and also I'm not sure i set up port forwarding right, if possible please write down the port forwarding step by step (I'm using a D-Link router). Thanks a lot.
For Port Forwarding open your router:
login >> manual setup >> Advanced Tab >> portforwarding rules >> give your local ip address of the webserver pointing to >> for hhtp(web) open port 80 >> save the settings.
there you go you can access your server from internet.
if you like, upgrade it to https using some ssl/ certificate process, there are so many youtube tutorials which could show this.

Mail of PHP, DNS request timed out, and FQDN

I want to make mail() of PHP work in my Windows Server 2012 R2. To this end, I first installed SMTP by following this page.
One thing that confuses me is the Full-qualified domain name. WIN-RFELH8GM0KN is what it proposes by default. My server hosts several websites, does anyone know which website I should specify here?
I did not change this, as a consequence, mail www.google.com in nslookup returns DNS request timed out. So is it an error?
Of cause, my test.php does not send the mail:
<?php
mail('mymail#gmail.com', 'title', 'content');
?>
Could anyone help?
Update 1 Following the answer of #LittleAI , I started SMTP, but DNS request timed out is still there:
Update 2 Here is php.ini:
telnet localhost 25 returns the follows:
Update 3 Here was a test, which worked well: I did receive the test mail in the inbox of softtitmur#gmail.com. However, if I redo the test in Update 1, there is still DNS requested time out.. And test.php still cannot send the mail...
Update 4 I just realised that in the page I followed, it is mail.vsysad.com under nslookup (I thought it was mail vsysad.com, that is why i tried mail www.google.com which did not make sense). So it works also in my server, and there is no DNS request timed out.
Then, I double checked php.ini, I realised that sendmail_from was not uncommented. So I uncommented it and set sendmail_from = softtimur#gmail.com, as a result, mail() of php works now, so the problem is solved, though I still don't understand FQDN and its default value (ie, WIN-RFELH8GM0KN)...
The first thing I noticed is that your SMTP Virtual service in IIS is not in a starting state so this would cause an issue. Make sure this service is in a starting state before testing.
The FQDN name is mainly used for the SMTP banner which the sender will be presented when connecting over port 25 to your server.
It maybe worth installing the DNS role onto your server and create a forward lookup zone referencing a fake domain e.g test.com and create an a record within this zone called SMTP using your servers IP. Make sure to then set your server to use 127.0.0.1 as the DNS provider so it can check record before delegating the reponse to root hints/external dns forwarder.
You need to do an SMTP request using Telnet to confirm SMTP is listening on port 25. You can do this by using the localhost ip address (127.0.0.1) as shown below:
telnet 127.0.0.1 25
helo test.com
MAIL FROM: ****YOUR EMAIL ACCOUNT****
RCPT TO: ****SENDERS ADDRESS****
DATA
You would probably not receive the email from your relay to GMAIL due to SPF Record which is in place that only allows certain IP/hostnames to send as google.com, but for testing you should see your server receive the mail after data has been inputted.
Here is the guide for using telnet on your server. Just make sure you have telnet feature installed as this is not installed by default.
http://www.yuki-onna.co.uk/email/smtp.html
Additional:
telnet localhost 25
After the SMTP banner type the following command in but make sure not to make any mistakes or else you'll need to probably start your sesssion all over again.
helo test.com
You should then see a 250 response to say the server is listening
The type the following:
MAIL FROM: test#test.com
It should respond with OK. If so, then type:
RCPT TO: ***YOU EMAIL ADDRESS OF CHOICE****
Again, it should respond with OK. If so, type the following:
DATA
Press enter after the DATA command. Your now into the body of the email. For testing purposes we will miss the subject bar and just add some data to the body.
This is a test email.
Then to complete the email you need to leave a blank line by pressing return, then a full stop, then return again like so.
***BLANK LINE****
.
***Hit Return****
Screenshot all the commands but you can blank out the email so I can see the output.

smtp;550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1)

I'm running Windows server 2008 R2 but am getting smtp mail rejected from a few domains.
To test it I'm dropping a text file into C:\inetpub\mailroot\Pickup directory, with something like this:
From: my#emailaddress.com
To: someone#somewhere.com
Subject: testing
This is a test
It will send to some domains, but some are returning:
Reporting-MTA: dns;DEDICAT-93I3U5A
Received-From-MTA: dns;DEDICAT-93I3U5A
Arrival-Date: Wed, 8 Aug 2012 12:50:58 +0100
Final-Recipient: rfc822;someone#somewhere.com
Action: failed
Status: 5.5.0
Diagnostic-Code: smtp;550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1)
I understand this could be something to do with the smtp setup on the server (IIS 7.5).
Can anybody give me some advice as to where to start please?
Thanks,
Andy.
Some SMTP servers require you to send a valid host name with the HELO command that also is the same as the reverse DNS of the IP address the request originates from.
You can configure the host name the IIS SMTP Server uses through the old IIS6 Management Console. To do so, select the SMTP Server, right click and select Properties, go to the tab Delivery and then click on the button Advanced.
The reverse DNS for your IP address is usually controlled by your ISP.
FWIW, I had the same problem using hMailServer, and found the configuration instructions here. For the benefit of other hMailServer users, here's the field you need to set:
Please try enabling SMTP authentication with TLS
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.auth=true
Here is the solution to the problem.
Set the Authorization property before creating session as below.
properties.put("mail.smtp.auth", "true");

Setting up SMTP under IIS 7 on Windows Server 2008

Website started life originally under IIS 6 and the site worked great there. Now after relocating to a new server running W2K8S, everything but mail delivery from the website now works great under IIS 7.
Researched briefly on the Web to see if anybody had a good resolution, but no avail... Not even a glimmer of hope on Microsoft's own support site.
Here are the steps taken so far on the new W2K8S box:
Added the feature for SMTP under the Server Manager
Enabled SMTP e-mail for the site itself in IIS 7 Manager to deliver e-mail to SMTP server local host, unsuccessful
Enabled SMTP e-mail for the root site in IIS 7 Manager (not sure if that needs to be on to enable sites) to deliver e-mail to SMTP server local host, unsuccessful
After failing those basic setups, I wanted to be sure I can actually talk from/to the serveron port 25. And I can successfully telnet from/to the server in question to a test e-mail on port 25 get a HELO, etc. So I do not believe it is a firewall config issue.
The IIS 7 setup test was performed with both anonymous and Windows authentication - no luck either way.
Manually checked Web Config file and it reflects correct entry for the server to use the localhost.
Read the manual and no luck there either... :-/
I faced the same problem.
I came across this link http://www.frontpagewebmaster.com/m-215289/tm.htm
and I was able to solve the issue. Go to the last post of this link.
In my case I solve problem by giving rights to "NETWORK SERVICE" user to the "Pickup" folder.
Hope this might help....
OK, to the post that said "give NETWORK USER the write rights to the pickup folder" it finally works. What I did was:
You need to use a "smart host" unless you are running exchange server. I am using a Gmail account, Gmail allows SMTP forwarding.
You can use Windows authentication for security on the SMTP server and the IIS7 config setting.
First step, set the delivery method = "network" in your web page, and get your smart host configured independently of the SMTP server.
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false; // use your smart host login client.Credentials = new NetworkCredential("xxxxx#gmail.com", "password");
client.EnableSsl = true;
This will send the email directly and bypass your SMTP server.
Second step, once you have that working, write a sample windows app to use your SMTP server independent of your web page, and get that working.
SmtpClient client = new SmtpClient("your server ip", 25);
client.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
client.EnableSsl = false; // you can't use ssl with a pickup folder
client.UseDefaultCredentials = true; // use windows credentials
This will bypass your web page and make sure you have your SMTP server configured properly.
Finally, get your web page working, by setting the sharing on your pickup folder to allow write access to NETWORK_SERVICE. Transfer the login info from step 3, into your SMTP settings, set authentication to integrated security, and use the code in step 4 for your web page.
I had exactly the same problem as described in this old question. Finally I found a solution to it. In my case the operation system is W2008 R2 with IIS 7.5, but I think this doesn’t matter.
The underlying problem is that the SMTP Service in W2008 R2 seems to be a legacy part of the IIS. It is installed with the IIS 6.0 administration tools, side by side to the IIS 7.X Server. This causes two derived problems:
IIS 7.X knows nothing about the SMTP service. If you configure SMTP in ASP.NET to use the PickupDirectoryFromIis this results in an exception. Therefore you can’t use this SMTP configuration:
<smtp deliveryMethod="PickupDirectoryFromIis" />
But it is possible to configure SMTP with SpecifiedPickupDirectory, You can use this configuration:
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="C:\inetpub\mailroot\Pickup" />
</smtp>
If you configure the pickup directory in this way, you may run into a second kind of problem: IIS6 and IIS7.X have different security systems. IIS 7.X introduces integrated security with application pool identities. IIS 6.0 and its SMTP service don’t know about this. Therefore you have to grant write permissions for IIS_IUSRS to the pickup folder. In my configuration the pickup folder is C:\inetpub\mailroot\pickup.
I noticed that the event ID 4006 was refering to the domain controller ip instead of the mail server ip.
I used the iis 6 admin tool to configure a smarthost pointing to the mail server and voila! the issue was resolved.
I am not sure if this diagnostic tool can provide more insights,
http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1308
This tool is for x86.
Have you checked to see if the SMTP service is accepting mail for relay from localhost? To do this, telnet from the machine in question to the local SMTP server and use SMTP commands to send a test message. The SMTP service is very picky about command formatting so you'll have to be careful when entering commands (i.e. don't use backspace to correct typographical errors).
Is this, by chance, an old "classic" ASP app relying on CDONTS to send mail?
If so, perhaps one of these links would be helpful?
Edited: I had replied before noticing the note on the original post. Disregard...
I came across this post when researching getting SMTP running on my ASP.Net app we're migrating from IIS6 to IIS7. What I found was we didn't have to set up the SMTP SERVER at all - simply setting up SMTP Email was enough - with the additional benefit of NOT having the security concerns of SMTP relaying thru the web server!
so if you don't need your web server to actually do the SMTP routing, you don't have to set up the server at all in IIS7.

Limit dev environment to e-mail only certain domains for testing (XP smtp IIS)

I'm developing a website on an XP virtual machine and have an SMTP virtual server set up in IIS -- it delivers mail just fine. What I would like is to confirm that any emails the site sends are only going to a specific domain.
The XP firewall seems to only involve incoming connections, I can't block outgoing TCP on port 25. And I haven't been able to configure the SMTP server to filter by delivery address.
With this setup, is there any easy way to filter outgoing email by destination address?
Here's one idea:
Under Advanced Delivery options (SMTP Virtual Server Properties > Delivery tab > Advanced). There you can set a "Smart Host" which is the SMTP server that will be used to actually send the mail, so you could possibly have it deliver directly to the specific domain's incoming SMTP server.
I think the easiest way would be to add a check to your mail sending code on the website (there's got to be some class which is in charge of sending the mails out).
You could include a check which is only active when the code is compiled in debug mode (using compiler directives). Thus, when you are developing and building the site in debug mode, this code checks if the outgoing messages are valid (specific domain) or not. If they are it lets them go, else it doesn't send the mail.

Resources