I am trying to send out 100 emails with HTML text body as follows :
Hello XYZ, I went to your Company X in PlaceY yesterday and was
impressed. I want to propose to you ProductZ. XYZ would be benefited by Productz
Subheading in Bold Are you interested?
Thanks
I want a tool where I can input XYZ, X, PlaceY and ProductZ just once and it fill it everywhere instead of having me manually edit the whole thing, and gives me an HTML content I can copy paste to my email client (Thunderbird)
Any advice on such a tool/or process
Thanks
using php is very easy
only need to add a PHP tags to open before the code and after de code to close it , i give you a function that can do what you want to do
/* " <?PHP" <- to open the tag, and, "?>" <- to close the tag */
<?PHP function sendemail($XYZ, $X, $PlaceY, $ProductZ, $emailto)
{
$subject = "your subject here";
$body = "<html><body>Hello $XYZ, I went to your Company $X in $PlaceY yesterday and was impressed. I want to propose to you $ProductZ. $XYZ would be benefited by $Productz <br><br><b>Subheading in Bold<b><br> Are you interested?<br><br>Thanks</body></html>";
$headers = "From: fromemail#yourdomain.com \r\n" ;
$headers .= 'Content-Type: text/html; charset=ISO-8859-1' . "\r\n";
"X-Mailer: php";
if (mail($emailto, $subject, $body, $headers))
{
return 1;
}
} ?>
Related
The below code able to read the content of file and print the content of body with the file's content.
use strict;
my $filename = '.../text.txt';
open (my $ifh, '<', $filename)
or die "Could not open file '$filename' $!";
local $/ = undef;
my #row = (<$ifh>)[0..9];
close ($ifh);
print "#row\n";
my ($body) = #_;
my ($html_body)= #_;
.
.
.
print(MAIL "Subject: Important Announcement \n");
.
.
.
push(#$html_body, "<h1><b><font color= red ><u>ATTENTION!</u></b></h1></font><br>");
push(#$html_body, "#row");
.
.
.
print(MAIL "$body", "#$html_body");
close(MAIL);
But unfortunately, i am having problem to produce the email body with same format of the text.txt file. The output email produced only having single line instead of paragraphs of 3.
The problem you're facing is that plain text contains no formatting information when placed inside a HTML document. End of line characters are ignored and treated just like ordinary white space. You need to add HTML tags to the text to convey the formatting you want or you could wrap it up in a pre tag as that will display it "as is".
As mentioned by others in the comments above, your use of #_ doesn't make sense. And it doesn't really make sense for $html_body to be treated like an array either when all you're doing is appending HTML to it. So I've rewritten that chunk of code to use it as a scalar and append the HTML to it instead. And also fixed some mistakes in the HTML as you need to close tags in the same order as you open them.
print MAIL "Subject: Important Announcement \n";
print MAIL "\n"; # Need a blank line after the header to show it's finished
my $html_body = "<html><body>";
$html_body .= "<h1><b><font color="red"><u>ATTENTION!</u></font></b></h1>";
$html_body .= "<pre>";
$html_body .= join("", #row);
$html_body .= "</pre>";
$html_body .= "</body></html>";
print MAIL $html_body;
close(MAIL);
First of all #_ is an arrayof arguments passed to subroutines, and it looks like you're not in one. So, doing:
my ($body) = #_;
my ($html_body) = #_;
is setting $body & $html_body to $_[0], which is undef.
How to fix?
There are two ways if you wrap it in a subroutine:
Use shift -> Which will make the above code look like:
my ($body) = shift;
my ($html_body)= shift;
Or,
my ($body, $html_body) = #_;
I would recommend the last one because it is less code and is more readable than the first one.
I am using the following PHP code to send e-mail when the users submits a form.
$to = 'mail#example.com';
$subject = 'Thank you for your mail ' . $mailRefrence . ' - www.example.com';
$headers = "From: " . 'info#example.com' . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$message = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <meta http-equiv='Content-Type' content='text/html;.......";
$message .= $mailReference;
mail($to, $subject, $message, $headers);
Please note that the HTML-code inside the $message-variable is much longer, I've just removed it due to it is way to long to be pasted here. The source code is available here: http://zurb.com/playground/projects/responsive-email-templates/basic.html
However, when the mail is sent to the user, there is random spaces in the text. Sometimes the spaces appear in the text, and sometimes in the code which often ruins the whole design of the mail.
Does anyone have an idea why this happens and how to solve it?
Use trim
http://php.net/manual/en/function.trim.php
this will remove white space
Hello guys I am working on webapplication for sending multimedia messages upon user input of their phone numbers. I am successfully able to send emails with images in HTML form. Now, I am trying to send my customers MMS via PHP mail function, but the only thing they receive is the link that I send them with the message.
Here is what I have come up with so far.
<?php
$email = '1234567890#somenetwork.domain';
$link = $_COOKIE["coupon"];
$to = $email;
$subject = 'Some Subject';
$message = " Hello, This is Testing Text 8.0
<a href=\"https://encrypted-tbn0.gstatic.com/images? \
q=tbn:ANd9GcS0dA2aipmy9hwAitgD8U5n8l_afNBvxYc3gnOFi7hOGoGAGIHssw\">Your Link</a> ";
$message->addAttachment("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS0dA2aipmy9hwAitgD8U5n8l_afNBvxYc3gnOFi7hOGoGAGIHssw", "image/gif");
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: someone <support#someone.com>' . "\r\n";
mail($email, $subject, $message, $headers);
?>
When sending to a phone as MMS, you have to send the image as an attachment.
I found the following answer to be very helpful for easily sending attachments, even though it references "mail", not MMS:
Send attachments with PHP Mail()?
One of the issues is that you can't fetch that image in that fashion.
I.e. https://encrypted-tbn0.gstatic.com/images?\
q=tbn:ANd9GcS0dA2aipmy9hwAitgD8U5n8l_afNBvxYc3gnOFi7hOGoGAGIHssw
returns an empty file.
Also, since when can you send MMS via PHP's mail() function?
The most reliable way in my experience to send images via SMS/MMS is to send a WAP push msg.
I was building a email functionality for my website and I am using PHP mail function. The issue I am having is that when I try to email a client with a image inside a message it takes forever(20-45 minutes) to get to them and when I just include text it gets to them right away. Is there solution to this. Thanks for any help.
<?php
$email = $_COOKIE["email"];
$link = $_COOKIE["coupon"];
$to = $email;
$subject = 'Your ads';
$message = ' Hello This is Testing Email 3.0 Text & Image Your Coupon Link
<img src="$link" width="300" height="300"/> ';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Ads <ads#advertising.com>' . "\r\n";
mail($email, $subject, $message, $headers);
?>
According to your code, you mail is a top tier Spam grade for almost all anti spamming mailing protection.
They will most likely put your mail in a slow queue because of that, delaying the message because it was considered an annoyance.
Your From header contains 'ads' and 'advertising' (even if I guess that advertising.com isn't your domain.
You also have little to no text, the word test in it and a big link button named "coupon".
You should try to make your email more personal.
This is the most likely problem.
Second one would be the file transfer.
If you're transferring from China to New-York with a 56kb/s connection, the file transfer will take long enough for your recipient to die from old age.
For your second problem, replace
$message = ' Hello This is Testing Email 3.0 Text & Image Your Coupon Link
<img src="$link" width="300" height="300"/> ';
by
$message = ' Hello This is Testing Email 3.0 Text & Image Your Coupon Link
<img src="' . $link . '" width="300" height="300"/> ';
I need to send a lot of numbers over so want to change the font to Courier.
HGow do I do this? My constructs are...
$message = "Contact : ".$_SESSION["Contact"]."\n\r".
...
$mail_sent = #mail( $to, $subject, $message, $headers );
When I try simple tests like bold on/off or spans suggested elsewhere they just appear as the text and are transmitted and appear identically in Outlook and my iPhone. Any ideas?
It seems that you are using php, so the next syntax should work. Just add the next headers to what you already have or replace the one you have with similar content:
$headers .= "Content-Type: text/html; charset=utf-8\r\n";
$headers .= "MIME-Version: 1.0\r\n";
And change your text to something like this:
$message = "Contact : "<span style="font-face:courier;">.$_SESSION["Contact"]<span>."\n\r".
I'm assuming that line is the one with the numbers you want to format. But of course you can modify any line in your message
Bye