phpmailer SMTP with STARTTLS encryption - encryption

would anyone know if it is possible to run phpmailer with STARTTLS encryption?
The story: an online order form that sends the output to both the site visitor and site owner. The goal is that the visitor receives an email from orders#ownerdomain.com, while the site owner receives an email from visitor#somedomain.com (the address that the visitor has filled i the online form).
I have the phpmailer running fine with my Gmail account, using TLS on port 587. I would, however, like to use mailbox provided along with the hosting (so that the from/replyTo looks professional, no freemail). Unfortunately, the hosting provider does not provide TLS - in their knowledgebase they only mention STARTTLS. I tried all combinations of SSL, TLS and STARTTLS for encryption and 465 and 587 for ports with no success.
Would anyone know if STARTTLS is somehow achievable, please?
My plan B would was to use the Gmail SMTP credentials and then tinker with addReplyTo, setFrom and addAddress in the phpmailer SMTP settings. I tried but if I use...
$mail->addReplyTo($_POST['customeremail'], $_POST['customername']);
...the from email address the site owner receives is that of my Google email - I understand this may be some Google email spoofing protection, which just doesn`t allow the SMTP to send an email with the From address taken from the form. - please see the attached ![Thunderbird screen( image: imgur.com/a/1f6vY).
Can this be possibly overridden?
I mean, with that plan B solution, I can grant Google access to send emails on behalf of orders#ownerdomain.com, that`s all fine, it will then mimick the professional domain address. But I cannot do the same for the visitor address (taken from the form), that makes sense, right?
Thanks a bunch in advance...

Yes, PHPMailer does TLS encryption by default. Look at the SMTPSecure property for more details.
Gmail does indeed prevent you from setting arbitrary from addresses, though you can pre-set aliases in your account. This is mentioned in the PHPMailer docs and has been covered many times on here.

Related

How to setup email with AWS Lightsail

