I am sending an email using the following code. But it shows up in my email as from "me#gmail.com" also when I press reply on the email it wants to send it to "me#gmail.com"
Don't know if I've done something wrong or?
$this->email->from($this->input->post('email'), $this->input->post('thename'));
$this->email->reply_to($this->input->post('email'), $this->input->post('thename'));
$this->email->to('me#gmail.com');
$this->email->subject('New Feedback');
$this->email->message($this->input->post('message'));
$this->email->send();
I set up a simple email test in CodeIgniter v 2.1.2 as follows:
$this->email->from('malcom#awdoffice.com','Malcom');
$this->email->reply_to('awd#awdoffice.com','AWD');
$this->email->to('marc#awdoffice.com');
$this->email->subject('Subject Mailer-Test');
$this->email->message('Lorem est email.');
$this->email->send();
$rc_email = $this->email->print_debugger();
I suggest that you go through the following debugging procedure.
(1) Hard code all email addresses and names in the from and reply_to setters. Test to see if the problem still exist.
(2) If step (1) fixes the problem, then something may be wrong with your input variables so try printing out the variables (append to email body text).
(3) Print out the text returned from print_debugger
(4) I tested the email in Mozilla Thunderbird and the from, reply_to and to fields worked as expected. What email client are you using? what email server (if testing locally)?
Please keep us posted with your progress.
I figured it out. I had uploaded the site to my "real" server and forgot to change the baseurl of the site.. I still had it as localhost. So whenever I sent an email it was using my localhost and the from email I had setup in phpmailer.
I know quite a silly mistake, but being up for 20+ hours can do that to someone.
Thanks for all the help.
Related
I've been searching a lot, but can't really find what i exactly need.
Im running a shop-online using XAMPP, and what i want is send emails to the customers with their order but using a specific function.
What this fuction does, is to hide some characters (for security purpose) on the email sent to customers. So i've made the function (looking on internet), but i want to test it now.
This is my function (if it's wrong, i'd really appreciate some help):
<?php
function xtc_hide_iban ($iban) {
$length = strlen($iban);
$lchars = substr($iban,0 ,5);
$rchars = substr($iban, -5);
$iban_hidden = $lchars.str_repeat('*',$length-10).$rchars;
return $iban_hidden;
}
?>
I think it's pretty obvious what i try to do, but i will still explain it:
Get the $iban from customers, and show only the first and last 5
characters when the email is sent e.G
Your IBAN is 'DE123************56789'
So, for now i can send emails from Mercury mail server to 'root#localhost',account i made on thunderbird, (it's the only account that worked for me, because any other with the same server, like 'anyname#localhost' didn't work or couldn't be created, and those who were create with imap before couldn't access to the inbox "could not connected to server, connection refuse", anyway this works with POP3)
Following what i looked before, is that somehow and somewhere i can put a *.php on Mercury folder so i will get a template of how to send the mails (headers, subject,body,etc).
My main question is how and where to do that? make a test php file to make sure my code is doing what i want to do
Thanks in advance
I just want to ask because I tried to send an email with a link. The problem is the link.
http://mysite/samplesite/login/confirm_email/qwVBEkXFqCp9BQLvKWNBPpWzOo2Ryx
becomes
http://mysite/samplesite/login/confirm_email/qwVBEkXFqCp=BQLvKWNBPpWzOo2Ryx
As you notice, the 9 became =.
I tried changing my mailtype as text and it work but how to solve it having mailtype as html?
I use the PHP Mailer for send email... Thats already makes the necessary settings for authentication and integrity of your email code in html. Always works for me.
Download PHPMailer: http://sourceforge.net/projects/phpmailer/
How to use: http://phpmailer.worxware.com/
I'm using modMail class to send custom emails. I have followed the guidelines on MODX site and used the following code which I placed in a snippet:
$message = $modx->getChunk('myEmailTemplate');
$modx->getService('mail', 'mail.modPHPMailer');
$modx->mail->set(modMail::MAIL_BODY,$message);
$modx->mail->set(modMail::MAIL_FROM,'me#example.org');
$modx->mail->set(modMail::MAIL_FROM_NAME,'Johnny Tester');
$modx->mail->set(modMail::MAIL_SUBJECT,'Check out my new email template!');
$modx->mail->address('to','user#example.com');
$modx->mail->address('reply-to','me#xexample.org');
$modx->mail->setHTML(true);
if (!$modx->mail->send()) {
$modx->log(modX::LOG_LEVEL_ERROR,'An error occurred while trying to send the email: '.$modx->mail->mailer->ErrorInfo);
}
$modx->mail->reset();
The snippet has been modified to contain message from custom chunk as well as email addresses have been replaced with the correct ones. The snippet sent email once and never again. I have no idea what causes such behavior which prevents it from sending emails.
I have read that using the reset function $modx->mail->reset(); resets email fields and allows the email to be sent again yet I have a feeling that it causes problem here.
The snippet is called uncached on the page [[!email]]
Does anyone have an idea why the emails are not being sent, even though it worked once?
if there is an error in your chunk or in processing your chunk, modx is never going to get to thepoint where it logs an error. try something like:
if (!$modx->mail->send()) {
$modx->log(modX::LOG_LEVEL_ERROR,'An error occurred while trying to send the email: '.$modx->mail->mailer->ErrorInfo);
}else{
$modx->log(modX::LOG_LEVEL_ERROR,'This mail was sent: '.$message);
}
to see if it logs something. but otherwise what you have there is exactly correct - try to take the $message variable out and send just a string. if it sent mail once, then something else must be wrong. I'd start looking at mail server logs, headers, spam [gmail??] etc.
I've found a couple online services that do this, and I found this post at stackoverflow about it:
How to check if an email address exists without sending an email?
The problem is that the PHP script linked to there requires you to populate a list of nameservers and domains, and thus (I think) only works if you are validating emails on a known domain. I want something that will work for any email (at least work with a high probability). I found a script that does it that I can buy for $40, but I'd rather find the same thing as open source.
Thanks for any advice,
Jonah
This:
$emailValidation = /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")#(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/;
if(preg_match($emailValidation, $testEmail)) {
echo "valid email.";
} else {
echo "invalid email.";
}
Is a well used email validation regex, which is PHP compatible.
Just check email addresses against it and you're done.
But note that without a confirmation postback you will never know that an email is 100% valid.
I'm having trouble when sending emails thorough the mail() function.
I have a script that works perfectly fine for an email address like name#domain.com but when the first part of the email is something with a dot like name.surname#domain.com it doesn't work and returns this error :
Warning: mail() [function.mail ]: SMTP server response: 554 : Recipient address rejected: Relay access denied in confirmed.php on line 119
I am using real email address but have changed it in the above example.
Any thoughts - I'm not a php master but surely there is an easy way to send emails to address with a 2 part first section??
Thanks in advance
Ali
It is not PHP's fault. It is your SMTP-server. Check mail log i.e. /var/log/mail.log and see if it puts out anything. My best guess is that your relaying is missconfigured.
If the code below fails with this error, then DeeD is partially correct - but it's not relaying which is broken - the address re-writing rules are completely ^&*(ed up.
<php
mail('name.surname#domain.com','hello','test');
?>
Also try:
However this would be a phenomonally stupid error on the part of the person who set up the MTA. I susepct its much more likely that code elsewhere may be modifying the address before the call to mail(...) or that your analysis is incomplete. If this is the case, then neither of the tests above will return the original error - instrument your code to find out where the address is being changed.
Alternatively, if the MTA really doesn't like a . in the name - go buy a cattle prod for the person who configured it.
C.