is there anyway to Send Email to someone in Qt?
-
@JonB said
Alpha Centauri
Haha. that might take some time... ;)
Ok maybe i went too far with "very" :) -
@opengpu
not directly, only with 3rd party libs:
https://github.com/cutelyst/simple-mail
https://github.com/bluetiger9/SmtpClient-for-Qt
...
and a SMTP server of course.or via IMAP server
http://trojita.flaska.net/wrote on 25 Apr 2019, 12:37 last edited by@raven-worx
after cmake and compile error in vs:
simple-mail-master\build\src\simplemail-qt5_autogen\include_Debug\EWIEGA46WW/moc_sender.cpp(197): error C2491: 'SimpleMail::Sender::staticMetaObject': definition of dllimport static data member not allowedvs2017, x64,
Qt\5.12.3\msvc2017_64\lib\cmake\Qt5\Qt5Config.cmake -
@raven-worx
after cmake and compile error in vs:
simple-mail-master\build\src\simplemail-qt5_autogen\include_Debug\EWIEGA46WW/moc_sender.cpp(197): error C2491: 'SimpleMail::Sender::staticMetaObject': definition of dllimport static data member not allowedvs2017, x64,
Qt\5.12.3\msvc2017_64\lib\cmake\Qt5\Qt5Config.cmake@opengpu
i haven't written nor used those 3rd party libs, i just pointed them out. -
wrote on 26 Apr 2019, 09:25 last edited by
thank you
-
wrote on 17 Jun 2019, 03:05 last edited by opengpu
anyone ever used libcurl to send email to smtp server?how many milliseconds it need for sending mail one time?is it fast enough to send email by libcurl in mainThread?
i tried this one, it works. but it's slow, as it needs about 3000 milliseconds for sending email one time.
https://github.com/bluetiger9/SmtpClient-for-Qt -
anyone ever used libcurl to send email to smtp server?how many milliseconds it need for sending mail one time?is it fast enough to send email by libcurl in mainThread?
i tried this one, it works. but it's slow, as it needs about 3000 milliseconds for sending email one time.
https://github.com/bluetiger9/SmtpClient-for-Qt@opengpu said in is there anyway to Send Email to someone in Qt?:
as it needs about 3000 milliseconds for sending email one time.
you mean 3000 ms till you've sent the email contents to the server?
or 3000 ms till you received it in the receivers mailbox? -
@opengpu said in is there anyway to Send Email to someone in Qt?:
as it needs about 3000 milliseconds for sending email one time.
you mean 3000 ms till you've sent the email contents to the server?
or 3000 ms till you received it in the receivers mailbox?wrote on 17 Jun 2019, 06:28 last edited by@raven-worx just the sent code complish
-
wrote on 17 Jun 2019, 06:29 last edited by
// First we need to create an SmtpClient object // We will use the Gmail's smtp server (smtp.gmail.com, port 465, ssl) SmtpClient smtp("smtp.gmail.com", 465, SmtpClient::SslConnection); // We need to set the username (your email address) and password // for smtp authentification. smtp.setUser("your_email_address@host.com"); smtp.setPassword("your_password"); // Now we create a MimeMessage object. This is the email. MimeMessage message; EmailAddress sender("your_email_address@host.com", "Your Name"); message.setSender(&sender); EmailAddress to("recipient@host.com", "Recipient's Name"); message.addRecipient(&to); message.setSubject("SmtpClient for Qt - Demo"); // Now add some text to the email. // First we create a MimeText object. MimeText text; text.setText("Hi,\nThis is a simple email message.\n"); // Now add it to the mail message.addPart(&text); // Now we can send the mail if (!smtp.connectToHost()) { qDebug() << "Failed to connect to host!" << endl; return -1; } if (!smtp.login()) { qDebug() << "Failed to login!" << endl; return -2; } if (!smtp.sendMail(message)) { qDebug() << "Failed to send mail!" << endl; return -3; } smtp.quit();
-
wrote on 17 Jun 2019, 06:30 last edited by
the time before the 1st line between after the last line.
-
@opengpu
does it help to keep the SmtpClient instance? instead of creating a new one everytime you send an email -
@opengpu
does it help to keep the SmtpClient instance? instead of creating a new one everytime you send an emailwrote on 19 Jun 2019, 07:51 last edited by@raven-worx said in is there anyway to Send Email to someone in Qt?:
does
seems not. i put all of this in another thread. so better. but the time of this func is still slow. the time is mainly cost on connectToHost, login, sendMail. and u can easily test it.
-
@raven-worx said in is there anyway to Send Email to someone in Qt?:
does
seems not. i put all of this in another thread. so better. but the time of this func is still slow. the time is mainly cost on connectToHost, login, sendMail. and u can easily test it.
@opengpu said in is there anyway to Send Email to someone in Qt?:
seems not. i put all of this in another thread. so better. but the time of this func is still slow. the time is mainly cost on connectToHost, login, sendMail. and u can easily test it.
well it doesn't matter if you move it to another thread if you still create a new instance everytime you send an email.
Also where does the
SmtpClient
class come from? -
wrote on 16 Apr 2020, 08:58 last edited by
Since no one has mentioned it, you can use
QDesktopServices::openUrl()
with a URL like "mailto:anybody@anywhere.com" which will open the default email client as a new message to that address. However, the user must fill in the subject and message body as well as adding any additional CC or BCC addresses, etc.But this might be enough if it is all you need, and extremely simple to use.
-
wrote on 25 Jan 2021, 19:10 last edited byThis post is deleted!
-
wrote on 19 Jan 2022, 19:24 last edited by maksimilijanThis post is deleted!
-
This post is deleted!
wrote on 19 Jan 2022, 19:49 last edited by@maksimilijan
This is what POP3 or IMAP do? -
This post is deleted!
@maksimilijan Please stop double posting!
https://forum.qt.io/topic/70601/how-to-send-email-using-qt-5-5-1/22 -
@maksimilijan
This is what POP3 or IMAP do?wrote on 20 Jan 2022, 11:27 last edited byThis post is deleted! -
This post is deleted!
@maksimilijan said in is there anyway to Send Email to someone in Qt?:
the professor didn't specify
Do you want that somebody does your home work for you?
-
@maksimilijan said in is there anyway to Send Email to someone in Qt?:
the professor didn't specify
Do you want that somebody does your home work for you?
wrote on 20 Jan 2022, 13:07 last edited byThis post is deleted!