I wrote a code for fetching mail from the inbox in php. It is working well . But actually i need to take the link contained in the message.. I want to take the link address which are came in the message part. Can you help me for doing this..
Cant really help like this , too little information and sample .. but i would say use a regular expression to get the links out of the email .. this would vary ofcourse if the email is HTML or plain text etc.
If you have influence on the content of the emails, make them so that the link is always on a certain line. Then walk through the email until you reach that line, then use it.
If you don't have influence on the email, definitely use a regular expression.
Related
I am using PHPMailer, I have set it all up and working everything is fine, however I have run into a problem.
I need for each recipient to receive the HTML slightly different which is a link within the HTML email. So the link would have to change for each recipient.
I could simply use a php loop that sends it one by one to each recipient, however this will take a lot of processing and could time out the request I do not want this to happen.
Is there away I can use shortcodes using curly brackets as you would on most wysiwyg editors {email} so then I do $mail->send() once as oppose to loop through all of the recipients and do $mail->send() for each one, which I am trying to avoid.
If you need any more information I am happy to edit this question.
https://code.google.com/a/apache-extras.org/p/phpmailer/
I don't think you can do that using only PHPMailer. I had a look at the class methods, nothing linked to such a thing.
Worx International Inc. has another solution called PHPMailer-ML that could provide a good solution to your needs : http://phpmailer.worxware.com/index.php?pg=phpmailerml
I have a form on a webpage which emails the details using the PHP mail() function. The form is quite long, and I also am including HTML formatting for the email.
The email sends fine if I don't include all the form information, but when I try to include the whole form the email doesn't get sent. It seems to stop working when I'm including too much information. As soon as I take some of the information out it works again, and it doesn't matter which part of the information I remove.
I have tried the form on two different website hosts with the same problem. The content for the email is only about 300 lines long so I'm not sure if size is the issue.
Does anyone know what might be causing the problem?
here is my code for your reference
When I say "stop working" above, I mean simply that the mail() function returns false and does not send the email. The actual form works fine.
When you come to that amount of HTML within a PHP-script it is useful to catch it in a variable instead of putting every single line in a $body variable.
ob_start();
?>
<html>
Your HTML.
</html>
<?
$body = ob_get_clean();
This way you can easier see if there is something wrong with your message ruining the mail-function.
Here is a description of the php mail function. This document along with this document, What is the PHP Mail Character Limit, specifies that each line of the body must be no longer than 70 characters.
This stackoverflow, What is the maximum length of a string in PHP, as well as other sources indicate that PHP does not have a specific limit other than total memory limits which your string appears to be well under.
Also there are several different places where there could be a failure and you do not specify the behavior you are seeing for a failure.
First of all, check the return value of mail() to determine if PHP was able to hand the message off to the mail agent, the MTA. Next make sure that you specify good to and return addresses so that if there is a problem in the mail agent, it will be able to send you some kind of a reply describing the problem.
An elaboration of the answer provided by Undrium above. Here are some links to additional materials based on his answer.
Here is the ob_get_clean() documentation.
Here is an example using ob_get_clear() with sending HTML Email.
Basically I'd be getting an email once a month that contains a link and some text. I need to be able to grab the link from the email and somehow get it to submit the URL to a database. I can do the database stuff on my own, so I just need to know if it's possible to automatically retrieve the URL from the email every month.
If this isn't something I could do with PHP, what other languages could I do it that are common to web servers? Or maybe there's a service that does this somehow?
I don't know if it's the proper way or not to accomplish your task, but this is something that will work.
Say that you want to check your email for new mails each 1 day, then set a cron job each 24h that executes a php file (you can set it as frequent as you want but some web hosting services limit it). In this file you need the code for retrieving your mail (whatever you use) and some code to parse the email and differentiate regular text from the link.
To do this, if the link is a regular html link, just search for "http" and then copy everything after it to the next " ", if it's user-written, you might get to work much more to parse it and avoid bugs, or you might get a different protocol. Just work the file and if you have any question come back to ask again.
EDIT: To answer the actual question, YES, it is possible using cron jobs or some less common alternatives
I am using imap to grap emails and insert them into a mysql database. But I don't want the original email included.
So lets say I send out an email that contains this:
Hello, How is the weather.
And then you respond
The weather is great
The email that php reads from Imap looks like this:
The weather is great
Hello, How is the weather.
Is there away to remove the orginal message, "Hello, How is the weather."?
I am not to savvy on this stuff and will probably need things explained very clearly. Thanks!
Nope. Since there is no standard way to reply (i.e., some people use >, some use |, some top-post, some intermix, some attach) there's no way to accurately and reliably pull out the original. You could fiddle with regexp to catch some of the more common cases, but I think you'll find that route to be far more trouble than it's worth.
To my knowledge, there is no foolproof way to do this. When you reply to an email, the MUA has the right to reformat the original message as it sees fit. For example, Outlook may convert the original text to HTML and add invisible tags.
If you have access to the whole email thread, you may be able to find the original message based on subject or any hints that the headers give you.
This is all AFAIK, so someone please correct me if I am wrong.
You could do what Gmail does when you are sending multiple emails back and forth with the same subject.
Just keep a copy of the email that you send and then when you get a reply, look for similar text or as Gmail refers to it: "quoted text".
Or you can look for certain patterns based on their email domain. However, there is no answer that will work 100% of the time; it is all just based on your best guess.
I have a place where I want users to submit emails for newsletter subs and a place to submit an entire contact form. Zero php knowledge outside of know that it can do what I need.
There's a mail function built-in, take a look at
http://php.net/manual/en/function.mail.php
you will however, need to format the email body with the form data posted, of course.
Check out FormToEmail. From their site:
FormToEmail is a PHP form mail script.
It comes in a free version and a Pro
version. It processes web forms and
sends the contents of the form to you
by email. It will process any form. It
doesn't make forms but it comes with
HTML code for a basic contact form
that you can use on your website. It
is very secure and cannot be hijacked
by spammers. It is very simple to
install, you only need to add your
email address to it. Step-by-step
instructions written in plain English.
Actually, you don't need to do any php programming to create a such a setup. There are plenty of mailing list software apps available and you can grab a formmail script (like the one from Matt's Script Archive) and build the html with the right fields.
Use the mail function.
However be aware that you need to specify the correct headers yourself if you want to use html in your emails!
A common beginner's mistake is assuming you can simply use html tags with mail and it should work automatically.
Figured this was worth mentioning, since you are wanting to do a newsletter. If you try sending the email, and the raw html tags seem to appear in the message, this is your issue :)
As someone who is a PHP know-nothing, I often look for easy solutions to complex problems. Using a super simple PHP form can have some downsides such as getting massive amounts of spam if you don't have any measures to prevent that, setting up those measures is hard to do if you do not have any knowledge of PHP.
Here is what I found, there is a script here: http://www.dagondesign.com/articles/secure-php-form-mailer-script/
that you can download at no charge and the developer seems to have a lot guidance on how to install and use. I was able to set it up and get it to work.. not without having to spend quite of bit of time reading and trouble shooting. Hope that helps you.