SSIS Send Mail Task Failed - ssis

The following is the error i get when i execute a simple package containing send mail task. i have configured the SMTP connection manager with server-smtp.office365.com and checked the windows authentication and ssl options too.
Thanks
Error: 0xC002F304 at Send Mail Task, Send Mail Task: An error occurred
with the following error message: "The SMTP server requires a secure
connection or the client was not authenticated. The server response
was: 5.7.57 SMTP; Client was not authenticated to send anonymous mail
during MAIL FROM [BMXPR01CA0031.INDPRD01.PROD.OUTLOOK.COM]".

This is a known issue. Check out this msdn link. It states the following in answer:
The SMTP Task in SSIS only supports Windows Authentication and the
port number cannot be changed. For a SMTP server that uses non-Windows
Authentication, we can use SmtpClient Class in Script Task to send the
email
That's why sending email via office365 fails.
In order to work with office365, either you can look for third party plugins integration with SSIS or you can use script task like below:
using System.Net.Mail;
using System.Net;
.
.
.
public void Main()
{
MailMessage mail = new MailMessage("<from email address>", "<to email address>");
mail.Body = "ssis sample email body";
mail.Subject = "ssis sample email subject";
//mail.Attachments.Add(new Attachment(AttachmentDiscardContratti));
//mail.Attachments.Add(new Attachment(AttachmentDiscardOrdini));
SmtpClient client = new SmtpClient("smtp.office365.com", 587);
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("<login email>", "<login password>");
client.Send(mail);
Dts.TaskResult = (int)ScriptResults.Success;
}
ps: swap and as I am not sure which one comes first.
another sample of code is available in this SO answer (not tested by me)

this can easly be achieved using execute sql task. first create a stored procedure and execute sp_send_dbmail in your newly created procedure. this sp requires many parameters .. pass the values of these parameters from ssis and u will be good. please search more on google about this procedure . u can even send attachments on this procedure

Related

Is there a way to temporarily override Moodle's SMTP settings in a custom PHP script?

For reasons too complex to disclose here, a client of mine has requested that we develop a custom notifications script (installed under the Moodle root as a plain .php script) that runs on a cron and scans certain activities in Moodle (3.11) in order to send notifications to students (but only in one specific course) when other students are posting/participating in those other activities.
My complication comes in when trying to send emails in this notifications script using Moodle's internal mailing system, which I understand is a custom implementation of PHPMailer. The client wants the emails sent by this script to come through a different email address than the official one used by the rest of the Moodle site. So, while all regular Moodle emails (password resets, etc.) should come from "original#example.com", they want the custom emails in this script to come from "new#example.com" instead.
Example:
// prepare variables
$subject = "subject line";
$body = "some body text";
$toUser = $DB->get_record('user', array('email' => 'somestudent#example.com'));
$fromUser = $DB->get_record('user', array('email' => 'new#example.com'));
// TO DO: swap out Moodle SMTP settings - if possible?
// send email
$success = email_to_user($toUser, $fromUser, $subject, '', $body);
I am currently using the email_to_user() method in Moodle but, by changing the "from user" value (as shown above), can only change the "name" of the sender, not the email address it actually sends from. So, the result is an email with sender/header info that looks like "Custom User (via Moodle Site) original#example.com" rather than the default which is essentially "Moodle Site original#example.com".
What I actually want to appear is "Custom User new#example.com". To do this, I understand that I would need to swap out the SMTP settings prior to sending.
Is there a way to temporarily use different SMTP settings in Moodle, without overwriting the ones in the database?
If not, is there some other way or repurposing Moodle's existing PHPMailer to send emails using manual SMTP credentials - such as creating a new instance of PHPMailer using the same code packaged within Moodle by in which I can specify custom SMTP settings?
After digging through the files in Moodle's messaging and core libraries, as well as the PHPMailer docs, I came up with the following solution. This still piggybacks off of Moodle's internal mail system (PHPMailer), but is a much more direct way of creating a PHPMailer instance. Because this bypasses a lot of Moodle's additional functions, I was not able to call email_to_user() and this required manually configuring a lot of settings that Moodle would normally take care of. But, in the end, I am able to send email from the script under my Moodle webroot directory without having to install, configure, or maintain a separate mail sending library (i.e. a separate version of PHPMailer).
// create ne PHPMailer instance and configure as needed
$mail = get_mailer();
$mail->Sender = 'new#example.com';
$mail->Host = "smtp.host.com";
$mail->Port = "587";
$mail->IsSMTP();
$mail->SMTPSecure = "tls";
$mail->SMTPAuth = true;
$mail->setLanguage("en");
$mail->SetFrom("new#example.com","New Name");
$mail->Username = "new#example.com";
$mail->Password = "password";
$mail->AuthType = "Login";
$mail->IsHTML(true);
For each email that needs to go out, I then just call a few functions to update the required parameters.
// clear existing recipient list before forming new email
$mail->ClearAllRecipients();
// form new email by specifying only basic attributes
$mail->Subject = "Email Subject Line";
$mail->Body = "This is a new text body.";
// address directly to student's email
$mail->addAddress('recipient#example.com');
// send email
$success = $mail->send();

Exim forward router

