I have created a small script that sends a multipart email via php the mail() (that has been a challenge in itself!).
When I test the script and send and email it all works fine, but when I try another address (one which has the same domain as the server) the email appears blank. All the content is there when you look at the raw code, but nothing displays.
I solved the problem by removing the doctype tag from the code and left everything bare coded.
I also noticed the php variable
$body=' (html code here) '
The whitespace after ' was causing the email to show up empty sometime... I'm not exactly sure why!
I have encountered a similar issue and it was because I had a website www.example.com sending an email to me#example.com but the web server and email servers were on different machines. I had to ask the host to sort it so that the website wouldn't try to route emails within the server itself.
I managed to sort this by changing my own code to instead using something a little more supported - phpMailer.
I found this very easy to use and install into my own code. Also giving me as much flexibility as I had with my original code.
I guess though this isn't sorting the original problem, but it did seem to sort on my code.
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.
I have a Joomla website up and running and need to set up a simple contact form.
The problem is, whenever Joomla tries to send an email, the page will hang for about a minute before I get a response. The mail will ultimately be sent fine, but the delay is way too big. I've tried setting the outgoing mail setting to PHP Mail, Sendmail and an SMTP server, all with the same effect.
Curiously, if I edit components/com_contact/controllers/contact.php and replace the lines that send the mail with a simple call to mail(), everything works fine.
Using Joomla 1.6.5, CentOS5 with PHP 5.3.
Anyone experienced something similar? Thanks in advance!
(Also, is this a case for StackOverflow or ServerFault? It seems borderline!)
Updated: Narrowed this down to PHPMailer using uniqid to generate its boundary strings. It seems that on some platforms, uniqid (without the more_entropy flag) is extremely slow.
If anyone else ever comes across the same problem, edit libraries/phpmailer/phpmailer.php and in the first few lines of the CreateHeader() function, pass true as the second argument of uniqid(). Seems to have fixed it.
Narrowed this down to PHPMailer using uniqid to generate its boundary strings. It seems that on some platforms, uniqid (without the more_entropy flag) is extremely slow.
If anyone else ever comes across the same problem, edit libraries/phpmailer/phpmailer.php and in the first few lines of the CreateHeader() function, pass true as the second argument of uniqid(). Seems to have fixed it.
I am trying to integrate IMAP email processing with another in house system that bases what it uses off of the subject line / email content.
We need to be able to change the text of the subject line before moving the email to a new folder. What/where would be a good place to start?
I've had a look around and it IS possible in a manual sense, via a thunderbird plugin or using outlook. I just can't seem to find a relevant example in PHP, or any other language for that matter. I also hear the idea is flakey at best as you need to modify the email content and upload it back to the imap server.
The outlook implementation seems to delete the original and save a new one to your IMAP folder on the server.
Side note: Yes I know it is a weird requirement, and although forwarding the email to ourselves then moving it is our fall back plan it is not much liked as it moves original headers useful for things like reply-all.
Any suggestions appreciated.
PS If I'm blind and there is something obvious I'm missing in the manual let me know.
Do you already have any code built to handle the email processing? IMAP subject line information is stored as a header so you would need to utilize the PHP functions of imap_headerinfo() and/or imap_fetchheader() depending on the functionality you're looking for to achieve this. You could have PHP check each message header and if it matches X format, remove the message, and create a new one with the appropriately modified header information.
Designing forms has always been fun, but getting them to send email on the server side is another story. I have used various email scripts (dynaform,phpmailer, etc), and have experienced a ton of problems.
So here is the site I am working on: Contact On the Right. It is very basic: no validation, no required fields. I simply need anything that is entered to be sent back to me.
Does anyone know of any BASIC PHP form processing scripts, or have a few lines of code that would work here? I'm not a PHP guy, so I am struggling!
Thanks in advance.
I simply need anything that is entered
to be sent back to me.
<?php
mail('your#mail.here','Site feedback',implode("\n\n",$_POST));
header("Location: thankyou.html");
?>
you can add this tag into thankyou.html:
<META HTTP-EQUIV="REFRESH" CONTENT="5;URL=http://v2.ztmag.com/livedates.html">
it will get user back in 5 seconds
For simple and hard tasks (it does HTML mail) this library always served me well: PHPMailer
Depending on servers and administrators, sometimes mail() doesn't work.
It must be configured to work correctly with smtp or have a sendmail binary installed in the correct path.
PHPMailer, instead, only needs outbound connection trough fsockopen not to be disabled.
A simple tutorial here:
http://www.ustrem.org/en/articles/send-mail-using-phpmailer-en/
A number of CMS uses it internally, too. Joomla, for example.