Not able send Email using coltware lib in Flex - apache-flex

We are working on Flex technology to develop a desktop application, in which we will send mail to specified users.
We have used coltware library to send email to users. But the system is not sending email. We have checked code and there system is not showing any error in this.
My code is:
sender = new SMTPSender();
sender.setParameter(SMTPSender.HOST,"smtp.mandrillapp.com");
sender.setParameter(SMTPSender.PORT,587);
sender.setParameter(SMTPSender.AUTH,true);
sender.setParameter(SMTPSender.USERNAME,"myusername");
sender.setParameter(SMTPSender.PASSWORD,"mypassword");
message = new MimeMessage();
from = new INetAddress("sendfromEmailID", "From Label");
message.setFrom(from);
toRecpt = new INetAddress("sentToEmailID", "To Label");
message.addRcpt(RecipientType.TO,toRecpt);
message.setSubject("Email from Test Application");
message.setTextBody("Hello User");
sender.send(message);
sender.close();
Can you please tell us? Is anything worng with above code. if not, then why the system is not sending email??
Waiting for solution.

Does Mandrill requires two-step authentication? (OAuth, OpenAPI)?
Also check if it needs tlsocket to be specified
var tlssocket:TLSSocket = new TLSSocket();
sender.setParameter(SMTPSender.SOCKET_OBJECT, tlssocket);

Related

asp.net core 3.1 sendgrid not sending out emails

Ive been stuck with this sendgrid not sending emails out. ive tried different API keys, different emails....etc. not getting any errors with the debugger unless im seeing it wrong but, maybe someone can help me understand. This is with ASP.NET CORE 3.1
EDIT: I FIGURED IT OUT.
it was in my email sender class. the "from emailaddress" had to actually be from a real email address. I used the same email used from my sendgrid account.
var msg = new SendGridMessage()
{
From = new EmailAddress("VALID EMAIL ADDRESS", "message"),
Subject = subject,
PlainTextContent = message,
HtmlContent = message
};

Email goes to spam instead of inbox

We have a domain name "www.mycloudcctv.com" at godaddy.com and we have created a sub domain cam.mycloudcctv.com which points to 212.78.237.157
We have an application running on third party server (212.78.237.157). This application wants to send an email on our behalf using the email address “alerts# mycloudcctv.com ". Following code snippet (ASP.NET) is being used to send the email from (212.78.237.157)
var mailClient = new SmtpClient();
mailClient.Credentials = new NetworkCredential { UserName = "alerts#mycloudcctv.com", Password = "xyz" };
mailClient.Port = 25;
mailClient.Host = "smtpout.secureserver.net";
mailClient.EnableSsl = false;
var mail = new MailMessage("alerts#mycloudcctv.com", "azharmalik3#hotmail.com", "Test Smtp server", "Testing mycloudcctv server") { IsBodyHtml = true };
//Now Send the message
mailClient.Send(mail);
Everything works fine and emails are being sent however they end up in SPAM/JUNK folders of gmail/hotmail/yahoo. Could you please provide us necessary information so that our emails go to inbox instead of spam folders?
this is a BIG question with lots of complex issues, but it really boils down to three main areas:
Does the email come from a server which has be delegated the authority to deliver emails for the specified domain?
Is the content of the email just hyperlinks and does it contain text which would trigger spam assassin to mark as spam.
Is your server blacklisted for spam
For point 1 look into how to setup SPF records for send authority. http://www.mydigitallife.info/how-to-set-up-and-create-sender-policy-framework-spf-domain-dns-txt-record-with-wizard/
For point 2 get a copy of spam assassin and run your emails through it to see the score.
http://spamassassin.apache.org/
For point 3 http://whatismyipaddress.com/blacklist-check
This is not that easy. There are fair few things you have to do. For example SendGrid has some guidelines:
http://support.sendgrid.com/entries/21194967-deliverability-101
I found this blog-posting extremely useful! Give it a good read, it covers a lot of the points already mentioned here thus far:
http://www.codinghorror.com/blog/2010/04/so-youd-like-to-send-some-email-through-code.html

Send email from ASP.NET application through an external exchange server

I have an ASP.NET application pointing the 2.0 version of the framework written in C# deployed in IIS6.
I am maintaining the application therefore some of its parts are not clear to me.
The application has to send email messages through an external exchange server to and from oldMailAddress and has been done correctly. Now I added a newMailAddress and I haven't changed anything else from the code.
The oldMailAddress receives the emails send through the application, the newMailAddress doesn't. I tried to send emails to newMailAddress from my mailbox and it works correctly.
I looked for solutions on the Internet and I saw that most of them are based on SMPT services installed in IIS6. Well, I do not have these services installed and I think it is not necessary since the application was working with oldMailAddress. Hereby I attach the code that I use, I hope anybody might help.
MailMessage oMail = new MailMessage();
switch (destination)
{
case "production":
strMailAddress = "newMailAdress#domain.eu";
oMail.From = new MailAddress(strMailAddress);
oMail.To.Add(strMailAddress);
break;
case "warehouse":
strMailAddress = "oldMailAdress#domain.eu";
oMail.From = new MailAddress(strMailAddress);
oMail.To.Add(strMailAddress);
break;
}
oMail.Subject = sTitle;
oMail.IsBodyHtml = true;
oMail.Body = sHTML;
SmtpClient oSmpt = new SmtpClient("external.smpt.eu");
oSmpt.Send(oMail);
My guess is that there is either an auth issue, or the email is being caught in a spam folder # newMailAddress.
If you still can't figure it out, then I would recommend enabling logging (if you have write permissions). I have an explanation of how to enable logging over at:
http://www.systemnetmail.com/faq/4.10.aspx