I am trying to create an exim router where the from and the to headers are being fetched from a mysql database.
As I can not find much documentation about using such a forwarder for non-existing domains on the local server I am quite stuck.
I have the following router where only the receiving mail account is being matched at the moment:
virtual_user_fwd:
driver = redirect
verify = no
data = ${lookup mysql{SELECT adress FROM mail_forwards WHERE host = '${quote_mysql:$domain}' AND fwd IS NOT NULL} {${sg{$value}{\\n}{, }}}}
I need the next step: Somewhere/Somehow where I define the mail account where the mails are forwarded to.
Is there anyone who can help me get to the next step?
I have found a new way to create the mysql link
virtual_userforward:
driver = redirect
verify = no
data = ${lookup mysql { SELECT goto FROM mail_forwards WHERE adress='${local_part}#${domain}'}}
domains = *
This seems to work for the virtual test, however when testing an email I get an error 'unroutable adress'. Any ideas?

Adding DestinationConnectionOLEDB in subject of SSIS send email task

We have a package on Server A which we use to load the data into different databases on different Servers. We just change the destination Connection through "SQL Server 2008 Integration Services Package Execution Utility". When the package loads the data it sends a confirmation Email with a subject of "package name and time" that data has been loaded successfully. I want to add the destination connection (Server name and database name) in the subject to make sure the data is loading into the right destination.
Any help is greatly appreciated.
The easiest way to do this would be to use a script task to load the information into a variable.
I am assuming that if you are dynamically setting your connection that you have the connection string stored as a variable.
If so you can use the SqlConnectionStringBuilder() class in .net.
var connstring = DTS.Variables["Yourvariablehere"].Value.ToString();
var builder = new SqlConnectionStringBuilder(connstring);
DTS.Variables["servervariablehere"].Value = builder.DataSource;
DTS.Variables["databasevariablehere"].Value = builder.InitialCatalog;

XMPPError:forbidden auth error while creating new user using smack 4.1.2

I am trying to create user using smack client 4.1.2. I am getting below error.
Send XML on stream = <<"<iq from='abc.example.com' to='admin#abc.example.com/Smack' id='Dym8b-14' type='error'><query xmlns=jabber:iq:register><password>xxxxxx</password><username>user</username><registered/></query><error code=403 type=auth><forbidden xmlns=urn:ietf:params:xml:ns:xmpp-stanzas/></error></iq>">>
My ejabberd config looks like below (.yml file)
register_from:
admin: allow
...
access_from: register_from
access: register
I am still getting above error. Please help
Adding code snippet to show how I create new user using smack 4.1.0
connection = new XMPPTCPConnection(getConnectionConfiguration());
connection.connect();
connection.login("admin", "admin");
if(connection.isAuthenticated())
{
AccountManager accountManager = AccountManager.getInstance(connection);
accountManager.sensitiveOperationOverInsecureConnection(true);
accountManager.createAccount(userName, password);
connection.disconnect();
// The account has been created, so we can now login
connection.login(userName, password);
}
private XMPPTCPConnectionConfiguration getConnectionConfiguration()
{
XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
.setServiceName("abc.example.com")
.setHost("abc.example.com")
.setPort(5222)
.build();
return config;
}
I found the issue. It was due to trusted_network tag had value as loopback:allow in ejabberd config file. I changed it to all:allow. It started working.
The snippet of configuration you provide is too small and badly indented, so it is impossible to tell you what is wrong in your configuration.
However, considering your config is correct, you should check that your user is properly authenticated with the right ACL credentials before sending the register request. Most client libraries assume self user registration and try to send the register before doing any form of authentication.

Passing parameters to service by URL - How do I discover the parameter names?

I have a report to which I have execute-only access - I don't have the access to the RDL file. This report exposes several parameters which I would like to set from URL.
I've successfully changed some parameters using the standard param=data form (as explained here: http://msdn.microsoft.com/en-us/library/ms153586.aspx). However, some parameters don't have the same parameter-prompt and parameter-name.
Unfortunately, to pass parameter values by URL I must know the name of the parameter and I don't see how I can deduct from the report and its parameters prompt text. I've tried to inspect the source and post-data but to no avail.
Anyone has an idea?
Thanks
P.S I also stumbled on this: http://odetocode.com/Articles/123.aspx. However, I wasn't able to connect to the web-services of my report server.
Ugh. I'm replying to myself, hopefully someone can learn from it:
I did it, eventually, using Reporting Services web service as described here and here. A point to remember here is that the name of the service has been changed (I believe from SQL server 2005 and onward) endpoint is ReportService2005.asmx.
After adding the web reference I was still having various problems. To summarize, this is the code that eventually worked for me (note: I am in domain and the IIS I'm connecting to requires domain windows auth).
ReportParameter[] parameters;
const string historyId = null;
const bool forRendering = true;
ParameterValue[] values = null;
DataSourceCredentials[] credentials = new DataSourceCredentials[] {};
ReportingService2005SoapClient c = new ReportingService2005SoapClient();
c.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("USERNAME", "PASSWORD", "DOMAIN");
c.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
c.GetReportParameters
(
"/CycleStatus/Builds Score",
historyId,
forRendering,
values,
credentials,
out parameters
);
However, I was plagued by the following error:
"The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'"
To handle that you need to change, in your app.config the security node, like so:
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
After that everything worked fine.