I have this:
open(MAIL,"|/usr/sbin/sendmail -t");
## Mail Header
print MAIL "To: $GLOB_OPT{email}\n";
print MAIL "From: $GLOB_OPT{from}\n";
print MAIL "Subject: $GLOB_OPT{sub}\n";
print MAIL qq|Content-Type: text/html; charset=us-ascii\n|;
print MAIL qq|Content-Transfer-Encoding: 7bit\n|;
print MAIL qq|MIME-Version: 1.0\n\n|;
print MAIL qq|<h3>Download File :</h3><br>|;
print MAIL qq|Click Here|;
close(MAIL);
I want to send the hyperlink to user so they can download the csv file in the $GLOB_OPT{html} path.
When I open the link in my email, it opens the csv in the browser. I want instead the browser to download the file. What can i do?
Try using content-disposition in http headers on the webserver's side. This even works with .htaccess.
As far as I understand, the way you send the e-mail has little to do with the save/display choice in the browser.
Don't use the system sendmail command. Instead use the MIME::Lite module.
They have a coding example that pretty much does exactly what you want to do.
This way, you're not depending upon an external command that may or may not work (depending upon the system and its configuration).
You could output the CSV via a script which sends to the browser first mime-header "application/octet-stream" instead of the default
MIME type sent by apache(or the used server). You can also configure the server to send the header it self by associating the .csv extension with "application/octet-stream" mime type.
see also The apache docs
Related
How I did understand, message/delivery-status is a mime type of message part,
which contains the data formatted for the mail server to read (Wiki)
Does it mean that I can ignore it while receiving message from mail server? If not, could you give more explanation of present mime type.
How should I parse it and do I need to present it to user?
I found it on official specifications https://www.rfc-editor.org/rfc/rfc3464#section-2.1
We send out password-reset emails to business partners who use our intranet. The body of the email contains a hyperlink:
`http://www.ourdomain.com/ResetPassword.aspx?token=....`
But some of the people who receive these emails are saying there's an extra dot in the domain name:
`http://www.ourdomain..com/ResetPassword.aspx?token=....`
I do not see where that could be happening in the program I've written. I store the base url in the web.config:
`http://www.ourdomain.com`
and attach the name of the aspx page and append the token to it.
Are there any corporate anti-virus programs out there which deliberately mangle hyperlinks discovered in the body of emails, to render them invalid and thus unclickable?
This seems to be per the spec of quoted-printable encoding. It just so happens that the length of text in the message breaks to a new line right at the .com (72 characters maybe?). Please verify that this is the case by sending yourself a message and analyzing the quoted-printable source of the message.
System.Net.Mail creating invalid emails and eml files? Inserting extra dots in host names
The solution would be to not use quoted-printable encoding if some email programs cannot correctly interpret the spec.
plainText.TransferEncoding = System.Net.Mime.TransferEncoding.SevenBit;
//or base64
I want to know more about the resent headers (resent-from, resent-to, resent-date etc) that get prepended to an email's header.
When do these headers get added? Do they get added by the server or the mail client program?
I need to write a Java program using JavaMail api to forward an email (without changing or parsing through it's original content). I would like the email to be redirected to the destination email address on arriving at the server for a specific recepient.
Any snippet where you have been able to forward / redirect a mime mail using the resent headers will be helpful.
Thank you
See section 3.6.6 of RFC 2822.
You should be able to use JavaMail to add these headers to a message. If the message was read from a folder on a mail server, you'll need to make a copy of the message first before you can change it. Use the MimeMessage copy constructor. You can then send it to whatever address you want, ignoring the addresses in the message, by using the Transport.send method that takes an array of addresses. If you need to preserve the original Message-ID (which may not be appropriate since you're modifying the message), you'll need to subclass MimeMessage and override the updateHeaders method.
I am using spring integration for a process which ends in an email being sent.
However, it is an HTML email and I receive the source for it, not the rendered HTML.
I have tried to use the mail header enricher provided with spring-integration-mail 2.1.4 to set the content type or activate multipart without result.
Can it be done with the mail header enricher or is it supposed to be configured in some other way?
A pure XML configuration preferable.
Yes you can send HTML via the XML configuration, you just need to set the content type as you said via the header enricher, example code below.
<int-mail:header-enricher id="emailheaderenricher">
<int-mail:content-type value="text/html;"/>
<int-mail:subject value="a subject"/>
<int-mail:to value="mail#somewhere.org"/>
<int-mail:from value="from#example.org"/>
</int-mail:header-enricher>
Im sending out an order conformation for recipients via the simple mail function built into PHP, and this works fine. It's a "nice" email set up in tables and a few styles with the details in it
However a few of the recipients just see html tags, and of course can't understand anything..
If i get one, it shows perfectly in thunderbird, hotmail, gmail..
The html is perfect, not missing any end tags, and i send some headers also as i have read i should. this is my mail send function:
$body = "some html tags, set up in a table" ;
$sendto = "The recipients email here" ;
$subject = "subject here" ;
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
$headers .= "To: theemailhere <theemailhere>\r\n";
$headers .= 'From: <thefromemailhere>' . "\r\n";
mail($sendto, $subject, $body, $headers);
Is this an error from my side, or has the recipient chosen not to receive html emails? I mean is this still possible in 2012 and do people disable this??
And if so, what could be a good workaround to do this. I mean i would like to avoid using plain text.
Yes. There are really email clients which do not allow HTML emails. I guess older Outlooks are one of these, too, but not sure.
So, anyway, it is not your fault, it is the user's. See Source 1 and Source 2.
And you can never be sure what does the user's mail program accept. Only plaintext is surely accepted. Quoting Source 2:
"The best you can do is anticipate how each of the major clients will
break your design, and then try to control how it breaks, so that it’s
still readable by most of your recipients."
It can be solved only with multipart messages, but then some people will get plaintext. See Source 3 for some details on the issue and Source 4 for solutions.
Some documents on this: Source 1, Source 2, Source 3, Source 4
I've been using Zend_Mail recently (from ZF), which has the option to set a plain text message, and then a HTML message which overrides it where HTML is available. I'm unsure of how this is implemented in the message (headers/etc.) but this could be an answer to your problems.