I've recently hosted my wordpress website through AWS Lightsail. The site has a contact form and a newsletter, but neither are working. I'm also unable to send a password reset email through wordpress, receiving a message that the host may have disabled the mail() function.
How do I setup email on my website? Is it handled through the domain or the host? I've read that I may need to sign up for AWS SES, however I'm unsure how to proceed. My client has also informed me that they have Outlook 365 setup for the domain, but I'm unsure where that fits in.
Apologies for the vagueness. I'm new to hosting websites online, and have been unable to find any useful tutorials/resources so any help would be greatly appreciated.
I would suggest not hosting your client's email through your Lightsail server. There are a lot of extra headaches to consider and there are other services that are more reliable and offer a better more robust user interface than the options available on server.
To get your client a custom domainname email address (ie joe#domainname.com) here are two options:
Zoho -
Cost: FREE
You can sign up here: https://www.zoho.com/workplace/pricing.html?src=zmail
You need to verify the domain name for this to work (either by adding an HTML file to the site or a CNAME to the domain)
GSuite by Google - Cost: $5/user/month
You can sign up here: https://inbox.google.com/u/0/search/google%20suite#m_-1052842142248281614_
You can also get some good promotional codes to get 20% off the first year - here's one: 9746YLRVNWERPAH
And, to your question about making sure forgot password emails are sent, make sure sendmail is installed on the server (apt-get install sendmail), that the /etc/hosts file contains the following
127.0.0.1 localhost localhost.localdomain yourhostnamehere
and that port 25 is open on the server.

How to authenticate emails to prevent gmail mark it as spam

We just open a new e-commerce website and recently noticed Gmail treat our e-mails as spam (notice the red question mark). Our website run behind CloudFlare so the email server IP address is different than the domain.
We also did not send a bulk email at least not yet. There are some explanations in Google FAQ but not sure what it means or how I need to implement it. Can you please explain how to set these DKIM (preferred) or SPF.
Our website uses nopcommerce (3.70) and developed with ASP.Net.
Disclaimer: I'm not a "pro" at these things (more later):
IMHO, this is probably the simplest explanation of DKIM
SPF: in my own words: providing a DNS TXT record that identifies "where" all your emails (smtp/mta servers) can come from. The more complete/formal spec is here
You can implement both
Opinionated:
SPF is easier to implement
identify all the origins of your email, set them in your SPF record, which is a TXT record in DNS
DKIM: is more complex - your mail/smtp server/s must implement it.
As a "web developer" one can see how this would be done in ASP.Net/C#/VB - e.g. sign some payload and using HttClient send some signature in an HTTP header in some outbound request.
But this is done on an SMTP server, so unless you have one that already implements it, it's something you'll have to do...
IMHO, for DKIM, unless your SMTP/MTA implements it, I'd go for services that provide it. There are 2 types:
Transactional email services:
Not for bulk email. These are the usual "order confirmation" emails, standard support/customer service, etc. emails. They will likely have APIs for you to implement (e.g. sending your MailMessage using thier servers and/or constructing something that equates to it and send that "object" to their API).
Bulk email services
these providers will already have implementations because one of their core value propositions is "deliverability" of your bulk/marketing emails. They should (of course do your due diligence) have both implementations inherently. Will also have their own APIs for bulk email context.
Hth

Email from address changes once it is delivered

I am currently doing work for a client and am running into a bit of an issue when an email receipt is sent to the user. What is happening is that once the email address is delivered the from address is completely different then the one I am using. I have tried using a few different email addresses and they work fine. It's only the one that they really want to use that is causing the problem.
I don't have access to their site and am also unsure of how the mail is sent. What I am wondering is if anyone knows the questions that I can ask to figure out what is going on on there end. They recently changed who was handling their site so I have a feeling something may be getting mixed up.
The site is built with WordPress and is using Gravity Forms. From the changed email address I can see that they are using Bluehost since the email changes from #companyname to #boxXXX.bluehost.com.
Email servers are not my area of expertise so I really appreciate any help.
Very likely their Wordpress website is sending emails through the wp_mail() function which is nothing more than the usual mail() function from PHP.
By default if you send an email through this method it will display either the hostname of the server where the website is sitting or the SMTP server, in this case boxXXX.bluehost.com depending on what's the policy of Bluehost regarding sending e-mails.
Generally hosting provider switch off the php mail() function in shared hosting environments to prevent spam and they provide you with the details to connect to their SMTP server and send legit e-mails, if their server is sitting on a shared hosting I think you might need support from Bluehost directly, explain to them the situation and they will help you throughout the process.
If the website is sitting on a virtual dedicated server then they need to do additional configuration on it. In this case what I do is to access onto cPanel and create a new mailbox with the address I want to send from (wordpress#domain.com, info#domain.com, whatever the client wants to be displayed) and configure Wordpress to send with through the VPS SMTP (you can do that easily with this nice plugin: http://wordpress.org/plugins/wp-mail-smtp ) with the address and password you chose when creating the email account on cPanel.
From now on the email will show the correct address.
Also you might want to increase the deliverability of your message and to instruct the email servers that are receiving the email that you're using a legit account, so you should add to their DNS both DKIM and SPF server records.
Note: I suggest you to be extremely cautious when playing around with DNSes, especially when touching email related records. If you are not familiar on how setup new and change the current existing records ask for help from someone who has quite good experience and to guide you through the process so you understand how it works and the consequences of a bad formatted or clashing records.
We recently had a really bad couple of hours at work when someone touched the company records without any clue of what was doing and we ended up with no email and website working for several hours.

Send E-mail without using SMTP in Asp.net

My website uses ASP.NET to send emails, but my school's network administrator has blocked the SMTP port and services. After I visited the p2p forums I found a suggestion to use web service to send email, have you any suggestion which website would provide web service for sending emails?
I tried to use System.Web.Mail.MailMessage class to send the emails through my program, but it also fail. Anyone can help me to solve this problem? I need your help. Thank you!
You can use SendGrid.
They offer a webservice and you can send up to 200 emails a day with a free account.
They have code samples for several languages: https://github.com/sendgrid
I think Email sending with ASp.net has nothing to do with blocking of your smtp port and service of school.
You can use gmail's smtp server for sening email in your application/
SMTP URL HOST : smtp.gmail.com,
IS SSL Enabled : true,
PORT: 465,
USERId:your_username#gmail.com,
Password: Your_Password
Use Gmail, Yahoo or other Email providers to send a mail.
Please refer my answer #CodeProject - sending email to gmail from asp.net, if you want to use Gmail.
Also follow - Send Email from Yahoo, Gmail, Hotmail (C#).
Well that depends, if you are talking about the SMTP port of your network, then you can still use Gmail, Yahoo, Outlook or other ports, all you will be needing will be just a username and password alongwith the port (that must be 25) and the server address (for gmail it is smtp.gmail.com).
But if you are talking about Sending emails without using SMPT. Its not possible, with or without ASP.NET.
However, you can try using SmtpSettings for ASP.NET.
There are some other issue too. Please checked that the SmtpServer that you are using (gmail, yahoo etc) are allowed, because if they are blocked too, you would have to search for something new.
And yes, there are some other servers too. Like free email providers that would also let you use 200emails/day for free or something like that. You can check that out.
You mentioned you are using System.Web.Mail.MailMessage, here is an msdn blog post about setting the Smtp for that: http://msdn.microsoft.com/en-us/library/system.web.mail.mailmessage.aspx

How do I configure TFS to work with GMail to send TFS Alerts?

Environment: Windows Server 2008, IIS 7.0, TFS 2008
We run Google Apps for email and I'm having a heck of time setting up TFS to send alerts to our Google hosted mail.
I googled around and found a couple of workarounds however none have worked for me. Any pointers graciously accepted.
Have you tried setting up an SMTP server on the same box as TFS, then configuring it to forward to GMail? That sounds like the easiest solution.
Alternatively, you could write a SOAP endpoint that handled TFS events with as many customizations as you want. This is a little more work but a lot more flexible.
I just ran through this problem in TFS-2013.
I think the root of the problem is that Apps must sign into Google Securely. For secondary apps, that means oauth. For those that can't, Google needs "Application Specific Passwords". Since it can't really trust the email application, it requires you to generate a random password for that specific account.
The solution for me was:
Enable Email Alerts
SMTP Server: smtp.gmail.com
port: 587
SSL Required: Yes
send from: email#mydomain.com
authentication:
username: mygmail#gmail.com
password: RANDOM APP PASSWORD
Can't you just configure TFS to send outgoing email through the Gmail servers?
http://msdn.microsoft.com/en-us/library/ms400808(VS.80).aspx
Does that not do what you need, or am I missing part of the question? We're using a local SMTP server to send email out, but I don't see a reason why you couldn't use a remote one instead.
I verified that WernerCD AppPassword solution works.

Resources