Hallo I've got a problem with sending html E-mails with a dyanamic Link via PHP.
That is my PHP Code:
$empfaenger = $_POST['email'];
$test = sha1($_POST['email']);
$betreff = "Test Mail";
$from = "From: Peter <tets#gmail.com>\n";
$from .= "Reply-To: test16#gmail.com\n";
$from .= "Content-Type: text/html\n";
$text = "Please click <p><a href='http://defaultpage/default.php?res=".$test."'>here</a></p>.";
mail($empfaenger, $betreff, $text, $from);
In the mail Log all looks normal like the mail is sended, but I didn't receive one. In PHP error Log also nothing. If I set $test to a specified string it's working as expected, but not with the dyanamic variable $test. I hope that someone can help me becuse I can't get rid of this problem.
Related
I'm sending e-mails through a form I coded and for some reason, for some cases the e-mail address becomes junk, and for other times it works fine.
//on form page
$message = str_replace("#e",$emtemail,$message);
$message is stored in SQL (defined on another page), same for $emtemail. $message is just the body of the e-mail being sent, and I'm replacing all instances of #e with the e-mail people send payments to. It sends one e-mail to the customer, and one e-mail to me.
//customer e-mail
//the display address might appear as payment52.62gmail.com instead of payment#gmail.com
//my e-mail
//all e-mail addresses formatted properly without error, # appears as #
Why do e-mail addresses parse strangely? Something to do with encoding?
This is all of the code relevant to sending e-mails I have. I can't pinpoint the problem.
//any variables used in the below but not declared are previously initialized
$em = $userc["email"];
$subject = $emailone["subject"];
$subject = str_replace("#o",$ordernum,$subject);
$subject = str_replace("#u",htmlspecialchars($rn),$subject);
$subject = str_replace("#g",$gt,$subject);
$subject = str_replace("#sl","www.SZVapor.com",$subject);
$subject = str_replace("#ss","SZVapor.com",$subject);
$subject = str_replace("#st","SZVapor",$subject);
$message = nl2br($emailone["message"]);
$message = str_replace("#o",$ordernum,$message);
$message = str_replace("#u",htmlspecialchars($rn),$message);
$message = str_replace("#t",$table,$message);
$message = str_replace("#e",$emtemail,$message);
$message = str_replace("#g",$gt,$message);
$message = str_replace("#a",$addrsubmit,$message);
$message = str_replace("#sl","www.SZVapor.com",$message);
$message = str_replace("#ss","SZVapor.com",$message);
$message = str_replace("#st","SZVapor",$message);
$message = str_replace("#c",$em,$message);
$headers = "MIME-Version: 1.0"."\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1"."\r\n";
$headers .= "From: no-reply#SZVapor.com";
mail($em, $subject, $message, $headers);
Some examples of e-mail addresses given:
payment62.44gmail.com
payment54.45gmail.com
payment22.59gmail.com
payment25.49gmail.com
http://php.net/manual/en/function.mail.php
The first parameter entry for mail is the email address.
The code above does not do anything with $em
And by the way, I think that the last header line should look like this:
$headers .= "From: no-reply#SZVapor.com" . "\r\n";
I solved the issue, and it was an error on my part. I was replacing all instances of certain character combinations with variables.
#g = replaced with grand total
#e = replaced with payment e-mail
#o = replaced with order number
etc
The order I did them in was such that I replaced #e with the e-mail payment#gmail.com, and then replaced all #g with the grand total, so payment*#g*mail.com became "payment".$grandtotal."mail.com".
I'm using BlueHost and I can't seem to get my email form to work. This is the PHP:
$to = "test#email.com";
$subject = "test";
$message = "test message";
$from = $_POST['cf_email'];
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo $headers;
This doesn't seem to send the email. However, if I add ANY string in front of the email, then it works. e.g.:
$from = "zz".$_POST['cf_email'];
Can anyone tell me what I'm doing wrong? Thanks.
You cannot use any personal email ($_POST['cf_email']) in the 'From' header.
Also you have to add 'reply-to'.
Please check below thread for more info.
problem with php mail 'From' header
I have a simple php email script where I wish to include an image at the bottom. When I add the image tags like below the email just shows <img src="http://domain.com/images/logo.png" /> instead of the actual image. Any ideas why?
<?PHP
$email = $_POST["emailaddress"];
$to = "you#youremail.com";
$subject = "New Email Address for Mailing List";
$headers = "From: $email\n";
$headers .= "Content-type: text/html\r\n";
$message = "A visitor to your site has sent the following email address to be added to your mailing list.\n
Email Address: $email";
$user = "$email";
$usersubject = "Thank You";
$userheaders = "From: info#domain.com\n";
$usermessage =
"
Thank you for joining our mailing list.
We hope to see you very soon!
Address 1
Address 2
<img src=\"http://domain.com/images/logo.png\" />
";
mail($to,$subject,$message,$headers);
mail($user,$usersubject,$usermessage,$userheaders);
$fh = fopen("email.xml", "a");
fwrite($fh, "$email\r\n");
fclose($fh);
?>
You're not passing the Content-Type header with the right message. $headers does contain the right header, but it is sent with a plain text message, whereas $userheaders does not contain the Content-Type header, but the message associated with it does contain some HTML
Replace
$userheaders = "From: info#domain.com\n";
with
$userheaders = "From: info#domain.com\r\n";
$userheaders = "Content-type: text/html\r\n";
and it should work perfectly
This is a word press plugin but if you delete everything BUT the XmailBaby class it should work for you nicely.
That code is a nice piece of work that sends emails very good.
It is just a basic version but it should be enough for you.
Take a look through the code, you might find it interesting.
http://plugins.svn.wordpress.org/xmail-the-right-way/trunk/xmail.php
You need to specify html headers. Rather than do this yourself, you can use a well-established method that supports sending HTML emails, such as PHPMailer:
http://phpmailer.worxware.com/
I want to send the user an activation link after they registered an account. when I put this http://www.homeloan.com.sg in the $message I didn't receive the email, but when I remove the .sg and put http://www.homeloan.com it works. There's no error message, so I really don't know what's my mistake. Please help
here are my codes:
$id = mysql_insert_id();
$to = 'myemail#gmail.com';
$subject = "E-mail Verification";
$message = 'Click on the link to verify your account-> http://www.homeloan.com.sg/rates/activate?id='.$id.'';
$headers = "From: Homeloan Singapore" . "\r\n" . "Reply-To: enquiry#homeloan.com.sg";
mail($to,$subject,$message,$headers, '-f enquiry#homeloan.com.sg');
Make sure if your site have a form to fill, then fill the form correctly by assembling the input tag in the corresponded variable.
Try concatenating 'the email' to the variables ($...) with (.) or "...".
I really don't know what's my mistake
There is no mistake. I tried this code:
<?php
$id = 1;
$to = 'my_email#gmail.com';
$subject = "E-mail Verification";
$message = 'Click on the link to verify your account-> http://www.homeloan.com.sg/rates/activate?id='.$id;
$headers = "From: Homeloan Singapore" . "\r\n" . "Reply-To: enquiry#homeloan.com.sg";
mail($to,$subject,$message,$headers, '-f enquiry#homeloan.com.sg');
It arrived in the mailbox. Maybe, for your account it was put into spam folder?
I have a PHP contact form on my website. I have been using it for about a year now without any problems. Nothing has been updated on my website that has do to with the contact form. However, all of a sudden, when a user enters "line breaks" or "paragraphs" in the message box, when I receive the message, instead of having several paragraphs I have 1 long paragraph with "\r\n" in place of line breaks.
Here is the code:
$to = "info#mycompany123.com";
$headers = "From: $email";
$subject = $subject;
$body = "Name: $name\n\n"
. "Email: $email\n\n"
. "Subject: $subject\n\n"
. "Message: $message" ;
mail ($to, $subject, $body, $headers) ;
I really do not know why it started doing this out of the blue but any help is greatly appreciated!
try to convert your message using the nl2br($row['message']); function when you are displaying the messages.
$row['message'] is just an example, it can be any string.