I'm trying to send emails using Serilog.Sinks.Email NuGet package (v1.5.0.0) with the Mandrill SMTP service. The following code executes but does not send any emails. When I try and use the same credentials using the System.Net.Mail.SmtpClient, it works and send an email.
EmailConnectionInfo info = new EmailConnectionInfo()
{
EmailSubject = "Email subject",
FromEmail = "from#gmail.com",
MailServer = "smtp.mandrillapp.com",
NetworkCredentials = new NetworkCredential("mandrill_username", "mandrill_apikey"),
Port = 587,
ToEmail = "to#gmail.com"
};
Log.Logger = new LoggerConfiguration()
.WriteTo.Email(info)
.CreateLogger();
Log.Error("Houston we have a problem");
As you spotted, this was a bug in the latest build of the Email sink, which your graciously-provided pull request has fixed. Version 1.5.13 of the sink, now on NuGet, includes the fix.
Related
I'm using EmailService in order to send a basic email:
String subject = request.getParameter("subject");
String body = request.getParameter("body");
EmailAddressModel fromAddress = modelService.create(EmailAddressModel.class);
fromAddress.setDisplayName("test#test.es");
fromAddress.setEmailAddress("test#test.es");
List<EmailAddressModel> addresses = new ArrayList<>();
addresses.add(fromAddress);
EmailMessageModel email = modelService.create(EmailMessageModel.class);
email.setSubject(subject);
email.setBody(body);
email.setToAddresses(addresses);
email.setFromAddress(fromAddress);
email.setReplyToAddress("myaccount#gmail.com");
modelService.save(email);
emailService.send(email);
Where do I configure the password of "myaccount#gmail.com" in order to make the Hybris SMTP server authentificate with my personal mail and send the email?
You can configure below parameters in local.properties file or you can change them in hac for runtime only.
mail.smtp.server
mail.smtp.port
mail.smtp.user
mail.smtp.password
mail.pop3.beforesmtp
mail.pop3.password
mail.pop3.server
mail.pop3.user
mail.from
mail.replyto
mail.use.tls
You can get more detail from blog post.
I’m using python to send emails using Mailgun’s SMTP server. I wish to use Mailgun’s builtin ability to tag my messages, and to track open and click events.
I know this can be done using Mailgun’s send message API, by adding headers like o:tag, o:tracking, o:tracking-clicks and o:tracking-opens (as explained here: https://documentation.mailgun.com/en/latest/api-sending.html#sending)
However, seeing as I'm the SMTP gateway and not the API, I’m trying to understand how to achieve the same result - emails that are tagged and fully tracked in Mailgun.
Any thoughts on how it can be done?
This is my little script at the moment:
message = MIMEMultipart("alternative")
message["Subject"] = "This is an email"
message["From"] = “<from email>”
message["To"] = “<to email>”
htmlpart = MIMEText("<html><body>email here!</body></html>", "html")
message.attach(htmlpart)
server = smtplib.SMTP_SSL(“<smtp server>”, 465)
server.ehlo()
server.login(“<username>”, “<password>”)
server.sendmail(from_addr=“<from email>”, to_addrs=“<to email>”, msg=message.as_string())
server.close()
Found it!
The following X-Mailgun headers can be added:
https://documentation.mailgun.com/en/latest/user_manual.html#sending-via-smtp
So my script would be:
message = MIMEMultipart("alternative")
message["Subject"] = "This is an email"
message["From"] = “<from email>”
message["To"] = “<to email>”
message["X-Mailgun-Tag"] = "<tag>"
message["X-Mailgun-Track"] = "yes"
message["X-Mailgun-Track-Clicks"] = "yes"
message["X-Mailgun-Track-Opens"] = "yes"
htmlpart = MIMEText("<html><body>email here!</body></html>", "html")
message.attach(htmlpart)
server = smtplib.SMTP_SSL(“<smtp server>”, 465)
server.ehlo()
server.login(“<username>”, “<password>”)
server.sendmail(from_addr=“<from email>”, to_addrs=“<to email>”, msg=message.as_string())
server.close()
Now my email is tagged (can be analysed on a tag level in Mailgun), and clicks are tracked.
Happy days!
I am trying to send Email from an asp.net webform using Gmail.
the code works from my machine but when I upload the code to my windows server 2012 in Azure I get
Unable to connect to Remote Server - exception
here is my code:
MailMessage mail = new MailMessage();
mail.Subject = "Subject";
mail.Body = "Main body goes here";
mail.From = new MailAddress("myAcount#gmail.com");
mail.IsBodyHtml = true;
mail.BodyEncoding = System.Text.Encoding.Unicode;
mail.SubjectEncoding = System.Text.Encoding.Unicode;
mail.To.Add("aaaa#gmail.com");
NetworkCredential cred = new NetworkCredential("myAccount#gmail.com", "myPwd");
SmtpClient smtp = new SmtpClient("smtp.gmail.com");
smtp.EnableSsl = true;
smtp.Credentials = cred;
smtp.Port = 587;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(mail);
Any ideas?
Make sure the local VM's Firewall rules are permitting outgoing connection via port 587. Here is a good article on how to create outbound Firewall rule.
Is there any possibility to send a mail in sharepoint 2010 using gmail smtp configuration.
I tried using .net.It is successfully going.. But i need this in sharepoint 2010 without usind SMTP configuration in Central administration in sharepoint 2010
I tried it by using event handler, but i can't
thanks in advance.....
//SmtpClient serverobj = new SmtpClient();
//serverobj.UseDefaultCredentials = true;
//serverobj.Credentials = new NetworkCredential("xxx#gmail.com", "Password");
//serverobj.Port = 587;
//serverobj.Host = "Smtp.gmail.com";
//serverobj.EnableSsl = true;
//MailMessage msgobj = new MailMessage();
//msgobj.From = new MailAddress("xxx#gmail.com", Subject ", System.Text.Encoding.UTF8);
//msgobj.To.Add("yyy#gmail.com.com");
//msgobj.Subject = "New Application Request";
//msgobj.Body = "Hi this is test mail";
//serverobj.Send(msgobj);
I wrote a WCF service for sending mail in Silverlight:
using System.Web.Mail;
MailMessage msg = new MailMessage();
msg.From = emailFrom;
msg.To = emailTo;
msg.Subject = msgSubject;
msg.Body = msgBody;
msg.Priority = MailPriority.High;
SmtpMail.Send(msg);
success = true;
This works fine in localhost, but when I host it in IIS, it doesn't show any error, but no mail has been received. What may be the problem?
Try to set the smtpserver property for the smtpmail class before you call the send method.