I am using fake mail for windows, For long time i got a problem with the FIRST mail i am sending, What i mean is that for example i am using php so i will use this line:
mail("example#gmail.com", "hey", "bye");
If i will load the page with this mail function for the first time the mail function will return false, But the second time and third and so on it will work, But, After some time i can not determine how long exactly, I can say the gmail mail server "going to sleep", And again when i am sending a mail for the first time its like, Ohh you need a mail to send give me a second(the first mail return false), After the mail server got the second it wanted it will send the mail(return true), I did follow this tut, The error appear at the error.log is: Connection Closed Gracefully., Now as i see it there is a problem on my gmail account(some setting i should change), Anyway If anyone got any idea i will be very thankful, Thank you all and have a nice day.
After researching this bug, it seems to be a bug of the mail() function. One alternative is to download the phpMailer library, and implement your mail function there. The other alternative, since you say that the second time it always works, is:
if (!mail("example#gmail.com", "hey", "bye"))
mail("example#gmail.com", "hey", "bye");
In other words, if it fails once then you try again. You might insert a 300-milisecond pause there in case Google needs some time to come back from sleep.
Related
Since yesterday I have had problems sending emails with Lumen. I think I have followed all the steps in the documentation correctly, but unfortunately I cannot send anything. Moreover, no error is displayed (I have activated APP_DEBUG=true), and I am sure that the credentials of the smtp server are correct. I also did composer require illuminate/mail.
Here are my modifications in bootstrap/app.php (I have $app->withFacades(); uncommented).
Here is my build function content: return $this->view('emails.mailTemplate', ['message' => $this->message]);.
And the line of code that ask to send mail: Mail::to("wewanthalflifethree#gmail.com")->send(new sendMail($destEmail, $subject, $message));.
Did I do something wrong? :/
Thx in advance for help!
EDIT: I just noticed something, the code stop working when I send the mail. If I add an echo after Mail::send, it will be appear on the page.
I have a problem with the Exceptions handler. By following this answer (which consists in adding a dd in the render function of Handler.php), I am now able to see what's going wrong.
So, here is the reason why my mail didn't send and why my page turned blank: Object of class Illuminate\Mail\Message could not be converted to string (View: /home/serveur-web/api.sl-projects.com/resources/views/emails/mailTemplate.blade.php).
The problem came from the fact that I was using the variable name $message, and this causes problems because it seems to be used in the class that handles the mails. My problem was therefore solved by renaming this variable $mailContent.
I hope this will help other people. :D
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'm using Zend_Mail and the following code to send my email messages.
$mail = new Zend_Mail('UTF-8');
$mail ->setBodyText($plainBody)
->setBodyHtml($htmlBody)
->setSubject($subject)
->setFrom(FROM_ADDR, FROM_NAME)
->addTo($email, $name )
->addHeader(MY_HEADER, serialize( array( 'foo' => 'bar' ) ) )
;
I need to check the spam rating for the prepared message and I'd like to do it using SpamAssassin.
I thought to create a file with the contents and running something such as exec('spamc $filename'), but how to get the file content with the full MIME body?
I noticed that there's a _buildBody() function in Zend_Mail_Abstract class (library/Zend/Mail/Transport/Abstract.php) that's return that, but that's a protected function.
Thanks
If you want to use SpamAssasin, then run your email message through spamc:
http://spamassassin.apache.org/full/3.1.x/doc/spamc.html
Spamc is the client half of the spamc/spamd pair. It should be used in
place of spamassassin in scripts to process mail. It will read the
mail from STDIN, and spool it to its connection to spamd, then read
the result back and print it to STDOUT. Spamc has extremely low
overhead in loading, so it should be much faster to load than the
whole spamassassin program.
You can do use in PHP by:
Writing the message into a temporary file and running shell_exec('spamc < message.tmp'), or
Running the command with proc_open() then send message via STDIN.
I am assuming you want to simulate a spam check on the recipient's end. That's an interesting idea, but note that the results it will give you will be far from 100% realistic. After all, it's the sending process that adds much of the vital information that helps determine whether an E-Mail is spam (e.g. the sender IP and routes.)
Anyway, to do this, you will probably have to implement a custom Zend_Mail_Transport class, based on the example of Zend_Mail_Transport_Smtp. Any data that transport class sends to the SMTP server, you would have to re-route to a text file. As far as I can see at a cursory glance, it's going to be a bit of work but not impossible.
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.
I want to create a script in php to read al mail from a mail acount. I connect to the server, I can see the mails but went I want to seet it back to unseen I can't find a function to do this.
If I understand this page correctly:
http://www.php.net/manual/en/function.imap-body.php
You can use the FT_PEEK option to leave the message as 'unread'.
EDIT AFTER YOUR COMMENTS
Have you looked at this method?:
http://www.php.net/manual/en/function.imap-clearflag-full.php
You are able to clear the \\Seen flag.