modify PHPList email headers, create minimal email headers - phplist

PHPList sends email with very complex email-headers. They insert links and messages and notices and all kinds of headers that aren't needed.
Does anyone know the filenames and lines of code to edit to remove everything except the bare minimum email headers?
I don't care why they are they I, personally, only want the bare minimum email headers.
I was able to find a way to edit some of them to remove only a few of the unnecessary headers but not all of them.
Thanks in advance!

I think this is possible, you should write a plugin to provide edited fields for your emails header.
you can start by implementing the plugin messageHeaders()
/**
* messageHeaders
* return headers for the message to be added, as "key => val"
* #param object $mail
* #return array (headeritem => headervalue)
*/
function messageHeaders($mail) {
return array();
}
Here is the post discussing the subject: edit emails header for phpList
Setting up custom email headers https://discuss.phplist.org/t/setting-up-custom-email-headers-is-it-possible/977
Another post about adding custom header fields :
can check here https://forums.phplist.com/viewtopic.php?f=7&t=24474&p=91989&hilit=unsubscribe+header#p91989

Related

How do I debug curl issues (CURLOPT_MAIL_FROM, text/html display) when a message is sent out successfully?

I am successfully sending a mime message using libcurl. However, in the received email I can only see the "username" in the From: field.
curlCode_ = curl_easy_setopt(curl, CURLOPT_MAIL_FROM, from_field);
recipients = curl_slist_append(recipients, (const char *)to_);
recipients = curl_slist_append(recipients, cc.str().c_str());
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
I assume its a security feature at gmail, ensuring that the sender is always shown in the From field.
Another issues is that I send out a multi-part mime message with an alt text portion. In zoho mail, I can view the HTML, however gmail always shows the text part.
For reference, I make sure the HTML comes before the text.
/* Build the mime message. */
mime = curl_mime_init(curl);
/* The inline part is an alternative proposing the html and the text
versions of the e-mail. */
alt = curl_mime_init(curl);
/* HTML message. */
part = curl_mime_addpart(alt);
curl_mime_data(part, html_body_.c_str(), CURL_ZERO_TERMINATED);
curl_mime_type(part, "text/html");
/* Text message. */
part = curl_mime_addpart(alt);
curl_mime_data(part, body_.c_str(), CURL_ZERO_TERMINATED);
/* Create the inline part. */
part = curl_mime_addpart(mime);
curl_mime_subparts(part, alt);
curl_mime_type(part, "multipart/alternative");
slist = curl_slist_append(NULL, "Content-Disposition: inline");
curl_mime_headers(part, slist, 1);
The code is rather long and in multiple classes, so I can post any code deemed relevant to avoid clutter. Essentially I am unsure how to debug this.
The specific problem - The text part of a multi-format MIME has to be before the html part. Now both zohomail and gmail display the html.
A more general answer relating to libcurl debugging - I use the curl program instead. Use -libcurl option to generate C code that can be used in your C/C++ project. There are sample curl commands available with most REST APIs.

How to remove default disclaimer in javamail