Sending bulk emails from ASP.NET

In the blog I'm working on currently whenever an user posts a comment for an article I like to send emails to all the other users commented for that post. What is the best way in sending mails in this case either synchronously or asynchronously? Can anyone share a code snippet for sending email to a list of users using System.Net.Mail in .NET.
You might want to use a separate webservice for sending emails. You app will send the body and email list to the webservice. You can use gzip or zip compression. This would make the webservice call very efficient(70%+ compression as the data is text).
Now in the webservice you can use multi-threading or Async operations for sending emails.
Edit: If you have a dedicated server, making a windows service might be a better option. Make a two tables in sql server, Queued Emails and Send Emails(Archive). So whenever user posts a comment, update the Queued emails table. Now the windows service can wake up every 30 seconds, extract all the rows from Queued emails and async send all of them. After an email is send, move/remove the row from the table.
Have a look at this
Sending Email with System.Net.Mail
MailMessage message = new MailMessage();
message.From = new MailAddress("sender#foo.bar.com");
message.To.Add(new MailAddress("recipient1#foo.bar.com"));
message.To.Add(new MailAddress("recipient2#foo.bar.com"));
message.To.Add(new MailAddress("recipient3#foo.bar.com"));
message.CC.Add(new MailAddress("carboncopy#foo.bar.com"));
message.Subject = "This is my subject";
message.Body = "This is the content";
SmtpClient client = new SmtpClient();
client.Send(message);
I use this to send mails asynchronously
SmtpClient smtp = new SmtpClient();
foreach(var mail in mailsToSend)
{
new Thread(() =>
{
smtp.Send(mail);
}
).Start();
}
If you are considering a third-party service, there is a decent article on getting started with Amazon's SES Email using .NET.
This worked very well for me, but note that SendGrid just announced new pricing equal to the Amazon's SES, SendGrid includes an SMTP wrapper so the code is even simpler.
I posted another StackOverflow answer addressing this issue of sending lots emails which can find by clicking here.
It is of course better to send email asynchronously to be able to maximize on how many can be sent in a fixed time frame. You can do this yourself or use already written components to do it.
I use Fluent.NET Mail to construct and send single emails and I use MassMailer.NET to send large volumes of emails.
Fluent.NET Mail
new Mail()
.Html(new MessageTemplate()
.FromText("This is my email with {content} text")
.DataFrom(new { content = "html" })
.BetweenBraces())
.To(new MailBox(emailAddress))
.From(new MailBox(emailAddress))
.Subject("Fluent API .NET 2")
.Timeout(5000)
.SmtpServer("[your smtp server]")
.SendAsync();
Check out the post.
MassMailer.NET
Check out this post for an example on how to send a large number of emails.
MailMessage message = new MailMessage();
message.From = new MailAddress("sender#foo.bar.com");
message.To.Add(new MailAddress("recipient1#foo.bar.com"));
message.To.Add(new MailAddress("recipient2#foo.bar.com"));
message.CC.Add(new MailAddress("carboncopy#foo.bar.com"));
message.Subject = "This is my subject";
message.Body = "This is the content";
SmtpClient client = new SmtpClient();
client.Send(message);
You can find more info here or here if you need to use NetworkCredential for authentication.
Sending it synchronously? Well, it depends how many you have to send. It can be time consuming.
In the situation where I have to send bulk emails and I do not want to hung my web server I develop a custom windows services which scans the DB periodically, collects info and sends emails.

QT Mobility - Nokia QT SDK

I want to send the email from my QTSimulator. I am using the following code for send the email.
QMessage msg;
msg.setType(QMessage::Email);
// Set recipient for our email message
QString recipient("xxxxx#gmail.com");
msg.setTo(QMessageAddress(QMessageAddress::Email, recipient));
// Define message subject, body and append attachment
msg.setSubject("Messaging API example");
msg.setBody("Hello,\n\nthis is an example message.");
// Send message using a new service handle
QMessageService* svc = new QMessageService();
if (svc->send(msg))
qDebug("Successfully sent message.");
else
qWarning("Failed to send message.");
But I got the following error...
"Invalid message account ID
Failed to send message."
Please help me.. Thanks is advance.
Is it possible to send mail from QT-Simulator? Can we do any configuration for network connectivity?
As far as I know this isn't possible. Qt simulator only has feature to simulate incoming messages so you can test how your app handles them.
Once I had qt mobility with messaging compiled on my own (under windows), so it was intergrated with ms outlook. Once email was received by Outlook, messaging sent notification. I guess this would work in an opposite direction. This worked in Qt Simulator as well (but button responsible for simulating new message was not working).

Resources