Does anyone know how to send an email with an attachment(txt file) using a gmail as an smtp relayer in windows environment.I have looked at some sample code here but that was for the linux os. So far i could not find any sample code for windows.Help would be appreciated.
Google mail server will only accept secure connection, SSL or TLS. Here are the addresses and ports GMail uses: http://support.google.com/mail/bin/answer.py?hl=en&answer=13287
So, you need to use SSL/TLS-enabled socket like this one: CSslSocket - SSL/TLS enabled CSocket.
Or, if you want to implement SMTP over SSL yourself, using SChannel API, this sample will guide you through: C++ SSPI Schannel TLS example (this shows how to break through SSL and you are to complete with with SMTP plain text conversation sending an email).
Related
I have Google cloud compute server instance. And i want to send email using smtp.gmail.com with port 465 using PHPMailer function. but it return error : "SMTP error: Could not authenticate."
I don't want to used any third party mail provider like Sendgrid, Mailgun, Mailjet and G Suite.
On other server like AWS we just have to enable email setting and port to send email. I don't want to integrate any 3rd party email provider.
I am new to google cloud server configuration. Please someone help me to send email using smtp.gmail.com with port 465 from google cloud compute engine.
Thanks in advance.
As documented here, you will have to use a SMTP relay agent service using a GSuite domain. This is only if you do not want use the third party email providers. Using the SMTP realy agent service, you can only use port 465 or 587.
I know your question was asked in February of 2019, but I came across it and wanted to give more information for those who may find your question.
PHP is great for sending email because it is fast. PHP mail settings are configured in your PHP.ini file and most issues with it can be resolved via some setting in there. Google cloud has ports 465 (ssl) and 587 (tls) open for you to use. In fact, only port 25 is closed. You specified you were using 465, so you are good to go there. The issue is that you are trying to use Google's SMTP system and likely have not set up the proper configuration - hence the system cannot authenticate you. PHP just creates the message and hands it off to the system to send. The system's smptp system requires a valid login to send mail though. Remember, PHP does NOT require authentication for you to use it.
You can use POST SMTP, which is a free wordpress plugin, to help you configure things if you are using Wordpress.
Walk through this document to see what settings you may need to configure.
https://cloud.google.com/compute/docs/tutorials/sending-mail/
You said you didn't want to use GSuite, but you should read through the documentation for the setup so you can see how to configure the SMTP settings. I am including the link to read the document because email on Google Compute Engine is not trivial and there are little things to configure here and there that you should know about.
https://www.jvfconsulting.com/blog/php-mail-function-vs-smtp-guaranteed-delivery/
We have had issues with our server being used to send spam via cfmail to our remote SMTP server. I cannot see where it is occurring, but the emails are sent from a domain that is not one on our server.
Is there a way using ColdFusion administrator to specify that only emails showing as from someone#mydomain.com are sent to the SMTP host via the spool?
Thanks in advance,
Paul
It sounds to me like the <cfmail> side of things here is a red herring and you have got an open relay on your mail server. You seriously need to disable that immediately! If your SMTP server has to relay email for your CFML app then make sure it's not configured to relay everything, instead just for the IP address of the CF server, or for the credentials the CF server uses to connect to it.
If you don't know how to configure the relaying settings for your SMTP server, raise another question on serverfault.com asking how. Provide the exact details of your SMTP server, as well as the requirement to still allow relaying for the CF server.
I want to send email over SMTP using c++ code, how should I handle it in generic way that a random user don't have to handle SMTP server specification? (Windows)
Without specification means user should not have to write IP address of SMTP server etc.
Install an smtp relay server on the same host where the code runs and set the SMTP server in the code to 'localhost'.
Jasper's answer is correct. You need to install an SMTP server on the host that your C++ program is running on. One option is qmail. See www.lifewithqmail.org for more info, including a step-by-step guide on how to install it.
Most linux SMTP servers (including qmail) will create a smylink /usr/sbin/sendmail which you can use to send an outgoing message. In general, the syntax is:
/usr/sbin/sendmail recipient#domain.tld < /path/to/file/containing/the/message
See the help file for more info, including flags that you can use to specify the envelope sender, etc.
You can send a message from your C++ program by doing a system call to /usr/sbin/sendmail similar to the above.
You could use Simple MAPI, but you need an email program supporting the MAPI-interface like Outlook.
I would like to create a mail sender on C++ (not Mail Client for eg. GMail). In this mailer I want to be able to change the headers also.
I have already downloaded and installed the POCO libraries, that might help (I found it on a similar anwser).
For example, what I would like is a command like below:
e-mailsend(to,headers,subject,message);
// Or something like:
email.send(to,headers,subject,message);
However, If possible, I would like to use a C++ Mail function not a system function (like mail-utils in unix).
If you need any more explanation please comment...
In your comments you asked for an option without an SMTP server.
SMTP requires an SMTP Server. The choice is that could send emails directly (e.g. to joe at yahoo.com on port 25) or to a SMTP server that will relay the message.
Ideally, you will want your own SMTP server locally (so your application is simpler and your SMTP server sends the messages in the background, handles retries, bounces and connection errors) and use a reputable SMTP service or an existing email account.
If you want to send spam, I'd strongly advise against it.
If you want to send a small number of messages that will be opened by people expecting those messages, use a normal account (Yahoo, GMail, Google Apps, etc) and if you find your application not responsive enough, install Postfix, Sendmail or whatever local SMTP server you like.
If you want to send a large volume of emails and you are sure those message won't get you targeted as a spammer, use an SMTP service, like SendGrid (note: they also have a web API that you might find easier to use than SMTP).
Depending on which of the above you need, I'm sure answering your original question with a recommendation for SMTP C++ clients (like POCO) with become simpler.
im looking for code example or tutorial on what i need to do to code sending email
via email client ( that i already have ) that will support ssl authentication
i guess using open ssl
Boost.Asio and the Sockets Library both have SSL support. The latter has SMTP server class but unfortunately no client. I found an example client but it uses the simple C socket.h.
Update: Here are some real working examples. They all support SSL or TLS.
Msmtp: An SMTP client and SMTP plugin for mail user agents such as Mutt
sSMTP: Extremely simple MTA to get mail off the system to a Mailhub
libESMTP: lib that implements the client side of the SMTP protocol