Dynamic subject on send port generated email - email

I've recently inherited a BizTalk 2013 setup and am struggling to get up to speed with it.
I have a send port which generates an email when it receives an XML file - currently it sends the file as an attachment to a specific email address. My question is how can I specify a custom subject which is based on the XML file contents. Currently, the subject is hardcoded into the properties of the port.
Having a subject will greatly help sorting the emails received, of which there are dozens everyday.

You need to change your send port to a Dynamic send port, and have an Orchestration or other process that sets the SMTP.Subject property and other properties such as
e.g.
Mail_MSG(SMTP.Subject) = XML_MSG.subject;
Search for the below in your favourite search engines for various examples
biztalk dynamic smtp send port

Related

Email server to receive email from any account within domain and ideally alias

I'm currently testing some complicated functionality in a web app that involves multiple accounts within the app; each with its own unique email address. I have a few temp gmail accounts that I'm using for this purpose, but keep having to update email addresses in the database to something else for some accounts in order to reuse email addresses. It gets meesy very quickly.
My question is; is there a way I can setup an email server on my VPS (Ubuntu 16.04) that is able to accept all email addresses on a given domain without me having to define each one in advance? Ie; I'd like to be able to make up email addresses as I go; test1#mydomain.com, test2#mydomain.com, etc, and have the server receive AND store any incoming emails to those addresses. Emails include account verifications, notifications, etc, and I need to know what is being sent to each participant at each point in each workflow as I test.
Ideally I'd like some way to view all of these emails on the domain regardless of address. Perhaps setting up an alias using some kind of wildcard so that all incoming email go to a single address that I can configure in my email client on my dev machine.
Consider rewriting envelope recipient x#subdomain.example.net to handler+x#example.net
AFAIR sendmail, postfix and exim support such rewrites. AFAIR all three support passing +detail as parameter to procmail script (to ~handler/.procmailrc as $1).
WARNING: test handling message to multiple special recipients.
Post which specific SMTP/MTA server do you use if you want more hints.
Gmail also supports plussed addresses BUT you get reliable hint about original recipient only for message to single special/plussed recipient.
After a lot of research and messing about with different configurations, I found the best solution for me was PostFix with Dovecot.
I was able to set up virtual mailboxes in PostFix with virtual_mailbox_maps pointing to a file that contained this; #mydomain.com mydomain.com/catchall/
This allows mail to any email address within the domain to go to one mailbox. The mydomain.com/catchall/ is a location on the server where the mailbox is located. By convention, the domain is used in the path. Useful if you are hosting email on multiple domains. Dovecot supports variables in the config which allows you to point it to the correct mailbox.
I also found that the PostFix main.cf file must have mydestination = localhost for this configuration to work.
the following posts helped me getting this up and running;
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-postfix-e-mail-server-with-dovecot
https://www.digitalocean.com/community/tutorials/how-to-install-and-setup-postfix-on-ubuntu-14-04

How to display all recipients in an email

I am currently using SMTP in a .net application to send files automatically when the user prompts the system
We have recipients setup to receive certian SSRS files, some clients want all and some clients only want one report. As such, the user just hits send and we send each client a single email with their requirements.
The issue is that since we have added this flexibility the clients have lost who is receiving the file.
Is there anyway to list all the receipients of an email in the to section or am I going to have to move all the recipients to the body of the email?

Can I replace Sitecore Email Sending Service?

