Change hyperlink when sending group mails - php

When sending a group mail about assigning to a newsletter, I need to create a hyperlink button which redirects to: example.com/action.php?id=11 ... email=<%email>
I need to change the <%email> area depending on the recipient's email...
I've done some research, but haven't come up with any solution.
Thanks for any response.

assign variable in code eg
$email = "someone#somewhere.com";
include the variable with the string eg.
echo "example.com/action.php?id=11&email=$email";

You can keep something like <%email> as placeholder text in mail body of each mail text in group mail and later you can replace this with your original email by using str_replace() function when you actually sending mail in your loop before sending mail.
provide complete code you are trying to do so we can help you more with it.

Related

Send a fancy mail with PHPMailer from Beefree

I want to send an email with PHPMailer. The mail is a HTML made up mail with Beefree. First the whole email was a PHP variable, but then I get the email with the first part repeated. I think this is a result of having a head in the body, but I'm not sure.
To clear this out the mail I want to send is this (with fancy lay-out):
[image]
Hello John,
How are you?
Best regards!
But it is send like this:
[image]
Hello $name,
[image]
Hello $name,
<div style="Margin: 0 auto;min-width: 320px;max-width: 600px;ov
Now I saved my mail as beefree.php. It is possible to send it like this:
$mail->msgHTML(file_get_contents('beefree.php'));
The file is now send with a correct lay-out, but with variables, like 'Hello $name'.
To solve this I can do this:
ob_start();
include 'beefree.php'; //execute the file as php
$body = ob_get_clean();
and send it like this:
$mail->msgHTML($body);
Then the variables are inserted, I see the real name, but the email is like the second mail-example, except the real name is visible. The problem is why it has repeated parts and not the whole email. How can I send the mail like in the file_get_contents, but with the correct variables?

Processing html mail using phpmailer mail->Body fetching mail body using imap_fetchbody

Okay. So what i did was that i retrieved the body of an email using imap_fetchbody and forward the contents in it to another user's email using mail->Body.
The following are the 2 different formats of the mail i get from different settings:
eg1:
mail->isHtml(true);
eg2:
mail->isHtml(false);
The result i want to have is eg2 but i need to insert html code into the mail itself hence i cannot have mail->isHtml(false), i need it to be true. I'm not sure why this is happening but i realize that the cause in difference in formatting is due to this mail->isHtm() property.
What can i do?
Any help here will be greatly appreciated.

HTML in php mail function

I have a contact form on my website so users can send me an email but I have run into a problem.
I want to use an HTML link inside the email and I also want the content the user is sending to me to be formated how they would like it.... let me explain.
If a user sends this:
Hello World!
Isnt it a great Day?
without using headers to enable html, then it says formated like that when it reaches me.
If I use headers (MIME) to enable html, to also include a link in the email (which I would like to do), then it reaches me as:
Hello World!Isnt it a great Day?
How can I include html, and also keep the email formatted properly?
Thanks
And hopefully all this makes sense :S
Use nl2br on your message - http://php.net/manual/en/function.nl2br.php
It will replace all newlines with HTML <br>
$message = nl2br($message, false);
The second parameter *is_xhtml* is optional if you want to send an HTML email instead of XHTML

Use PHPmailer or regualer PHP mail to send text: From $Phone-Number

Can I send a text message using PHP or PHPmailer and in the return use a phone number and not an email?
PHP mail() and PHPmailer makes me use a valid email with an "#" symbol. Is there a way around this?
You can put whatever you want in the from field, but don't expect your mail server, or the receiving mail server to accept it.
Better to set your from: field to something like this instead:
"123-123-1234 <noreply#yourdomain.com>"
That way, you can have a valid from address, and still display a number to the end user.

block sending emails that are not from a specific domain

I would like to filter emails sent. Emails are sent with the PHP mail() function. I would like, without modifying any PHP file if possible, to let emails out only emails that are to a specific domain, and not others. I don't have access to the SMTP server.
Just in case this helps someone ... If the emails are sent after a form is submitted (or similar action), you could change the action attribute of the form html element to point to a new php file that acts as a filter. Once passed (if so) you redirect to the "proper" destination to send the emails. The filtering could be something as easy as:
$good = "*#mydomain.foo, *#localhost";
$good = explode(',', $good);
if (pattern_grep($_POST['email'], $good)) {
// action
}
You should be able to look at the associative array for the "to" field and use the php regex class to match domains that you blacklist.

Categories