Rank: Newbie
Groups: Registered
Joined: 6/10/2023(UTC)
Posts: 0
Starting from this code: int AsyncMail::SendMail(const WCHAR *address) { ::CoInitialize(NULL); IMailPtr oSmtp = NULL; oSmtp.CreateInstance("EASendMailObj.Mail"); oSmtp->LicenseCode = _T("TryIt"); // Set your sender email address oSmtp->FromAddr = _T("xxxxx"); // Add recipient email address oSmtp->AddRecipientEx(address, 0); // Set email subject oSmtp->Subject = _T("email from Visual C++ project in asynchronous mode "); // Set email body oSmtp->BodyText = _T("this is a test email sent from Visual C++ asynchronously"); // Your SMTP server address oSmtp->ServerAddr = _T("smtp.libero.it"); // User and password for ESMTP authentication, if your server doesn't // require User authentication, please remove the following codes. oSmtp->UserName = _T(xxxxx"); oSmtp->Password = _T("yyyyy"); oSmtp->FromAddr = _T("xxxxxxx"); // If your SMTP server requires SSL connection, please add this line oSmtp->SSL_init(); _tprintf(_T("Start to send email ...\r\n")); // Attach event connection pointer CMailEvents oEvents; oEvents.DispEventAdvise(oSmtp.GetInterfacePtr()); oEvents.m_bFinished = FALSE; oEvents.m_bError = FALSE; // Set asynchronous mode oSmtp->Asynchronous = 1; oSmtp->SendMail(); // Waiting for email sending ... while (!oEvents.m_bFinished) { MSG msg; while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) return 0; TranslateMessage(&msg); DispatchMessage(&msg); } // You can do other thing here ::Sleep(10); } // Detach event connection pointer oEvents.DispEventUnadvise(oSmtp.GetInterfacePtr()); if (!oEvents.m_bError) { _tprintf(_T("email was sent successfully!\r\n")); } else { _tprintf(_T("failed to send email with the following error: %s\r\n"), (const TCHAR*)oEvents.m_lastError); } if (oSmtp != NULL) oSmtp.Release(); return 0; } So, basically this code works but I'd like to send anonymous email or an email with a fake fantasy address. Suggestions?
Rank: Administration
Groups: Administrators
Joined: 11/11/2010(UTC) Posts: 1,154
Thanks: 9 times Was thanked: 55 time(s) in 55 post(s)
In EASendMail, you can set any email address in FromAddr property: oSmtp->FromAddr = _T("xxxxxxx"); However, most email servers will check if the from address is same as the authenticated user. And I don't suggest that you use faked or anonymous email address, most email servers will reject your message or mark your email as spam.
Forum Jump
EmailArchitect Support
Email Component Development
- EASendMail SMTP Component - .NET Version
- EASendMail SMTP Component - Windows Store Apps
- EASendMail SMTP ActiveX Object
- EAGetMail POP3 & IMAP4 Component - .NET Version
- EAGetMail POP3 & IMAP4 ActiveX Object
Exchange Server and IIS SMTP Plugin
- DomanKeys/DKIM for Exchange Server and IIS SMTP
- Disclaimer and S/MIME for Exchange Server and IIS
EmailArchitect Email Server
- EmailArchitect Email Server (General)
- EmailArchitect Email Server Development
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.