By default smtp server can be configed in Sitecore web.config. However is it possible to hijack the whole email sending part to use a different method instead of a smtp server? Is there some kind of pipeline?
For example, I want to use another web service to send all emails, or I want to save all of them into a database instead of actually sending them?
Also a different question would be, does content delivery instance need to send emails by default? I would assume all out-of-box email sending are from content authoring instance right?
And from my understanding, there's only workflows in Sitecore need to send emails and it can be customized by changing the email action. (Assume no Email Campaign Modules, no Webform for Markets module and etc.)
Any insight would be great help, thanks!
--------------Update---------------------29/09/2015--------------
I have got my answers, thanks everyone.
Basically I shouldn't need to working about the smtp server on CDS instances, and all email sending can be controlled by pipelines on CAS instances.
However when I checked the source code, there's only one place "Reminder" which uses the smtp server to send emails directly. So if this function is important to you, you should consider update this function.
Yes absolutely.
At runtime when you are defining the SMTPClient you can set the properties for the server by the following code
SmtpClient client=new SmtpClient("Host");
client.Credentials=new NetworkCredential("username", "password");
MailMessage mailMessage = new MailMessage();
mailMessage.from="sender#gmail.com";
mailMessage.To.Add("recipient#gmail.com");
mailMessage.body="body";
mailMessage.subject="subject";
client.Send(mailMessage);
What you can do, instead of having the values hardcoded in the code you can retrieve the values from Sitecore Items and use those, this will allow greater control for Content Editors and even use different SMTP Server in different parts of functionality.
Item emailItem = Sitecore.Context.Database.GetItem("Id of Item");
string from = emailItem["From"];
string to = emailItem["To"];
string server = emailItem["Mail server"];
string subject = emailItem["Subject"];
string message = emailItem["Message"];
There is a SendEmail pipeline apart of Sitecore's EXM aka ECM which you can override if you take the EXM route. It has two processors FillEmail and SendEmail which you can utilise or remove and add your own processor for actually sending the message.
It is possible to save the emails to a database, or rather the content, instead of sending them. This can be achieved by custom code in Sitecore or Webforms for Marketers which has Save Actions for Sending Emails or Saving to a Database and its really simple to configure.
As you said there is no need to send emails on every occasion its more about determining what you are trying to achieve and if Sending Emails, Saving to Database etc is more relevant. The great thing about Sitecore is you can create Items programmatically and store the information there, save you worrying about creating database tables, managing ConnectionStrings, setting up EntityFramework etc.
Here is a simple blog on creating Sitecore Items Programmatically.
Sitecore Workflow sending Emails is optional and can be removed by deleting the Send Email CommandAction Item from beneath the WorkflowState Item and then publish.
The easiest way to intercept all emails is to configure Sitecore to send all emails to the locally hosted SMTP server (127.0.0.1) and then grab them from there using your custom code.
There is a lot of free SMTP servers, just make sure you test them with high volume of emails before moving to production.

Inbound email with attached file

I'm creating a new web app and I need to process files (word, pdf) sent via email message (attached files).
That also would be necessary to have a specific email address to route file to a proper destination (its a job application service, so each job opening would have its own email address).
I'm completely lost and have no idea from where I would begin.
Thanks a lot!
There are a few options here. You can:
Create a system to poll an existing IMAP account every x minutes. Then download the message, parse it and extract the attachment.
Install your own email server, and set the server up to run a script as the emails arrive.
Use a third party service that receives the email and forwards the messages as an HTTP POST (such as CloudMailin).
I wrote a blog post explaining a few of the options a few years back now for Rails but pretty much all of it is still relevant and relevant to other languages.

Accepting emails from domain with wildcard subdomain

I'm setting up an app to preform mailhooks. You create an account, assign a callback url, and a pattern to match. Then you get a subdomain that you can send email to. Something like accountname.mail.appdomain.com.
This is how it might work.
Pattern: ^(?P\w+)-reply$
Account: accountname
Callback: http://www.someotherapp.com/reply/create/
If someone sends an email to 12345-reply#accountname.mail.appdomain.com I need to be able to collect that email in I guess a catch all mailbox. Then have a background job that fetches mail and routes them based on the TO address and custom domain.
The problem I am running into is how to get the email server to accept these incoming emails. Right now I have a MX record set up that points from *.mail.appdomain.com to mx1.emailsrvr.com and mx2. When I "dig" I get the correct routing however I don't think the email server is set up to accept the incoming mail.
If this is not possible another option I have been playing with is creating a python smtp server using the built-in smtp lib. All this server would do is accept incoming requests to port 25 and place the mail in a queue. I have that working fine I'm just worried that not using a real smtp server might create problems.
BTW: The main server will be running on slicehost, if that matters.
ALSO: This server is not going to be sending email from these custom domain, if that matters.
What you need is a dynamic configuration of your mail server, right? Then this depends on your mail server capabilities.
If you use Postfix then you could add virtual domain setup being configured in MySQL tables. Or other databases. From within your application you then only need to add/remove rows in these tables to accept only the valid domains.
Same goes for Exim which is even more extensible.