Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
kenhero  
#1 Posted : Saturday, June 10, 2023 1:26:50 AM(UTC)
kenhero

Rank: Newbie

Groups: Registered
Joined: 6/10/2023(UTC)
Posts: 0
Italy

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?
ivan  
#2 Posted : Monday, June 12, 2023 6:56:47 AM(UTC)
ivan

Rank: Administration

Groups: Administrators
Joined: 11/11/2010(UTC)
Posts: 1,149

Thanks: 9 times
Was thanked: 54 time(s) in 54 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.
Users browsing this topic
Forum Jump  
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.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.306 seconds.

EXPLORE TUTORIALS

© All Rights Reserved, AIFEI Software Limited & AdminSystem Software Limited.