When sending emails via javamail, the following is always appended to the bottom of each message:
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager. This message contains confidential information and
is intended only for the individual named. If you are not the named
addressee you should not disseminate, distribute or copy this e-mail.
Please notify the sender immediately by e-mail if you have received
this e-mail by mistake and delete this e-mail from your system. If you
are not the intended recipient you are notified that disclosing,
copying, distributing or taking any action in reliance on the contents
of this information is strictly prohibited.
How does one prevent this?
(NOTE: This problem is extremely frustrating to research on the web due to the fact that a disclaimer of this form is attached to so many indexed documents! :-(
JavaMail is not doing that, it is your outgoing SMTP server appending it to each message, probably set up by IT.
To confirm, you can use gmail's servers (with a personal account) and you will see it does not get added to the messages.
This should work. Pay attention to the form in which email body get parsed. In my case the emailBody string is on one line, so you have to put the "#Your disclaimer Here#" on one line. Answer for who will come in future.
public String deleteDisclaimer(String emailBody) {
String disclaimer = "#Your disclaimer here#";
if (emailBody.contains(disclaimer)) {
System.out.println("Deleting Disclaimer..");
return emailBody.substring(0,emailBody.indexOf(disclaimer));
}
System.out.println("DISCLAIMER NOT FOUND!");
return emailBody;
}

multiple mail recipients with CakePHP using bcc (the right insert method)

i use the php framework cakePHP to create a web app. There,i want the user to insert in a field as many email addresses as he desires and by hitting the Send button,a message would be emailed to all of the emails.
To achieve that,i have to use bcc.
My problem is that i do not know how can i "read" from the user his email addresses in the right form so that i use them in bcc.
Till now,i have a variable $to = $this->request->data['Mail']['to']; ,where 'Mail' is my model name,and in case the user inserts just one email address,the recipient receives the mail correctly. But how can i enable it to receive multiple email addresses (maybe in an array??) so that i use the variable $to at this piece of code:
$Email = new CakeEmail();
$Email->from($from)
->**bcc($to)**
->subject($subject)
->send($message);
and help is welcomed :)
thank you in advance!
There is the API ( http://api.cakephp.org/2.3/class-CakeEmail.html#_addBcc ) and the code is open source. They all provide the information you are looking for.
If you open the class CakeEmail you will find ( https://github.com/cakephp/cakephp/blob/master/lib/Cake/Network/Email/CakeEmail.php#L482 ):
public function addBcc()
which is different from bcc() since it can be used multiple times to add multiple bcc addresses.

How can I let individual users import their own external blog feeds in Drupal 7?

So, I'm trying to build a 'blog gateway' in Drupal 7 that will let users add/edit/remove feeds from their own external sites to a collective stream for rating, comments etc.
The site should do something along the lines of:
Let the user add a URL for their feed via the registration form
Import the most recent posts from the feed upon registration (and afterwards continually).
Create a node for each item in the feed, which can be rated by other users.
Create lists from these nodes.
Okay, so Views in combination with the Feeds module can do most of this (import feeds, create nodes for each item and create lists). I've managed to allow users to import feeds 'manually' using the Feeds module.
The problems are that I can't find a way to limit the number of feeds a user can import, and I can't figure out how to make a URL from the registration form the basis of an import.
I've been trying to solve these problems using the Rules module, but with no results.
Methinks something along the lines of the Profile Blog Information module could do the trick, but it's only available for Drupal 6 and doesn't work with the Feeds module.
Any thoughts on solutions or alternatives?
I can't find a way to limit the number of feeds a user can import
If you use the default settings of the Feeds module, you should have a "Feed" content type already. So, if you want to control the number of "feeds" a user can import, http://drupal.org/project/node_limit should do the trick, I think. It'll help you set the number of nodes of the "Feed" content type that a user can create (which should be the same thing, right?)
how to make a URL from the registration form the basis of an import
Now, I'm going to suggest a custom module route here. It should do the trick but you may/may not want to add a custom module depending on the nature of your project/your level of expertise with Drupal.
Add a URL field (probably an instance of the URL field type) to the user profile. Check to allow it to be shown in the registration form. Lets say we call it feed_url.
Implement hook_user_insert() which is called when a new user is added to the site:
/**
* Implements hook_user_insert().
*/
function MY_MODULE_user_insert(&$edit, $account, $category) {
if (isset($edit['feed_url'])) {
$index = array('feed_url', LANGUAGE_NONE, 'value');
// Get the feed URL from the registration form values.
$feed_url = drupal_array_get_nested_value($edit, $index);
if (!empty($feed_url)) {
// Create a new feed on behalf of the user
_MY_MODULE_create_feed($feed_url, $account->uid);
}
}
}
/**
* Creates a new feed on behalf of a user.
*
* #param string $url
* Feed URL
* #param numeric $uid
* {users}.uid of the user for whom this feed is being created.
*/
function _MY_MODULE_create_feed($url, $uid) {
// #todo Add more validations here
$node = new stdClass();
$node->uid = $uid;
$node->type = 'feed';
$node->feeds['FeedsHTTPFetcher']['source'] = $url;
$node->language = language_default('language');
node_save($node);
}

How can i extract attachments from salesforce?

I need to extract attatchments out of salesforce? I need to transfer some notes and attachments into another environmant. I am able to extract the notes but not sure how to go about extracting the attatchments
Thanks
Prady
This mostly depends on what tools/utilities you use to extract. The SOQL for Attachment sObject will always return one row at a time if Body field is included in the query. This is enforced to conserver resources and prevent overbearing SOQL scripts.
Approach #1, if queryMore is not available: Issue a SOQL without Body field to enumerate all attachments, then issue one SOQL per attachment ID to retrieve Body
Approach #2: Issue a SOQL to retrieve all needed attachments then loop using queryMore to get them one at a time.
Approach #3: If you can "freeze" the SF environment and just want to take snapshot of the system to pre-load a different one to be used going forward you can use "data exports". In setup menu, in data management there is an export data command, make sure you click "Include in export" to include all binary data. After due process it will give you a complete data backup you can crunch offline.
Btw, body is base64 encoded, you'll need to decode it to get the actual binary
Here is the solution I've used to get the attachment binary content from SalesForce. The example in their documentation points the following:
curl
https://na1.salesforce.com/services/data/v20.0/sobjects/Document/015D0000000NdJOIA0/body
-H "Authorization: Bearer token"
So there are a couple different elements here. The host (https://na1.salesforce.com) you should be able to get after the login process, this host is session based so it can always change. Second element is the rest of the URL, that you will get from the "body" field of the Attachment object. Third and last element is the Authorization header, which is composed by the string "Bearer ", plus the token that is given to you after you authenticate with the SF backend.
The response is the binary file, it is NOT in base64, just save it to a file and you are good to go.
Here is an example of how I did it in Objective C:
// How to get the correct host, since that is configured after the login.
NSURL * host = [[[[SFRestAPI sharedInstance] coordinator] credentials] instanceUrl];
// The field Body contains the partial URL to get the file content
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:#"%#%#", [host absoluteString], {AttachmentObject}.body]];
// Creating the Authorization header. Important to add the "Bearer " before the token
NSString *authHeader = [NSString stringWithFormat:#"Bearer %#",[[[[SFRestAPI sharedInstance] coordinator] credentials] accessToken]];
NSMutableURLRequest * urlRequest = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0];
[urlRequest addValue:authHeader forHTTPHeaderField:#"Authorization"];
[urlRequest setHTTPMethod:#"GET"];
urlConnection = [NSURLConnection connectionWithRequest:urlRequest delegate:self];
Hope it helps.
You can use SOQl Query options, or if you are looking for some automation tool that will help you with quick export, then you can try AppExchange App Satrang Mass File Download - https://appexchange.salesforce.com/listingDetail?listingId=a0N3A00000EcsAOUAZ&tab=e
Disclaimer: I work at Satrang Technologies, the publisher of this Mass File Download AppExchange App.
In SalesForce attachment will be against an Object for e.g. Account object.
Steps to retrieve attachment (in Java)
Get the ID of the Object to which a file is attached. e.q. Account Object
String pid = Account__r().getId();
Execute a Query on Salesforce Object "Attachment" for the ID in Step 1
*String q = "Select Name, Body, ContentType from Attachment
where ParentId = '" + pid + "'";
QueryResult qr = connection.query(q);
SObject[] sarr = qr.getRecords();*
SObject so = sarr[0];
Typecast Salesforce Generic Object (SObject) to "Attachment" object
*Attachment att = (Attachment)so;*
Retrieve the Byte Array Stream from Body of Attachment, and do the operation needed on byte array.
*byte[] bName = att.getBody();
// Do your operation in byte array stream*

Resources